mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-24 01:40:13 +01:00
Move each rule implementation into its own file (fixes #83).
This commit is contained in:
parent
49e36f817c
commit
9ba143555d
42 changed files with 1289 additions and 1028 deletions
29
lib/md037.js
Normal file
29
lib/md037.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
var shared = require("./shared");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD037", "no-space-in-emphasis" ],
|
||||
"description": "Spaces inside emphasis markers",
|
||||
"tags": [ "whitespace", "emphasis" ],
|
||||
"function": function MD037(params, onError) {
|
||||
shared.forEachInlineChild(params, "text", function forToken(token) {
|
||||
var left = true;
|
||||
var match = /\s(\*\*?|__?)\s.+\1/.exec(token.content);
|
||||
if (!match) {
|
||||
left = false;
|
||||
match = /(\*\*?|__?).+\s\1\s/.exec(token.content);
|
||||
}
|
||||
if (match) {
|
||||
var text = match[0].trim();
|
||||
var line = params.lines[token.lineNumber - 1];
|
||||
var column = line.indexOf(text) + 1;
|
||||
var length = text.length;
|
||||
shared.addErrorContext(onError, token.lineNumber,
|
||||
text, left, !left, [ column, length ]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue