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-ast@15.5.2/lib/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@textlint/markdown-to-ast@15.5.2/lib/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Syntax = void 0;\nexports.parse = parse;\nconst markdown_syntax_map_1 = require(\"./mapping/markdown-syntax-map\");\nconst ast_node_types_1 = require(\"@textlint/ast-node-types\");\nObject.defineProperty(exports, \"Syntax\", { enumerable: true, get: function () { return ast_node_types_1.ASTNodeTypes; } });\nconst legacy_1 = __importDefault(require(\"neotraverse/legacy\"));\nconst debug_1 = __importDefault(require(\"debug\"));\nconst parse_markdown_1 = require(\"./parse-markdown\");\nconst structured_source_1 = require(\"structured-source\");\nconst debug = (0, debug_1.default)(\"@textlint/markdown-to-ast\");\n/**\n * Workaround for remark-gfm issue: https://github.com/remarkjs/remark-gfm/issues/16\n *\n * remark-gfm generates AST nodes (especially Str and Link nodes inside tables)\n * that are missing essential position information (position.start, position.end).\n * This creates problems for textlint which relies on accurate position data for:\n * - Error reporting with line/column numbers\n * - Source code highlighting and navigation\n * - Rule application to specific text ranges\n *\n * This function attempts to reconstruct missing position information by:\n * 1. Finding sibling nodes with valid position data\n * 2. Calculating relative positions based on node content and structure\n * 3. Using StructuredSource for accurate line/column conversion\n *\n * The approach handles three scenarios:\n * - Reference node before target: Add accumulated lengths\n * - Reference node after target: Subtract accumulated lengths\n * - Parent as reference: Search within parent content\n *\n * @param targetNode - The node missing position information\n * @param parentNode - Parent node containing the target\n * @param source - StructuredSource for offset-to-position conversion\n * @param sourceText - Original source text for content extraction\n * @returns Calculated position data or null if calculation fails\n */\nfunction calculatePositionFromSiblings(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntargetNode, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nparentNode, source, sourceText) {\n    if (!parentNode || !parentNode.children || !Array.isArray(parentNode.children)) {\n        return null;\n    }\n    const children = parentNode.children;\n    const targetIndex = children.indexOf(targetNode);\n    if (targetIndex === -1) {\n        return null;\n    }\n    // Find the nearest sibling with position information\n    let referenceNode = null;\n    let referenceIndex = -1;\n    // Look for previous siblings first\n    for (let i = targetIndex - 1; i >= 0; i--) {\n        if (children[i] && children[i].position) {\n            referenceNode = children[i];\n            referenceIndex = i;\n            break;\n        }\n    }\n    // If no previous sibling found, look for next siblings\n    if (!referenceNode) {\n        for (let i = targetIndex + 1; i < children.length; i++) {\n            if (children[i] && children[i].position) {\n                referenceNode = children[i];\n                referenceIndex = i;\n                break;\n            }\n        }\n    }\n    // If no siblings with position found, try parent's position\n    if (!referenceNode && parentNode.position) {\n        referenceNode = parentNode;\n        referenceIndex = 0; // Treat parent as reference point\n    }\n    if (!referenceNode || !referenceNode.position) {\n        return null;\n    }\n    let estimatedStart;\n    const targetValue = targetNode.value || targetNode.url || \"\";\n    if (referenceIndex < targetIndex) {\n        // Reference node is before target node\n        estimatedStart = referenceNode.position.end.offset;\n        // Add length of nodes between reference and target\n        for (let i = referenceIndex + 1; i < targetIndex; i++) {\n            const node = children[i];\n            if (node.value && typeof node.value === \"string\") {\n                estimatedStart += node.value.length;\n            }\n            else if (node.raw && typeof node.raw === \"string\") {\n                estimatedStart += node.raw.length;\n            }\n            else {\n                // Rough estimation for complex nodes\n                estimatedStart += 1;\n            }\n        }\n    }\n    else if (referenceIndex > targetIndex) {\n        // Reference node is after target node\n        estimatedStart = referenceNode.position.start.offset;\n        // Subtract estimated length of nodes between target and reference\n        for (let i = targetIndex + 1; i < referenceIndex; i++) {\n            const node = children[i];\n            if (node.value && typeof node.value === \"string\") {\n                estimatedStart -= node.value.length;\n            }\n            else if (node.raw && typeof node.raw === \"string\") {\n                estimatedStart -= node.raw.length;\n            }\n            else {\n                // Rough estimation for complex nodes\n                estimatedStart -= 1;\n            }\n        }\n        // Subtract target node's own length\n        estimatedStart -= targetValue.length;\n    }\n    else {\n        // Reference node is parent - search within parent's content\n        const parentContent = sourceText.slice(referenceNode.position.start.offset, referenceNode.position.end.offset);\n        // Try to find the target value within parent content\n        const targetValueIndex = parentContent.indexOf(targetValue);\n        if (targetValueIndex !== -1) {\n            estimatedStart = referenceNode.position.start.offset + targetValueIndex;\n        }\n        else {\n            // Fallback to start of parent\n            estimatedStart = referenceNode.position.start.offset;\n        }\n    }\n    // Ensure start position is not negative and within bounds\n    estimatedStart = Math.max(0, Math.min(estimatedStart, sourceText.length - targetValue.length));\n    const estimatedEnd = estimatedStart + targetValue.length;\n    // Use StructuredSource to convert offsets to line/column\n    const startLoc = source.indexToPosition(estimatedStart);\n    const endLoc = source.indexToPosition(estimatedEnd);\n    return {\n        loc: {\n            start: { line: startLoc.line, column: startLoc.column },\n            end: { line: endLoc.line, column: endLoc.column }\n        },\n        range: [estimatedStart, estimatedEnd],\n        raw: sourceText.slice(estimatedStart, estimatedEnd)\n    };\n}\n/**\n * parse Markdown text and return ast mapped location info.\n * @param {string} text\n */\nfunction parse(text) {\n    // remark-parse's AST does not consider BOM\n    // AST's position does not +1 by BOM\n    // So, just trim BOM and parse it for `raw` property\n    // textlint's SourceCode also take same approach - trim BOM and check the position\n    // This means that the loading side need to consider BOM position - for example fs.readFile and text slice script.\n    // https://github.com/micromark/micromark/blob/0f19c1ac25964872a160d8b536878b125ddfe393/lib/preprocess.mjs#L29-L31\n    const hasBOM = text.charCodeAt(0) === 0xfeff;\n    const textWithoutBOM = hasBOM ? text.slice(1) : text;\n    const ast = (0, parse_markdown_1.parseMarkdown)(textWithoutBOM);\n    const source = new structured_source_1.StructuredSource(textWithoutBOM);\n    // Collect all nodes without position for advanced processing\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    const nodesWithoutPosition = [];\n    (0, legacy_1.default)(ast).forEach(function (node) {\n        if (this.notLeaf) {\n            if (node.type) {\n                const replacedType = markdown_syntax_map_1.SyntaxMap[node.type];\n                if (!replacedType) {\n                    debug(`replacedType : ${replacedType} , node.type: ${node.type}`);\n                }\n                else {\n                    node.type = replacedType;\n                }\n            }\n            // map `range`, `loc` and `raw` to node\n            if (node.position) {\n                const position = node.position;\n                // line start with 1\n                // column start with 0\n                const positionCompensated = {\n                    start: { line: position.start.line, column: Math.max(position.start.column - 1, 0) },\n                    end: { line: position.end.line, column: Math.max(position.end.column - 1, 0) }\n                };\n                const range = [position.start.offset, position.end.offset];\n                node.loc = positionCompensated;\n                node.range = range;\n                node.raw = textWithoutBOM.slice(range[0], range[1]);\n                // Compatible for https://github.com/syntax-tree/unist, but it is hidden\n                Object.defineProperty(node, \"position\", {\n                    enumerable: false,\n                    configurable: false,\n                    writable: false,\n                    value: position\n                });\n            }\n            else if (node.type === \"Str\" || node.type === \"Link\") {\n                // WORKAROUND: Handle nodes missing position information\n                //\n                // Due to remark-gfm issue (https://github.com/remarkjs/remark-gfm/issues/16),\n                // some AST nodes (particularly Str and Link nodes within table cells)\n                // are generated without proper position information. This is problematic\n                // because textlint requires accurate position data for:\n                // - Precise error reporting with line/column numbers\n                // - Source code range highlighting in editors\n                // - Rule application to specific text locations\n                //\n                // We collect these nodes for post-processing where we'll attempt to\n                // reconstruct their position information using sibling nodes and parent context.\n                // Get parent using this.parent\n                const parent = this.parent;\n                nodesWithoutPosition.push({ node, parent });\n            }\n        }\n    });\n    // WORKAROUND: Reconstruct position information for nodes missing it\n    //\n    // Process all nodes that were missing position information during the initial traversal.\n    // This is necessary due to remark-gfm's incomplete position generation for certain nodes.\n    // We attempt to calculate accurate position data using the advanced position calculation\n    // that leverages sibling nodes and parent context.\n    for (const { node, parent } of nodesWithoutPosition) {\n        // Try to calculate position from siblings\n        const calculatedPosition = calculatePositionFromSiblings(node, parent, source, textWithoutBOM);\n        if (calculatedPosition) {\n            // Successfully calculated position - use the computed values\n            node.loc = calculatedPosition.loc;\n            node.range = calculatedPosition.range;\n            node.raw = calculatedPosition.raw;\n        }\n        else {\n            // Fallback: Unable to calculate accurate position\n            // Use basic fallback values to ensure the node has required properties\n            // This prevents crashes but may result in less accurate position reporting\n            const value = node.value || node.url || \"\";\n            node.raw = value;\n            node.loc = {\n                start: { line: 1, column: 0 },\n                end: { line: 1, column: value.length }\n            };\n            node.range = [0, value.length];\n        }\n    }\n    return ast;\n}\n"]}