Refactor to remove micromark helper getTokenTextByType, update getDescendantsByType to allow sub-arrays.

This commit is contained in:
David Anson 2024-09-24 22:48:14 -07:00
parent 0f210d5c1a
commit 8cbbed8e79
7 changed files with 44 additions and 94 deletions

View file

@ -3,7 +3,7 @@
"use strict";
const { addErrorDetailIf } = require("../helpers");
const { getDescendantsByType, getTokenTextByType } = require("../helpers/micromark.cjs");
const { getDescendantsByType } = require("../helpers/micromark.cjs");
const { filterByTypesCached } = require("./cache");
const listStyleExamples = {
@ -19,7 +19,7 @@ const listStyleExamples = {
* @returns {number} List item value.
*/
function getOrderedListItemValue(listItemPrefix) {
return Number(getTokenTextByType(listItemPrefix.children, "listItemValue"));
return Number(getDescendantsByType(listItemPrefix, [ "listItemValue" ])[0].text);
}
// eslint-disable-next-line jsdoc/valid-types