Skip to content
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

Fix sublanguages highlight #37

Merged
merged 2 commits into from
Aug 29, 2019
Merged

Conversation

l-vo
Copy link
Contributor

@l-vo l-vo commented Aug 11, 2018

Highlightjs has a sublanguages feature which allows some languages to incorporate and highlight another language inside it. When I use a sublanguage in Hexo, it doesn't work:

without_highlight

This PR make the sublanguages functional:

highlight

The sublanguage feature requires that the sublangage definition is loaded. But Hexo only load the definition of the main language of the code chunk. I suggest to always load all language definitions, like it's done in highlightjs library and in hexo-util tests (so the tests are currently not totally right since the definitions loaded in tests are not the same as the definitions actually loaded by hexo-utils).

Also, it could be possible to dynamically load sublanguages but it will make hexo-util too closely coupled with hightlighjs IMHO.

@coveralls
Copy link

coveralls commented Aug 11, 2018

Coverage Status

Coverage increased (+0.7%) to 95.897% when pulling 5e0deb9 on l-vo:fix_sublanguages_highlight into 95f791a on hexojs:master.

@l-vo l-vo force-pushed the fix_sublanguages_highlight branch from 417592d to b15b518 Compare August 11, 2018 09:03
@segayuu segayuu requested review from tommy351 and JLHwung August 12, 2018 05:31
@segayuu
Copy link
Contributor

segayuu commented Aug 12, 2018

This PR is loosely coupled or a trade-off with memory, and it is difficult to decide which one to prioritize.
Whether this behavior should be changed as hexo-util libraries remains in doubt.
However, I acknowledge that it is not good to use sub language features at Hexo in the current situation.

@segayuu segayuu merged commit 05fe5a3 into hexojs:master Aug 29, 2019
@l-vo l-vo deleted the fix_sublanguages_highlight branch October 28, 2019 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants