-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Expose code block metadata to SyntaxHighlighterAdapter #257
Conversation
Hi Luc! Thanks so much for this, and sorry for my delay in responding! This is shaping up excellently.
I think we should simply always capture it and make it available. I'd prefer to avoid having a second boolean, because — as the I particularly want to avoid the "2 booleans (4 combinations) yet 3 code paths" we have here — it reveals the disconnect between the modelling of the configuration and the modelling of the logic proper. This would better be represented with a single tri-state option, but I figure we can afford to avoid changing the configuration entirely. Instead, just always add the If this becomes an issue for someone down the track, we can deal with it then, but for now simple is best. Footnotes
|
@kivikakk Okay, I've made those suggested changes such that |
👍 Interface looks good to me! Uncomplicated is best. |
@kivikakk These changes have introduced some test failures that I need to poke at 😅 I should be able to knock that out this week. |
Things have moved on a bit in the last couple of months -- we now have ComrakRenderOptions::full_info_string (from #276), which exposes the remainder of the info string to the highlighting plugin via the appropriate tag. If it's alright with you, I'll close this PR and #253 -- I think Comrak now supports your use case. |
Apologies for dropping off there. My life and employment situation changed pretty drastically. I'll close this, as I think that #253 indeed satisfies the use case 🚀 |
Not a problem at all, can totally relate! Glad to hear it; thanks for your efforts as always! 🐰🤍 |
Fixes #253.
This PR is very much a WIP but I wanted to submit what I have so far in pursuit of a bit of help. In a nutshell, this PR exposes any code block "metadata" to the
SyntaxHighlighterAdapter
. Here's what I mean by metadata:In this case, the string
showLineNumbers {1-5,11}
would be exposed via themeta
key inattributes
in thebuild_pre_tag
function, as I've done in thesyntax_highlighter.rs
example. Runcargo run --example syntax_highlighter
to see the respectiveattributes
maps.My goal is to enable people to build things like
rehype-pretty-code
in pure Rust. As far as I can tell, this is not currently possible incomrak
via theSyntaxHighlighterAdapter
. I've marked this as a draft because, as you can see, the actual implementation is pretty straightforward. What I'm less clear on is how you'd like this to fit in with the configuration options. I would love some guidance on what you'd prefer there. One possibility might be adding a distinct Boolean option toComrakRenderOptions
, likefancy_code_blocks
or something, to capture bothlang
andmeta
, or maybe it'd be best to just capture the entire thing as one string, i.e.meta
would berust showLineNumbers {1-5,11}
and users could do whatever they like with it.