Exclude some languages in code highlighting#3865
Conversation
|
Requires #3827 |
53ca8f0 to
8d45180
Compare
|
I just started testing this,
By "render", you mean html escape? I tried if (options.exclude_languages) {
if (options.exclude_languages.includes(options.lang)) {
options.wrap = false;
<br>
options.gutter = false;
options.autoDetect = false;
}
}
Looks like |
Well, in my blogs, when I work with my latest changes and hexo-util@1.8.0, I could get the proper result which does not include
|
|
There will be other code highlighting engines added to Hexo: #4119 This looks more clear than |
Well, I have downloaded that branch and tested it, and it may somehow achieve the function I requested. But I have a question: why not let the hexo user decide when the code should be rendered(in the hexo building or in the browser loading). |
stevenjoezhang
left a comment
There was a problem hiding this comment.
Please make it compatible with #4119 thanks
|
Will, we could merge #4119 first, and then I will bring up the feature in another PR. |
Signed-off-by: corvofeng <corvofeng@gmail.com>
985c281 to
bf18425
Compare
|
@SukkaW @stevenjoezhang @curbengh I have rebased this PR based on the latest master branch, could anyone merge it or give me some advice? I don’t want to be forgotten after a long time, because I really need this feature. |
How to testgit clone -b exclude_highlight_lang https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test |
|
The failed test is fixed in #4902, not caused by the PR itself. The change LGTM. |
|
I try to exclude java in highlight like this: highlight:
enable: true
line_number: true
auto_detect: false
tab_replace: ''
wrap: true
hljs: false
exclude_languages:
- java But I find that tags still exist, is this expected behavior?🤔🤔 |
Signed-off-by: corvofeng corvofeng@gmail.com
What does it do?
Only wrap some languages' code with
<pre>and<code>, and do no render all tags(span, and br) in content, so that user could process those languages freely.How to test
How to use?
config.yaml:Blog code:
```flowchartjs-code
st=>start: Start:>http://www.bing.com[blank]
e=>end:>http://www.bing.com
op1=>operation: My Operation
sub1=>subroutine: My Subroutine
cond=>condition: Yes
or No?:>http://www.google.com
io=>inputoutput: catch something...
para=>parallel: parallel tasks
st->op1->cond
cond(yes)->io->e
cond(no)->para
para(path1, bottom)->sub1(right)->op1
para(path2, top)->op1
```
You will get:
Pull request tasks