mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Move single use, not explicitly tested helpers into the file that uses them.
This commit is contained in:
parent
df70ea5989
commit
c5d4a3297f
5 changed files with 72 additions and 84 deletions
17
lib/md048.js
17
lib/md048.js
|
|
@ -2,10 +2,25 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, fencedCodeBlockStyleFor } = require("../helpers");
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
/**
|
||||
* Return the string representation of a fence markup character.
|
||||
*
|
||||
* @param {string} markup Fence string.
|
||||
* @returns {"tilde" | "backtick"} String representation.
|
||||
*/
|
||||
function fencedCodeBlockStyleFor(markup) {
|
||||
switch (markup[0]) {
|
||||
case "~":
|
||||
return "tilde";
|
||||
default:
|
||||
return "backtick";
|
||||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,26 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addError, emphasisOrStrongStyleFor } = require("../helpers");
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByPredicate, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
|
||||
const intrawordRe = /^\w$/;
|
||||
|
||||
/**
|
||||
* Return the string representation of a emphasis or strong markup character.
|
||||
*
|
||||
* @param {string} markup Emphasis or strong string.
|
||||
* @returns {"asterisk" | "underscore"} String representation.
|
||||
*/
|
||||
function emphasisOrStrongStyleFor(markup) {
|
||||
switch (markup[0]) {
|
||||
case "*":
|
||||
return "asterisk";
|
||||
default:
|
||||
return "underscore";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import("./markdownlint").RuleParams} params Rule parameters.
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addError, ellipsify, linkReferenceDefinitionRe } =
|
||||
require("../helpers");
|
||||
const { addError, ellipsify } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
|
||||
const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])\]:/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue