Split micromark.cjs into separate -parse and -helpers files.

This commit is contained in:
David Anson 2024-09-28 16:26:38 -07:00
parent 5701d0bf52
commit 33631a5984
47 changed files with 353 additions and 1236 deletions

View file

@ -3,7 +3,7 @@
"use strict";
const { addError, addErrorDetailIf, getHtmlAttributeRe } = require("../helpers");
const { filterByPredicate, filterByTypes, getHtmlTagInfo } = require("../helpers/micromark.cjs");
const { filterByPredicate, filterByTypes, getHtmlTagInfo } = require("../helpers/micromark-helpers.cjs");
const { filterByTypesCached } = require("./cache");
// Regular expression for identifying HTML anchor names
@ -22,7 +22,7 @@ const tokensInclude = new Set(
* Converts a Markdown heading into an HTML fragment according to the rules
* used by GitHub.
*
* @param {import("../helpers/micromark.cjs").Token} headingText Heading text token.
* @param {import("../helpers/micromark-helpers.cjs").Token} headingText Heading text token.
* @returns {string} Fragment string for heading.
*/
function convertHeadingToHTMLFragment(headingText) {
@ -51,7 +51,7 @@ function convertHeadingToHTMLFragment(headingText) {
/**
* Unescapes the text of a String-type micromark Token.
*
* @param {import("../helpers/micromark.cjs").Token} token String-type micromark Token.
* @param {import("../helpers/micromark-helpers.cjs").Token} token String-type micromark Token.
* @returns {string} Unescaped token text.
*/
function unescapeStringTokenText(token) {
@ -104,7 +104,7 @@ module.exports = {
// Process link and definition fragments
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").TokenType[][] */
/** @type import("../helpers/micromark-helpers.cjs").TokenType[][] */
const parentChilds = [
[ "link", "resourceDestinationString" ],
[ "definition", "definitionDestinationString" ]