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 lang to code blocks in Markdown #5299
Conversation
This change aims to make documents more readable and avoid syntax errors by adding a language specifier to code blocks in Markdown. To perform this task efficiently, I use two remark plugins: - [remark-lint-code-block-syntax](https://github.com/ybiquitous/remark-lint-code-block-syntax) - [remark-lint-fenced-code-flag](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-flag) ```diff --- a/package.json +++ b/package.json @@ -66,7 +66,9 @@ }, "remarkConfig": { "plugins": [ - "@stylelint/remark-preset" + "@stylelint/remark-preset", + "remark-lint-code-block-syntax", + "remark-lint-fenced-code-flag" ] }, "jest": { @@ -189,6 +191,8 @@ "postcss-import": "^12.0.1", "prettier": "^2.2.1", "remark-cli": "^9.0.0", + "remark-lint-code-block-syntax": "^0.2.1", + "remark-lint-fenced-code-flag": "^2.0.1", "typescript": "^4.2.4" }, "engines": { ``` Note: I do not recommend the addition of the plugins because they produce false positives.
$ npm run lint:md
> stylelint@13.13.1 lint:md
> remark . --quiet --frail
docs/developer-guide/formatters.md
16:1-46:4 warning Invalid JavaScript: Line 3: Unexpected token : code-block-syntax remark-lint
50:1-59:4 warning Invalid JavaScript: Line 2: Unexpected token : code-block-syntax remark-lint
docs/developer-guide/rules.md
99:1-106:4 warning Invalid JavaScript: Line 3: Illegal return statement code-block-syntax remark-lint
docs/user-guide/ignore-code.md
79:1-82:4 warning Missing code language flag fenced-code-flag remark-lint
docs/user-guide/rules/about.md
63:1-67:4 warning Missing code language flag fenced-code-flag remark-lint
73:1-78:4 warning Missing code language flag fenced-code-flag remark-lint
lib/rules/media-feature-name-value-allowed-list/README.md
14:1-19:4 warning Invalid JavaScript: Line 2: Unexpected token : code-block-syntax remark-lint
lib/rules/media-feature-name-value-whitelist/README.md
16:1-21:4 warning Invalid JavaScript: Line 2: Unexpected token : code-block-syntax remark-lint
lib/rules/no-irregular-whitespace/README.md
32:1-57:4 warning Missing code language flag fenced-code-flag remark-lint
⚠ 9 warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just scrolled through all 93 files and each change seems reasonable to me! It's great you were able to use the plugin instead of having to do it manually, I imagine that must've been a headache 😅
Note: I do not recommend the addition of the plugins because they produce false positives.
I'm curious if this is something we should submit upstream and/or reconfigure?
@mattxwang Thank you for the review!
I think it hard to do it because:
@jeddy3 Thank you for the feedback!
Sorry, I forgot the conflict with the Of course, I can remove the conflicted files from this PR if anyone hopes:
I can address both. 🙆🏼♂️ |
Done. |
This change aims to make documents more readable and avoid syntax errors by adding a language specifier to code blocks in Markdown.
To perform this task efficiently, I use two remark plugins:
Note: I do not recommend the addition of the plugins because they produce false positives.
Closes #5272
Contents in some code blocks are modified to prevent syntax errors.