-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
🐛 Bug Report
Language syntax specified in markdown code blocks is ignored, eg ```js and ```text render the same output.
Today's (27th July) revision #75538395beb3bcd7591f586877d5971c51d4f5db in master was supposed to contain the fix for the language highlighting.
In fact the css bug of language- <lang> is fixed and now the CSS attribute is language-<lang> without the space. This was fixed by #840
Have you read the [Contributing Guidelines on issues]
Yes
To Reproduce
Create a .md file with the following content:
---
title: EXAMPLE
---
```text
function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
}
export $initHighlight;
```
```js
function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
}
export $initHighlight;
```
Expected behavior
I would expect the output to be highlighted differently between text and js code blocks, like this:
function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
}
export $initHighlight;
function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
}
export $initHighlight;Actual Behavior
With fixed code in master, highlightjs seems to ignore language syntax specified in the code block:
As you can see the CSS class name is fixed but ignored.
Reproducible Demo
Use node 8
git clone https://github.com/bettiolo/docusaurus-hl-bug.git
cd docusaurus-hl-bug/website
npm install
npm startA browser will open and will show the bug:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

