-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add support for inline code highlighting #3180
Add support for inline code highlighting #3180
Conversation
Resolves highlightjs#945 for non-technical users such as those using highlight.js via a WordPress plugin, allowing trivial and much- less-invasive inclusion of other elements (such as <code>s not wrapped in a <pre>) than existing proposed solutions
This type of item would fall under While selector does seem a natural choice [as an argument] one could also suggest that other items pertaining directly to how we perform "highlight all" (such as hljs.configure({cssSelector: "code"});
hljs.highlightAll(); Are you willing to re-work your PR to instead add a |
It's then also worth discussing if our default CSS may need to be changed to offer both the a This lives in |
Yes, I think that may also require a lot of refactoring. I'm currently jury-rigging it with a code.hljs:not(pre>code) {
padding: initial;
display: initial;
} (This may be idiopathic to WordPress, which has a sort of "convention" — and by "sort of", I mean it's nearly immutably how the HTML is operated while using the software — that Block
Certainly! Since I'm currently unfamiliar with your API, you've done 90% of the work for me just there by defining the implementation! 😁 (I've just pushed the changes; how do they look?) |
That sounds 100% semantically correct to me. So why can't that just be accomplished with two rules? pre code.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
}
code.hljs {
padding: ...;
} The block level items then only apply to pre/code as they should... and we only add a small amount of padding to inline elements. |
Strongly consider that since it seems that `code:not(pre code)` are excluded from in the definition of "code blocks" - therefore, reconsider this?: https://github.com/highlightjs/highlight.js/blob/11.0.0-beta0/src/styles/default.css#L11-L12
Co-authored-by: Josh Goebel <[email protected]>
I don't think we need a separate PR for that, the scope of this one is small enough to finish this work I think. This will merit a mention in breaking changes now since it would break anyone using |
Yeah, I could use a hand with the documentation / I'm not qualified to tear down chesterton's fence in this case; thanks. |
This nearly-singlehandedly resolves highlightjs#945
Co-authored-by: Josh Goebel <[email protected]>
Co-authored-by: Josh Goebel <[email protected]>
Co-authored-by: James <[email protected]>
This reverts commit bd421b6.
@JamesTheAwesomeDude Thanks so much for working on this. |
Resolves #945
Changes
This pull request adds an optional parameter to
highlightAll()
, which can make it use a query selector other thanpre code
. It does not change any existing behavior of the software.Checklist
This wasn't a
deprecation
orremoval
; I'm unclear if it's big enough to bother listing as anAPI change
high-level bullet; it doesn't belong undersecurity
,themes
,language grammars
,parser
,grammars
,new languages
,theme improvements
,new themes
, ordev improvements
(that last one looks like it's to do with changes to your in-house tooling system.)It's a tiny, optional, backwards-compatible, mostly-user-facing
enhancement
. But it looks like that's not currently a header/category in the changelog. Should I create it?