-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Code block annotations #1048
Comments
I've not looked into it yet but you should be able to do precisely the same kind of stuff as in the blog post; shell repl and code blocks have separate classes and so a different style can be applied to those. Have you tried copying whatever it is that they're doing for the styling of their code blocks on the rust blog post and see if it works for you? |
I'm not well versed in web technologies, but I got something that works halfway using .hljs::before {
content: attr(class);
position: absolute;
top: 0;
right: 0;
padding: 0.2rem 0.5rem;
background-color: #1d2735;
border-bottom-left-radius:10px;
font-size: 0.75rem;
font-weight: 700;
text-transform: uppercase;
} Since the Reading the highlightjs docs, it looks like access to the How can I make use of this in Franklin? |
ok so I was under the impression that there was one additional class, not just the |
would you mind testing #1050 which should hopefully help you for your use case? |
In the following example, #1050 turns the class from The code block inside the doc string is still wrongly shown as How can I include https://highlightjs.readthedocs.io/en/latest/plugin-recipes.html#data-language in Franklin? This should allow me to turn e.g. |
(sorry for not answering your points properly in the first shot) so the custom classes should allow you to add specific styling only to the dedicated class, let me play with it a bit so I can see whether I can modify what you did to get something that might be more satisfactory for the ruby stuff what happens is that the next steps are: (1) let me play with the CSS stuff for the annotation thing, I'll get back to you here if I can make something nicer work |
ok (2) is done, I'll try to look into (1) soon but basically what you should try is to use a more specific selector instead of .hljs::before {
content: attr(class);
...
} something like .hljs::before {
... /* everything but content */
}
.julia-repl .hljs::before {
content: "Julia repl";
}
.julia-repl-shell .hljs::before {
content: "Julia repl / shell mode";
}
.julia-repl-help .hljs::before {
content: "Julia repl / help mode";
}
.julia-repl-pkg .hljs::before {
content: "Julia repl / pkg mode";
} |
Thanks a lot! |
The lastest commit of #1050 works really well already! However, sing something like .julia-repl::before {
content: "Julia REPL";
} seems to currently remove the whitespace after the |
hmm this is odd, Franklin definitely adds a space. Could you:
alternatively, if you could post here a standalone HTML with a single code cell, the styling, and the javascript, so I can reproduce what you see locally and try to see what CSS rules are clashing. Edit: wait am playing with |
ok, there's some stuff I don't understand (why that space got swallowed), I suspect it's due to the In any case the following will fix the problem: .hljs .prompt_::after {
content: " ";
} the Note: I didn't check but let's say you only had the problem with hope this works! I'll merge the modifications in #1050 which seem to do what you were hoping for. edit the pr closed the issue but feel free to re open if you feel we missed something |
Thanks a lot! :) |
@adrhill can you transfer this to our new Xranklin version? |
Sure, let me try. 👍 |
For reference, this is used in modernjuliaworkflows/modernjuliaworkflows.github.io#67. Some insights since then: The weird .language-julia::before {content: "Julia";} I fixed this adding /* Julia code after REPL prompts doesn't need a language tag */
.language-julia-repl .language-julia::before {content: "";}
.julia-repl .language-julia::before {content: "";}
.julia-repl-pkg .language-julia::before {content: "";}
.julia-repl-help .language-julia::before {content: "";}
.julia-repl-shell .language-julia::before {content: "";} All in all, the approach with Some discussion on this topic can be found in highlightjs/highlight.js#1108 (comment), but I'm not familiar enough with JS and its DOM to really understand it. I also noticed that Xranklin doesn't have the distinction between |
The Modern Julia Workflows blog switches between shell, code and REPL code blocks quite frequently. It would be nice to be able to annotate code blocks to avoid confusing readers.
Example of this feature in a blog post:
https://fasterthanli.me/series/advent-of-code-2022/part-1
Mock-up illustrating the problem:
CC @gdalle
The text was updated successfully, but these errors were encountered: