MCPcopy Create free account
hub / github.com/zhongsp/TypeScript / checkForImproperlyIndentedFencedCodeBlocks

Function checkForImproperlyIndentedFencedCodeBlocks

docs/lint.js:72–93  ·  view source on GitHub ↗

* @param {string} fileName * @param {string} text

(fileName, text)

Source from the content-addressed store, hash-verified

70 * @param {string} text
71 */
72function checkForImproperlyIndentedFencedCodeBlocks(fileName, text) {
73 var lines = text.split(/\r?\n/g);
74 var numErrors = 0;
75
76 for (var i = 0; i < lines.length; i++) {
77 var line = lines[i];
78 var codeBlockMatch = line.match(/^(\s*)```\S+/);
79
80 if (codeBlockMatch) {
81 var startingColumn = codeBlockMatch[1].length;
82 if (startingColumn === 0 || startingColumn === getCorrectStartingColumnForLine(lines, i)) {
83 continue;
84 }
85
86 numErrors++;
87 console.log(fileName + ": " +
88 i + 1 + ": A fenced code block following a list item must be indented to the first non-whitespace character of the list item.")
89 }
90 }
91
92 return numErrors;
93}
94
95/**
96 * @param {string[]} line

Callers 1

lint.jsFile · 0.70

Calls 1

Tested by

no test coverage detected