Skip to content

Commit

Permalink
fix(docs): syntax highlight variations of Rust language tag (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadaj authored Dec 4, 2024
1 parent 53da4c1 commit c2d6fa0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/src/theme/prism-include-languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export default function prismIncludeLanguages(PrismObject) {
require(`prismjs/components/prism-${lang}`);
});
Prism.languages["rust,ignore"] = Prism.languages.rust;
Prism.languages["rust,no_run"] = Prism.languages.rust;

const origTokenize = PrismObject.tokenize;
PrismObject.hooks.add("after-tokenize", function(env) {
if (env.language === "rust") {
if (env.language === "rust" || env.language === "rust,ignore" || env.language === "rust,no_run") {
let code = env.code.split("\n").filter(line => !line.startsWith("# ")).join("\n");
env.tokens = origTokenize(code, env.grammar);
}
Expand Down

0 comments on commit c2d6fa0

Please sign in to comment.