Skip to content

hljs - Added compatibility for CSS styles.#30

Merged
JLHwung merged 3 commits intohexojs:masterfrom
alxbl:support-hljs
Dec 20, 2017
Merged

hljs - Added compatibility for CSS styles.#30
JLHwung merged 3 commits intohexojs:masterfrom
alxbl:support-hljs

Conversation

@alxbl
Copy link
Contributor

@alxbl alxbl commented Dec 11, 2017

This pull request adds additional support to render the highlighting with hljs- prefix and preserves backward compatibility for existing themes/stylesheets.

Support for both marked lines and line numbers, as well as vanilla highlight.js blocks is included.

This is a quick proof of concept that I whipped up after I started working on my theme and realizing that hljs CSS themes weren't supported. I hope it can be helpful to hexo users.

It's a two part pull request as hexo/#2901 adds support for propagating the hljs configuration through to the highlight plugin.

If everything is good (or after necessary changes), I will be updating the documentation as well to document the new config for _config.yml.

Cheers,

@coveralls
Copy link

coveralls commented Dec 11, 2017

Coverage Status

Coverage increased (+0.1%) to 96.338% when pulling fba4b08 on alxbl:support-hljs into 793b58a on hexojs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 96.338% when pulling 707862d on alxbl:support-hljs into 793b58a on hexojs:master.

@alxbl
Copy link
Contributor Author

alxbl commented Dec 11, 2017

FYI: Don't approve the PR yet, there's a bug with the line numbers at the moment due to letting hljs render the lines on its own terms. I'm about to call it a night, but I should have time to fix it up tomorrow.

@JLHwung JLHwung changed the title hljs - Added compatibility for CSS styles. WIP: hljs - Added compatibility for CSS styles. Dec 11, 2017
@coveralls
Copy link

coveralls commented Dec 11, 2017

Coverage Status

Coverage increased (+0.1%) to 96.328% when pulling df0d1cf on alxbl:support-hljs into 793b58a on hexojs:master.

@alxbl
Copy link
Contributor Author

alxbl commented Dec 11, 2017

I think this should cover it. I've tested it with and without the gutter. Line numbering works fine, but it's obviously not styled via highlight.js themes.

Let me know if there's anything you'd change about the code.

Cheers,
Alex

@NoahDragon NoahDragon changed the title WIP: hljs - Added compatibility for CSS styles. hljs - Added compatibility for CSS styles. Dec 16, 2017
Copy link
Member

@NoahDragon NoahDragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@JLHwung JLHwung merged commit ce6dda9 into hexojs:master Dec 20, 2017
@JLHwung
Copy link
Contributor

JLHwung commented Dec 20, 2017

@alxbl Good job! Please document the hljs usage on https://github.com/hexojs/hexo-util#highlightstr-options. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants