-
Notifications
You must be signed in to change notification settings - Fork 991
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
Classed syntax highlighting + Line numbers #1242
Classed syntax highlighting + Line numbers #1242
Conversation
9e94065
to
5155f5b
Compare
Hello @Keats. Is this something you're interested in? Before I continue, I wanted to see if this is going in a right direction. |
Sorry I thought I replied to it already! This is something we want but I'm wondering if we need to override the HTML syntect outputs so we can support line numbers and highlight in the best possible way (https://zola.discourse.group/t/highlighting-improvements/19/11?u=keats) |
This comment has been minimized.
This comment has been minimized.
I think if we go the rewrite html route, adding the classes is trivial since we just put it instead of inline css? |
I think if we go the rewrite HTML route, the first thing to do is to write by hand the HTML we would like to end up so we can experiment easily |
4c06480
to
59bc44d
Compare
@evan-brass Thanks for pushing my PR forward. This year i have time to work on Zola (and my website). If you need any help, just drop me a note. |
Copied and pasted from pull request 913 Co-Authored-By: Uwe Arzt <[email protected]>
Mostly copied from PR 913 Co-Authored-By: Uwe Arzt <[email protected]>
This is copied from getzola#913 Co-Authored-By: Uwe Arzt <[email protected]>
Give `CodeBlock` access to the start and end events because classed highlighting needs to adjust the pre element and close spans. Rename get_highlighter and make it return everything needed for highlighting so that we don't need the config after a codeblock is created. Prep the code block for classed highlighting which will need to store different state from inline highlighting.
still need to do open_spans and lots of stuff.
* Remove html_escape: use Tera * Output table
The foreground color will now be applied to the line numbers. This also reduces the number of spans required in inline output.
59bc44d
to
6d7f708
Compare
Sorry for the delay. I'm still not sure what line number style to implement so I implemented the few discussed already. There's some bugs and no tests yet. I don't like how much code I wrote in the codeblock module - it feels like there's some simple design that I'm not seeing. I tried to break the line numbers, highlighted lines, and syntax highlighting into multiple "passes", but it still doesn't seem right. |
I did it again sorry >_> |
@evan-brass is it ready or is it still a WIP? |
Another ping @evan-brass |
I've been using this branch for a while and so far I'm quite happy with it, but I had one suggestion/request: when using the "css" highlight theme, it would be nice to include the |
It looks really good! Merge conflict is going to be a bit annoying (hidden lines, how it interacts with line numbers etc) but I'll try to merge things through the |
Erhm the merge is annoying, do you mind if I do it manually in a new commit and mark you as the commit author @evan-brass ? I will probably tweak some bits but most of it will be this PR. |
Sure. Sounds good. |
@kzurawel should the lang be moved entirely to |
I would be fine with that; I can’t think of a situation where having the inner lang class would matter |
It's if you want to use something like highlightjs. I think I will just the class on |
6075d56
to
7b75ad0
Compare
Not finished yet but #1531 is a simplified implementation as it doesn't try to unify various spans, which sounds like it would something better done in syntect directly. |
trishume/syntect#336 and I made a PR to fix it so it should be ok |
7b75ad0
to
ebfbd8d
Compare
CSS classed syntax highlighting
This extends #913
ClassedHtmlGenerator
usestokens_to_classed_spans
internally which creates a new scope stack for each line causing the panic when a restore occurs on a different line from a clear.Documentation
.code
class, samples for<mark>
, etc.)Implement hl_lines (
<mark>
tags?)Implement line numbers
linenostart
fence optionTests
Is any more documentation needed?
Is it ok for
highlighting_css_themes
to not be under the new markdown section?