You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"use strict";module.exports={names: ["gs-ignore-md014-in-text-code-blocks"],description: "Extends MD014 but ignores `text` code blocks",tags: ["dollar-sign","code-block"],function: functionMD014Extended(params,onError){letinsideTextBlock=false;params.tokens.forEach((token,index)=>{// Detect fenced code blocksif(token.type==="fence"){constlanguage=token.info ? token.info.trim() : "";insideTextBlock=language==="text";// Track if it's a `text` block}// Skip checking MD014 inside `text` code blocksif(insideTextBlock){return;}// Check inline text and paragraphs for unescaped `$`if((token.type==="inline"||token.type==="paragraph")&&token.content.includes("$")){constdollarIndex=token.content.indexOf("$");onError({lineNumber: token.lineNumber,detail: "Dollar sign used without escaping (MD014).",context: token.content.substring(Math.max(0,dollarIndex-5),dollarIndex+5),});}// Reset the insideTextBlock flag when leaving a fenced code blockif(token.type==="fence"&&insideTextBlock){insideTextBlock=false;}});},};
Once this is done we can update .pre-commit-config.yaml to run with the custom rules.
Issue identified in PR #1332 where fenced markdown code blocks trigger markdownlint rule MD014: Dollar signs used before commands without showing output.
To address this we can create a custom rule to ignore cases where the code block is text or some other custom language fence.
Custom Rules: https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md
To do this we need to create a new directory
and then add our custom rule:
Here is a start to the rule that needs refinment.
Once this is done we can update
.pre-commit-config.yaml
to run with the custom rules.The text was updated successfully, but these errors were encountered: