diff --git a/README.md b/README.md index c577bb8..4b1c1be 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,8 @@ Legend for syntax support: | Label | | 🚫 | 🚫 | | Reference | | 🚫 | 🚫 | | Heading | Header | ✅ | 🚫 | -| Bullet list | List / ListItem | 🚫 | 🚫 | -| Numbered list | List / ListItem | 🚫 | 🚫 | +| Bullet list | List / ListItem | ✅ | 🚫 | +| Numbered list | List / ListItem | ✅ | 🚫 | | Term list | | 🚫 | 🚫 | | Math | | 🚫 | 🚫 | | Line break | Break | ✅ | 🚫 | diff --git a/bun.lock b/bun.lock index 77401a5..659b908 100644 --- a/bun.lock +++ b/bun.lock @@ -15,6 +15,7 @@ "@types/node": "^20.12.2", "bun-types": "latest", "esbuild": "^0.20.2", + "textlint-rule-period-in-list-item": "^1.0.1", "textlint-rule-preset-ja-technical-writing": "^12.0.2", "textlint-scripts": "^14.0.4", "textlint-tester": "^14.0.4", @@ -1085,6 +1086,8 @@ "textlint-rule-no-zero-width-spaces": ["textlint-rule-no-zero-width-spaces@1.0.1", "", {}, "sha512-AkxpzBILGB4YsXddzHx2xqpXmqMv5Yd+PQm4anUV+ADSJuwLP1Jd6yHf/LOtu9j3ps8K3XM9vQrXRK73z0bU3A=="], + "textlint-rule-period-in-list-item": ["textlint-rule-period-in-list-item@1.0.1", "", { "dependencies": { "check-ends-with-period": "^3.0.1" } }, "sha512-dNPa4WzePcgsz8A+CxFGQgKNZCEvjjwMCu3DFcpYB4eKuhcSISEiS/mvEO42oGAALJluYdYVZxN3yMD6XzkLBA=="], + "textlint-rule-preset-ja-technical-writing": ["textlint-rule-preset-ja-technical-writing@12.0.2", "", { "dependencies": { "@textlint-rule/textlint-rule-no-invalid-control-character": "^3.0.0", "@textlint-rule/textlint-rule-no-unmatched-pair": "^2.0.4", "@textlint/module-interop": "^14.4.0", "textlint-rule-ja-no-abusage": "^3.0.0", "textlint-rule-ja-no-mixed-period": "^3.0.1", "textlint-rule-ja-no-redundant-expression": "^4.0.1", "textlint-rule-ja-no-successive-word": "^2.0.1", "textlint-rule-ja-no-weak-phrase": "^2.0.0", "textlint-rule-ja-unnatural-alphabet": "2.0.1", "textlint-rule-max-comma": "^4.0.0", "textlint-rule-max-kanji-continuous-len": "^1.1.1", "textlint-rule-max-ten": "^5.0.0", "textlint-rule-no-double-negative-ja": "^2.0.1", "textlint-rule-no-doubled-conjunction": "^3.0.0", "textlint-rule-no-doubled-conjunctive-particle-ga": "^3.0.0", "textlint-rule-no-doubled-joshi": "^5.1.0", "textlint-rule-no-dropping-the-ra": "^3.0.0", "textlint-rule-no-exclamation-question-mark": "^1.1.0", "textlint-rule-no-hankaku-kana": "^2.0.1", "textlint-rule-no-mix-dearu-desumasu": "^6.0.3", "textlint-rule-no-nfd": "^2.0.2", "textlint-rule-no-zero-width-spaces": "^1.0.1", "textlint-rule-preset-jtf-style": "^3.0.1", "textlint-rule-sentence-length": "^5.2.0" } }, "sha512-BBVY6oA5V799k5wRfP+gCpDHsp6vWjWX2UT+/KLlAFFsNdmRB8Z6qyOnqiOjfzmLGIRgoMcPI1dXj5upOqnD6Q=="], "textlint-rule-preset-jtf-style": ["textlint-rule-preset-jtf-style@3.0.2", "", { "dependencies": { "analyze-desumasu-dearu": "^2.1.2", "japanese-numerals-to-number": "^1.0.2", "match-index": "^1.0.3", "moji": "^0.5.1", "regexp.prototype.flags": "^1.5.3", "regx": "^1.0.4", "textlint-rule-helper": "^2.3.1", "textlint-rule-prh": "^6.0.0" } }, "sha512-rpB1OCIK4KZqZOnM+vVxDCBkgzDH3XINCRiHQ+gV8SRydtfppPWx9WAoxCvq8lm7YuRdGiFU6XartIix2Fc2kA=="], diff --git a/package.json b/package.json index 76df5ad..b4e9ca8 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@types/node": "^20.12.2", "bun-types": "latest", "esbuild": "^0.20.2", + "textlint-rule-period-in-list-item": "^1.0.1", "textlint-rule-preset-ja-technical-writing": "^12.0.2", "textlint-scripts": "^14.0.4", "textlint-tester": "^14.0.4", diff --git a/src/typstToTextlintAst.ts b/src/typstToTextlintAst.ts index ac95b94..220f944 100644 --- a/src/typstToTextlintAst.ts +++ b/src/typstToTextlintAst.ts @@ -44,8 +44,10 @@ export const convertRawTypstAstStringToObject = (rawTypstAstString: string) => { // NOTE: If the line does not match the pattern, it is considered a continuation of the previous value. if (!/^\s*(path:|ast:|- s: |s: |c:)/.test(line)) { if (acc.length > 0) { - acc[acc.length - 1] = - `${acc[acc.length - 1].slice(0, -1)}\\n${line}"`; + acc[acc.length - 1] = `${acc[acc.length - 1].slice( + 0, + -1, + )}\\n${line}"`; } return acc; } @@ -201,11 +203,21 @@ export const convertRawTypstAstObjectToTextlintAstObject = ( }; const calculateOffsets = (node: AstNode, currentOffset = 0): number => { - const startOffset = currentOffset; - + const calculateOffsetFromLocation = ( + location: TxtNodeLineLocation, + ): number => { + const lines = typstSource.split("\n"); + let offset = 0; + for (let i = 0; i < location.start.line - 1; i++) { + offset += lines[i].length + 1; // +1 for newline + } + offset += location.start.column; + return offset; + }; const location = extractLocation(node.s, node.c); const nodeRawText = extractRawSourceByLocation(typstSource, location); const nodeLength = nodeRawText.length; + const startOffset = calculateOffsetFromLocation(location); if (node.c) { // If TxtParentNode @@ -284,7 +296,7 @@ export const convertRawTypstAstObjectToTextlintAstObject = ( node.value = extractRawSourceByLocation(typstSource, location); } - const endOffset = currentOffset + nodeLength; + const endOffset = startOffset + nodeLength; node.raw = extractRawSourceByLocation(typstSource, location); node.range = [startOffset, endOffset]; @@ -302,6 +314,163 @@ export const convertRawTypstAstObjectToTextlintAstObject = ( if (/^Escape::Linebreak/.test(node.type)) { node.type = ASTNodeTypes.Break; } + if (/^Marked::(ListItem|EnumItem)$/.test(node.type)) { + node.type = ASTNodeTypes.ListItem; + // @ts-expect-error + node.spread = false; + // @ts-expect-error + node.checked = null; + + if (node.children && node.children.length > 0) { + const originalRange = node.range; + const originalLoc = node.loc; + const originalRaw = node.raw; + + const contentChildren = node.children.filter( + (child) => + !["Marked::ListMarker", "Marked::EnumMarker"].includes(child.type), + ); + + const flattenedContent: Content[] = []; + for (const child of contentChildren) { + // @ts-expect-error + if (child.type === "Marked::Markup" && child.children) { + // @ts-expect-error + flattenedContent.push(...child.children); + } else { + flattenedContent.push(child); + } + } + + const textContent: Content[] = []; + const nestedListItems: Content[] = []; + + for (const child of flattenedContent) { + if (child.type === ASTNodeTypes.ListItem) { + nestedListItems.push(child); + } else { + textContent.push(child); + } + } + + const processedChildren: Content[] = []; + + if (textContent.length > 0) { + const validTextContent = textContent.filter( + (child) => + !(child.type === ASTNodeTypes.Str && child.raw?.trim() === ""), + ); + + if (validTextContent.length > 0) { + const firstChild = validTextContent[0]; + const lastChild = validTextContent[validTextContent.length - 1]; + + processedChildren.push({ + type: ASTNodeTypes.Paragraph, + // @ts-expect-error + children: validTextContent, + loc: { + start: firstChild.loc.start, + end: lastChild.loc.end, + }, + range: [firstChild.range[0], lastChild.range[1]], + raw: validTextContent.map((c) => c.raw).join(""), + }); + } + } + + if (nestedListItems.length > 0) { + const isOrdered = nestedListItems.some((item) => + /^\d+\./.test(item.raw?.trim() || ""), + ); + + const firstNestedItem = nestedListItems[0]; + const lastNestedItem = nestedListItems[nestedListItems.length - 1]; + + processedChildren.push({ + type: ASTNodeTypes.List, + ordered: isOrdered, + start: isOrdered ? 1 : null, + spread: false, + // @ts-expect-error + children: nestedListItems, + loc: { + start: firstNestedItem.loc.start, + end: lastNestedItem.loc.end, + }, + range: [firstNestedItem.range[0], lastNestedItem.range[1]], + raw: nestedListItems.map((item) => item.raw).join("\n"), + }); + } + + for (const child of processedChildren) { + if (child.type === ASTNodeTypes.Paragraph) { + if (child.children && child.children.length > 0) { + const firstStr = child.children[0]; + const lastStr = child.children[child.children.length - 1]; + + const actualStart = calculateOffsetFromLocation(firstStr.loc); + const actualEnd = calculateOffsetFromLocation({ + start: lastStr.loc.end, + end: lastStr.loc.end, + }); + + child.range = [actualStart, actualEnd]; + + for (const strChild of child.children) { + if (strChild.type === ASTNodeTypes.Str) { + const strStart = calculateOffsetFromLocation(strChild.loc); + const strEnd = calculateOffsetFromLocation({ + start: strChild.loc.end, + end: strChild.loc.end, + }); + strChild.range = [strStart, strEnd]; + } + } + } + } else if (child.type === ASTNodeTypes.List) { + if (child.children && child.children.length > 0) { + const firstListItem = child.children[0]; + const lastListItem = child.children[child.children.length - 1]; + if (firstListItem && lastListItem) { + child.range = [firstListItem.range[0], lastListItem.range[1]]; + } + } + } + } + + node.children = processedChildren; + if (processedChildren.length > 0) { + const firstChild = processedChildren[0]; + const lastChild = processedChildren[processedChildren.length - 1]; + + const markerStart = calculateOffsetFromLocation(originalLoc); + const contentEnd = lastChild.range[1]; + + node.range = [markerStart, contentEnd]; + node.loc = { + start: originalLoc.start, + end: lastChild.loc.end, + }; + + node.raw = extractRawSourceByLocation(typstSource, node.loc); + } else { + const nodeStart = calculateOffsetFromLocation(originalLoc); + const nodeEnd = nodeStart + originalRaw.length; + node.range = [nodeStart, nodeEnd]; + node.loc = originalLoc; + node.raw = originalRaw; + } + + // @ts-expect-error + // biome-ignore lint/performance/noDelete: Convert TxtParentNode to TxtTextNode + delete node.s; + // biome-ignore lint/performance/noDelete: Convert TxtParentNode to TxtTextNode + delete node.c; + + return node.range[1]; + } + } if (node.type === "Marked::Raw") { if (node.loc.start.line === node.loc.end.line) { // If Code @@ -416,46 +585,250 @@ export const paragraphizeTextlintAstObject = ( rootNode: TxtDocumentNode, ): TxtDocumentNode => { const children: Content[] = []; - let paragraph: Content[] = []; + let i = 0; + + while (i < rootNode.children.length) { + const node = rootNode.children[i]; + + // Collect consecutive ListItems into a single List node. + if (node.type === ASTNodeTypes.ListItem) { + const listItems: Content[] = [node]; + i++; + + // Determine if this is an ordered list by checking the original node type. + // Look at the raw content to determine if it's ordered. + const isOrdered = /^\d+\./.test(node.raw?.trim() || ""); + + // Collect consecutive ListItems including those separated by line breaks. + while (i < rootNode.children.length) { + const currentNode = rootNode.children[i]; + + if (currentNode.type === ASTNodeTypes.ListItem) { + // Check if the current item matches the list type (ordered/unordered). + const currentIsOrdered = /^\d+\./.test(currentNode.raw?.trim() || ""); + if (currentIsOrdered === isOrdered) { + listItems.push(currentNode); + i++; + continue; + } + // Different list type, break here. + break; + } - const pushChild = (paragraph: Content[]) => { - if (paragraph.length === 0) return; + // Skip line breaks between ListItems. + if (currentNode.type === ASTNodeTypes.Str && currentNode.raw === "\n") { + if ( + i + 1 < rootNode.children.length && + rootNode.children[i + 1].type === ASTNodeTypes.ListItem + ) { + const nextIsOrdered = /^\d+\./.test( + rootNode.children[i + 1].raw?.trim() || "", + ); + if (nextIsOrdered === isOrdered) { + i++; + continue; + } + } + } - const headNode = paragraph[0]; - const lastNode = paragraph[paragraph.length - 1]; + // Skip line-break-only Paragraphs between ListItems. + if ( + currentNode.type === ASTNodeTypes.Paragraph && + currentNode.children.length === 1 && + currentNode.children[0].type === ASTNodeTypes.Str && + currentNode.children[0].raw === "\n" + ) { + if ( + i + 1 < rootNode.children.length && + rootNode.children[i + 1].type === ASTNodeTypes.ListItem + ) { + const nextIsOrdered = /^\d+\./.test( + rootNode.children[i + 1].raw?.trim() || "", + ); + if (nextIsOrdered === isOrdered) { + i++; + continue; + } + } + } - if (["Kw::Hash", "Fn::(Hash: "#")"].includes(headNode.type)) { - children.push(...paragraph); - return; - } + break; + } - children.push({ - loc: { - start: headNode.loc.start, - end: lastNode.loc.end, - }, - range: [headNode.range[0], lastNode.range[1]], - raw: paragraph.map((node) => node.raw).join(""), - type: ASTNodeTypes.Paragraph, - // @ts-expect-error - children: paragraph, - }); - }; + // Create List node from collected ListItems. + const firstItem = listItems[0]; + const lastItem = listItems[listItems.length - 1]; - for (const node of rootNode.children) { - switch (node.type) { - case ASTNodeTypes.Header: - case ASTNodeTypes.Break: - case ASTNodeTypes.CodeBlock: - pushChild(paragraph); - paragraph = []; + children.push({ + type: ASTNodeTypes.List, + ordered: isOrdered, + start: isOrdered ? 1 : null, + spread: false, + // @ts-expect-error + children: [...listItems], + loc: { + start: firstItem.loc.start, + end: lastItem.loc.end, + }, + range: [firstItem.range[0], lastItem.range[1]], + raw: listItems.map((item) => item.raw).join("\n"), + }); + } + // Skip line-break-only Paragraphs. + else if ( + node.type === ASTNodeTypes.Paragraph && + node.children.length === 1 && + node.children[0].type === ASTNodeTypes.Str && + node.children[0].raw === "\n" + ) { + i++; + } else { + const paragraph: Content[] = []; + + // Add standalone nodes directly without wrapping in Paragraph. + if ( + node.type === ASTNodeTypes.Header || + node.type === ASTNodeTypes.CodeBlock || + node.type === ASTNodeTypes.Break + ) { children.push(node); - break; - default: + i++; + } + // Group other nodes into paragraphs, but handle EnumItems specially. + else { + // Check if this paragraph contains EnumItems that should be converted to a List. + if (node.type === ASTNodeTypes.Paragraph) { + const enumItems: Content[] = + node.children?.filter( + // @ts-expect-error + (child) => child.type === "Marked::EnumItem", + ) || []; + + if (enumItems.length > 0) { + // Convert EnumItems to ListItems. + const listItems = enumItems.map((enumItem) => { + // Remove enum marker and empty Str nodes. + const contentChildren = + // @ts-expect-error + enumItem.children?.filter( + // @ts-expect-error + (child) => + child.type !== "Marked::EnumMarker" && + !(child.type === "Str" && child.raw?.trim() === ""), + ) || []; + + // Use the children of Marked::Markup nodes if they exist. + const actualContent: Content[] = []; + for (const child of contentChildren) { + if (child.type === "Marked::Markup" && child.children) { + actualContent.push(...child.children); + } else { + actualContent.push(child); + } + } + + const firstContentChild = actualContent[0]; + const lastContentChild = actualContent[actualContent.length - 1]; + + return { + type: ASTNodeTypes.ListItem, + spread: false, + checked: null, + children: + actualContent.length > 0 + ? [ + { + type: ASTNodeTypes.Paragraph, + children: actualContent, + loc: { + start: + firstContentChild?.loc?.start || + enumItem.loc.start, + end: lastContentChild?.loc?.end || enumItem.loc.end, + }, + range: [ + firstContentChild?.range?.[0] || enumItem.range[0], + lastContentChild?.range?.[1] || enumItem.range[1], + ], + raw: actualContent.map((child) => child.raw).join(""), + }, + ] + : [], + loc: enumItem.loc, + range: enumItem.range, + raw: enumItem.raw, + }; + }); + + const firstItem = listItems[0]; + const lastItem = listItems[listItems.length - 1]; + + children.push({ + type: ASTNodeTypes.List, + ordered: true, + start: 1, + spread: false, + // @ts-expect-error + children: listItems, + loc: { + start: firstItem.loc.start, + end: lastItem.loc.end, + }, + range: [firstItem.range[0], lastItem.range[1]], + raw: listItems.map((item) => item.raw).join("\n"), + }); + + i++; + continue; + } + } + paragraph.push(node); + i++; + + // Collect consecutive nodes for paragraph grouping. + while (i < rootNode.children.length) { + const currentNode = rootNode.children[i]; + + if ( + currentNode.type === ASTNodeTypes.Header || + currentNode.type === ASTNodeTypes.CodeBlock || + currentNode.type === ASTNodeTypes.Break || + currentNode.type === ASTNodeTypes.ListItem + ) { + break; + } + + paragraph.push(currentNode); + i++; + } + + if (paragraph.length > 0) { + const headNode = paragraph[0]; + const lastNode = paragraph[paragraph.length - 1]; + + // Special handling for hash symbols. + if ( + ["Kw::Hash", "Fn::(Hash: "#")"].includes(headNode.type) + ) { + children.push(...paragraph); + } else { + children.push({ + loc: { + start: headNode.loc.start, + end: lastNode.loc.end, + }, + range: [headNode.range[0], lastNode.range[1]], + raw: paragraph.map((node) => node.raw).join(""), + type: ASTNodeTypes.Paragraph, + // @ts-expect-error + children: paragraph, + }); + } + } + } } } - pushChild(paragraph); return { ...rootNode, children }; }; diff --git a/test/integration/fixtures/smoke/textlint-rule-period-in-list-item/main.typ b/test/integration/fixtures/smoke/textlint-rule-period-in-list-item/main.typ new file mode 100644 index 0000000..cb3bce3 --- /dev/null +++ b/test/integration/fixtures/smoke/textlint-rule-period-in-list-item/main.typ @@ -0,0 +1,45 @@ += Bullet List + +== Normal list + +- Text +- Math. +- Layout + +== Multiple lines + +- This list item spans multiple + lines because it is indented. + +== Function call + +#list( + [Foundations], + [Calculate], + [Construct], + [Data Loading.], +) + += Numbered List + +== Automatically numbered + ++ Preparations. ++ Analysis ++ Conclusions + +== Manually numbered + +2. What is the first step? +5. I am confused. ++ Moving on + +== Multiple lines + ++ This enum item has multiple + lines because the next line + is indented. + +== Function call + +#enum[First.][Second] diff --git a/test/integration/linting.test.ts b/test/integration/linting.test.ts index fb4440d..713177f 100644 --- a/test/integration/linting.test.ts +++ b/test/integration/linting.test.ts @@ -6,7 +6,12 @@ import { type TextlintResult, } from "@textlint/kernel"; // @ts-expect-error -import { rules, rulesConfig } from "textlint-rule-preset-ja-technical-writing"; +import textlintRulePeriodInListItem from "textlint-rule-period-in-list-item"; +import { + rules as textlintRulePresetJaTechnicalWritingRules, + rulesConfig as textlintRulePresetJaTechnicalWritingRulesConfig, + // @ts-expect-error +} from "textlint-rule-preset-ja-technical-writing"; import { beforeAll, describe, expect, it } from "vitest"; @@ -37,12 +42,14 @@ describe("linting", () => { ], rules: [ // Set each rule in the preset individually - ...Object.entries(rules).map( + ...Object.entries(textlintRulePresetJaTechnicalWritingRules).map( ([id, rule]) => ({ ruleId: `ja-technical-writing/${id}`, rule: rule, - options: rulesConfig[id] || true, + options: + textlintRulePresetJaTechnicalWritingRulesConfig[id] || + true, }) as TextlintKernelRule, ), ], @@ -170,5 +177,89 @@ describe("linting", () => { }); } }); + describe("textlint-rule-period-in-list-item", () => { + let textlintResult: TextlintResult; + + beforeAll(async () => { + const kernel = new TextlintKernel(); + textlintResult = await kernel.lintText( + fs.readFileSync( + path.join( + __dirname, + "./fixtures/smoke/textlint-rule-period-in-list-item/main.typ", + ), + "utf-8", + ), + { + ext: ".typ", + plugins: [ + { + pluginId: "typst", + plugin: typstPlugin, + }, + ], + rules: [ + { + ruleId: "period-in-list-item", + rule: textlintRulePeriodInListItem, + }, + ], + }, + ); + }); + const getViolations = () => { + return textlintResult.messages.filter( + (message) => message.ruleId === "period-in-list-item", + ); + }; + + it("should detect period in single line bullet list items", () => { + const violations = getViolations(); + + const singleLineBulletViolation = violations.find( + (v) => v.loc.start.line === 6, + ); + expect(singleLineBulletViolation).toBeDefined(); + expect(singleLineBulletViolation?.message).toBe( + 'Should remove period mark(".") at end of list item.', + ); + }); + + it("should detect period in multiple lines bullet list items", () => { + const violations = getViolations(); + + const multipleLinesBulletViolation = violations.find( + (v) => v.loc.start.line === 12, + ); + expect(multipleLinesBulletViolation).toBeDefined(); + expect(multipleLinesBulletViolation?.message).toBe( + 'Should remove period mark(".") at end of list item.', + ); + }); + + it("should detect period in single line numbered list items", () => { + const violations = getViolations(); + + const singleLineNumberedViolation = violations.find( + (v) => v.loc.start.line === 27, + ); + expect(singleLineNumberedViolation).toBeDefined(); + expect(singleLineNumberedViolation?.message).toBe( + 'Should remove period mark(".") at end of list item.', + ); + }); + + it("should detect period in multiple lines numbered list items", () => { + const violations = getViolations(); + + const multipleLineNumberedViolation = violations.find( + (v) => v.loc.start.line === 41, + ); + expect(multipleLineNumberedViolation).toBeDefined(); + expect(multipleLineNumberedViolation?.message).toBe( + 'Should remove period mark(".") at end of list item.', + ); + }); + }); }); }); diff --git a/test/unit/fixtures/Break/output.json b/test/unit/fixtures/Break/output.json index ac97806..981b0f6 100644 --- a/test/unit/fixtures/Break/output.json +++ b/test/unit/fixtures/Break/output.json @@ -1,455 +1,455 @@ { "children": [ { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, - "range": [0, 19], - "raw": "*Date:* 26.12.2022 ", - "type": "Paragraph", "children": [ { "children": [ { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [0, 1], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 1 + "column": 1, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 1], + "raw": "*", + "type": "Marked::Star", + "value": "*" }, { - "type": "Str", - "raw": "Date:", - "range": [1, 6], "loc": { - "start": { - "line": 1, - "column": 1 - }, "end": { - "line": 1, - "column": 6 + "column": 6, + "line": 1 + }, + "start": { + "column": 1, + "line": 1 } }, + "range": [1, 6], + "raw": "Date:", + "type": "Str", "value": "Date" }, { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [6, 7], "loc": { - "start": { - "line": 1, - "column": 6 - }, "end": { - "line": 1, - "column": 7 + "column": 7, + "line": 1 + }, + "start": { + "column": 6, + "line": 1 } - } + }, + "range": [6, 7], + "raw": "*", + "type": "Marked::Star", + "value": "*" } ], - "type": "Strong", - "raw": "*Date:*", - "range": [0, 7], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 7 + "column": 7, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 7], + "raw": "*Date:*", + "type": "Strong" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [7, 8], "loc": { - "start": { - "line": 1, - "column": 7 - }, "end": { - "line": 1, - "column": 8 + "column": 8, + "line": 1 + }, + "start": { + "column": 7, + "line": 1 } - } + }, + "range": [7, 8], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "26.12.2022", - "type": "Str", - "raw": "26.12.2022", - "range": [8, 18], "loc": { - "start": { - "line": 1, - "column": 8 - }, "end": { - "line": 1, - "column": 18 + "column": 18, + "line": 1 + }, + "start": { + "column": 8, + "line": 1 } - } + }, + "range": [8, 18], + "raw": "26.12.2022", + "type": "Str", + "value": "26.12.2022" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [18, 19], "loc": { - "start": { - "line": 1, - "column": 18 - }, "end": { - "line": 1, - "column": 19 + "column": 19, + "line": 1 + }, + "start": { + "column": 18, + "line": 1 } - } + }, + "range": [18, 19], + "raw": " ", + "type": "Str", + "value": " " } - ] - }, - { - "value": "\\", - "type": "Break", - "raw": "\\", - "range": [19, 20], + ], "loc": { - "start": { - "line": 1, - "column": 19 - }, "end": { - "line": 1, - "column": 20 + "column": 19, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 19], + "raw": "*Date:* 26.12.2022 ", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { - "line": 2, - "column": 29 + "column": 20, + "line": 1 + }, + "start": { + "column": 19, + "line": 1 } }, - "range": [20, 49], - "raw": "*Topic:* Infrastructure Test ", - "type": "Paragraph", + "range": [19, 20], + "raw": "\\", + "type": "Break", + "value": "\\" + }, + { "children": [ { "children": [ { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [20, 21], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { - "line": 2, - "column": 1 + "column": 1, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 } - } + }, + "range": [21, 22], + "raw": "*", + "type": "Marked::Star", + "value": "*" }, { - "type": "Str", - "raw": "Topic:", - "range": [21, 27], "loc": { - "start": { - "line": 2, - "column": 1 - }, "end": { - "line": 2, - "column": 7 + "column": 7, + "line": 2 + }, + "start": { + "column": 1, + "line": 2 } }, + "range": [22, 28], + "raw": "Topic:", + "type": "Str", "value": "Topic" }, { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [27, 28], "loc": { - "start": { - "line": 2, - "column": 7 - }, "end": { - "line": 2, - "column": 8 + "column": 8, + "line": 2 + }, + "start": { + "column": 7, + "line": 2 } - } + }, + "range": [28, 29], + "raw": "*", + "type": "Marked::Star", + "value": "*" } ], - "type": "Strong", - "raw": "*Topic:*", - "range": [20, 28], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { - "line": 2, - "column": 8 + "column": 8, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 } - } + }, + "range": [21, 29], + "raw": "*Topic:*", + "type": "Strong" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [28, 29], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { - "line": 2, - "column": 9 + "column": 9, + "line": 2 + }, + "start": { + "column": 8, + "line": 2 } - } + }, + "range": [29, 30], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "Infrastructure Test", - "type": "Str", - "raw": "Infrastructure Test", - "range": [29, 48], "loc": { - "start": { - "line": 2, - "column": 9 - }, "end": { - "line": 2, - "column": 28 + "column": 28, + "line": 2 + }, + "start": { + "column": 9, + "line": 2 } - } + }, + "range": [30, 49], + "raw": "Infrastructure Test", + "type": "Str", + "value": "Infrastructure Test" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [48, 49], "loc": { - "start": { - "line": 2, - "column": 28 - }, "end": { - "line": 2, - "column": 29 + "column": 29, + "line": 2 + }, + "start": { + "column": 28, + "line": 2 } - } + }, + "range": [49, 50], + "raw": " ", + "type": "Str", + "value": " " } - ] - }, - { - "value": "\\", - "type": "Break", - "raw": "\\", - "range": [49, 50], + ], "loc": { - "start": { - "line": 2, - "column": 29 - }, "end": { - "line": 2, - "column": 30 + "column": 29, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 } - } + }, + "range": [21, 50], + "raw": "*Topic:* Infrastructure Test ", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 17 + "column": 30, + "line": 2 + }, + "start": { + "column": 29, + "line": 2 } }, - "range": [50, 67], - "raw": "*Severity:* High ", - "type": "Paragraph", + "range": [50, 51], + "raw": "\\", + "type": "Break", + "value": "\\" + }, + { "children": [ { "children": [ { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [50, 51], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 1 + "column": 1, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [52, 53], + "raw": "*", + "type": "Marked::Star", + "value": "*" }, { - "type": "Str", - "raw": "Severity:", - "range": [51, 60], "loc": { - "start": { - "line": 3, - "column": 1 - }, "end": { - "line": 3, - "column": 10 + "column": 10, + "line": 3 + }, + "start": { + "column": 1, + "line": 3 } }, + "range": [53, 62], + "raw": "Severity:", + "type": "Str", "value": "Severity" }, { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [60, 61], "loc": { - "start": { - "line": 3, - "column": 10 - }, "end": { - "line": 3, - "column": 11 + "column": 11, + "line": 3 + }, + "start": { + "column": 10, + "line": 3 } - } + }, + "range": [62, 63], + "raw": "*", + "type": "Marked::Star", + "value": "*" } ], - "type": "Strong", - "raw": "*Severity:*", - "range": [50, 61], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 11 + "column": 11, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [52, 63], + "raw": "*Severity:*", + "type": "Strong" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [61, 62], "loc": { - "start": { - "line": 3, - "column": 11 - }, "end": { - "line": 3, - "column": 12 + "column": 12, + "line": 3 + }, + "start": { + "column": 11, + "line": 3 } - } + }, + "range": [63, 64], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "High", - "type": "Str", - "raw": "High", - "range": [62, 66], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { - "line": 3, - "column": 16 + "column": 16, + "line": 3 + }, + "start": { + "column": 12, + "line": 3 } - } + }, + "range": [64, 68], + "raw": "High", + "type": "Str", + "value": "High" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [66, 67], "loc": { - "start": { - "line": 3, - "column": 16 - }, "end": { - "line": 3, - "column": 17 + "column": 17, + "line": 3 + }, + "start": { + "column": 16, + "line": 3 } - } + }, + "range": [68, 69], + "raw": " ", + "type": "Str", + "value": " " + } + ], + "loc": { + "end": { + "column": 17, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - ] + }, + "range": [52, 69], + "raw": "*Severity:* High ", + "type": "Paragraph" }, { - "value": "\\", - "type": "Break", - "raw": "\\", - "range": [67, 68], "loc": { - "start": { - "line": 3, - "column": 17 - }, "end": { - "line": 3, - "column": 18 + "column": 18, + "line": 3 + }, + "start": { + "column": 17, + "line": 3 } - } + }, + "range": [69, 70], + "raw": "\\", + "type": "Break", + "value": "\\" } ], - "type": "Document", - "raw": "*Date:* 26.12.2022 \\\n*Topic:* Infrastructure Test \\\n*Severity:* High \\", - "range": [0, 70], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 3, - "column": 18 + "column": 18, + "line": 3 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 70], + "raw": "*Date:* 26.12.2022 \\\n*Topic:* Infrastructure Test \\\n*Severity:* High \\", + "type": "Document" } diff --git a/test/unit/fixtures/Code/output.json b/test/unit/fixtures/Code/output.json index 5e77459..c84ea1b 100644 --- a/test/unit/fixtures/Code/output.json +++ b/test/unit/fixtures/Code/output.json @@ -1,613 +1,613 @@ { "children": [ { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "range": [0, 13], - "raw": "`inline code`", - "type": "Paragraph", "children": [ { - "type": "Code", - "raw": "`inline code`", - "range": [0, 13], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 13 + "column": 13, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } }, + "range": [0, 13], + "raw": "`inline code`", + "type": "Code", "value": "inline code" } - ] - }, - { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [13, 15], + ], "loc": { - "start": { - "line": 1, - "column": 13 - }, "end": { - "line": 3, - "column": 0 + "column": 13, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 13], + "raw": "`inline code`", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 21 + "column": 0, + "line": 3 + }, + "start": { + "column": 13, + "line": 1 } }, - "range": [15, 36], - "raw": "aaa `inline code` bbb", - "type": "Paragraph", + "range": [13, 15], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { "children": [ { - "value": "aaa", - "type": "Str", - "raw": "aaa", - "range": [15, 18], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 3 + "column": 3, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [15, 18], + "raw": "aaa", + "type": "Str", + "value": "aaa" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [18, 19], "loc": { - "start": { - "line": 3, - "column": 3 - }, "end": { - "line": 3, - "column": 4 + "column": 4, + "line": 3 + }, + "start": { + "column": 3, + "line": 3 } - } + }, + "range": [18, 19], + "raw": " ", + "type": "Str", + "value": " " }, { - "type": "Code", - "raw": "`inline code`", - "range": [19, 32], "loc": { - "start": { - "line": 3, - "column": 4 - }, "end": { - "line": 3, - "column": 17 + "column": 17, + "line": 3 + }, + "start": { + "column": 4, + "line": 3 } }, + "range": [19, 32], + "raw": "`inline code`", + "type": "Code", "value": "inline code" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [32, 33], "loc": { - "start": { - "line": 3, - "column": 17 - }, "end": { - "line": 3, - "column": 18 + "column": 18, + "line": 3 + }, + "start": { + "column": 17, + "line": 3 } - } + }, + "range": [32, 33], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "bbb", - "type": "Str", - "raw": "bbb", - "range": [33, 36], "loc": { - "start": { - "line": 3, - "column": 18 - }, "end": { - "line": 3, - "column": 21 + "column": 21, + "line": 3 + }, + "start": { + "column": 18, + "line": 3 } - } + }, + "range": [33, 36], + "raw": "bbb", + "type": "Str", + "value": "bbb" } - ] - }, - { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [36, 38], + ], "loc": { - "start": { - "line": 3, - "column": 21 - }, "end": { - "line": 5, - "column": 0 + "column": 21, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [15, 36], + "raw": "aaa `inline code` bbb", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 6, - "column": 33 + "column": 0, + "line": 5 + }, + "start": { + "column": 21, + "line": 3 } }, - "range": [38, 108], - "raw": "What is ```rust fn main()``` in Rust\nwould be ```c int main()``` in C.", - "type": "Paragraph", + "range": [36, 38], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { "children": [ { - "value": "What is", - "type": "Str", - "raw": "What is", - "range": [38, 45], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 5, - "column": 7 + "column": 7, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 } - } + }, + "range": [38, 45], + "raw": "What is", + "type": "Str", + "value": "What is" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [45, 46], "loc": { - "start": { - "line": 5, - "column": 7 - }, "end": { - "line": 5, - "column": 8 + "column": 8, + "line": 5 + }, + "start": { + "column": 7, + "line": 5 } - } + }, + "range": [45, 46], + "raw": " ", + "type": "Str", + "value": " " }, { - "type": "Code", - "raw": "```rust fn main()```", - "range": [46, 66], "loc": { - "start": { - "line": 5, - "column": 8 - }, "end": { - "line": 5, - "column": 28 + "column": 28, + "line": 5 + }, + "start": { + "column": 8, + "line": 5 } }, + "range": [46, 66], + "raw": "```rust fn main()```", + "type": "Code", "value": "fn main()" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [66, 67], "loc": { - "start": { - "line": 5, - "column": 28 - }, "end": { - "line": 5, - "column": 29 + "column": 29, + "line": 5 + }, + "start": { + "column": 28, + "line": 5 } - } + }, + "range": [66, 67], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "in Rust", - "type": "Str", - "raw": "in Rust", - "range": [67, 74], "loc": { - "start": { - "line": 5, - "column": 29 - }, "end": { - "line": 5, - "column": 36 + "column": 36, + "line": 5 + }, + "start": { + "column": 29, + "line": 5 } - } + }, + "range": [67, 74], + "raw": "in Rust", + "type": "Str", + "value": "in Rust" }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [74, 75], "loc": { - "start": { - "line": 5, - "column": 36 - }, "end": { - "line": 6, - "column": 0 + "column": 0, + "line": 6 + }, + "start": { + "column": 36, + "line": 5 } - } + }, + "range": [74, 75], + "raw": "\n", + "type": "Str", + "value": "\n" }, { - "value": "would be", - "type": "Str", - "raw": "would be", - "range": [75, 83], "loc": { - "start": { - "line": 6, - "column": 0 - }, "end": { - "line": 6, - "column": 8 + "column": 8, + "line": 6 + }, + "start": { + "column": 0, + "line": 6 } - } + }, + "range": [75, 83], + "raw": "would be", + "type": "Str", + "value": "would be" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [83, 84], "loc": { - "start": { - "line": 6, - "column": 8 - }, "end": { - "line": 6, - "column": 9 + "column": 9, + "line": 6 + }, + "start": { + "column": 8, + "line": 6 } - } + }, + "range": [83, 84], + "raw": " ", + "type": "Str", + "value": " " }, { - "type": "Code", - "raw": "```c int main()```", - "range": [84, 102], "loc": { - "start": { - "line": 6, - "column": 9 - }, "end": { - "line": 6, - "column": 27 + "column": 27, + "line": 6 + }, + "start": { + "column": 9, + "line": 6 } }, + "range": [84, 102], + "raw": "```c int main()```", + "type": "Code", "value": "int main()" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [102, 103], "loc": { - "start": { - "line": 6, - "column": 27 - }, "end": { - "line": 6, - "column": 28 + "column": 28, + "line": 6 + }, + "start": { + "column": 27, + "line": 6 } - } + }, + "range": [102, 103], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "in C.", - "type": "Str", - "raw": "in C.", - "range": [103, 108], "loc": { - "start": { - "line": 6, - "column": 28 - }, "end": { - "line": 6, - "column": 33 + "column": 33, + "line": 6 + }, + "start": { + "column": 28, + "line": 6 } - } + }, + "range": [103, 108], + "raw": "in C.", + "type": "Str", + "value": "in C." } - ] - }, - { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [108, 110], + ], "loc": { - "start": { - "line": 6, - "column": 33 - }, "end": { - "line": 8, - "column": 0 + "column": 33, + "line": 6 + }, + "start": { + "column": 0, + "line": 5 } - } + }, + "range": [38, 108], + "raw": "What is ```rust fn main()``` in Rust\nwould be ```c int main()``` in C.", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 8, - "column": 0 - }, "end": { - "line": 11, - "column": 13 + "column": 0, + "line": 8 + }, + "start": { + "column": 33, + "line": 6 } }, - "range": [110, 225], - "raw": "This has ``` `backticks` ``` in it\n(but the spaces are trimmed). And\n``` here``` the leading space is\nalso trimmed.", - "type": "Paragraph", + "range": [108, 110], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { "children": [ { - "value": "This has", - "type": "Str", - "raw": "This has", - "range": [110, 118], "loc": { - "start": { - "line": 8, - "column": 0 - }, "end": { - "line": 8, - "column": 8 + "column": 8, + "line": 8 + }, + "start": { + "column": 0, + "line": 8 } - } + }, + "range": [110, 118], + "raw": "This has", + "type": "Str", + "value": "This has" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [118, 119], "loc": { - "start": { - "line": 8, - "column": 8 - }, "end": { - "line": 8, - "column": 9 + "column": 9, + "line": 8 + }, + "start": { + "column": 8, + "line": 8 } - } + }, + "range": [118, 119], + "raw": " ", + "type": "Str", + "value": " " }, { - "type": "Code", - "raw": "``` `backticks` ```", - "range": [119, 138], "loc": { - "start": { - "line": 8, - "column": 9 - }, "end": { - "line": 8, - "column": 28 + "column": 28, + "line": 8 + }, + "start": { + "column": 9, + "line": 8 } }, + "range": [119, 138], + "raw": "``` `backticks` ```", + "type": "Code", "value": "`backticks`" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [138, 139], "loc": { - "start": { - "line": 8, - "column": 28 - }, "end": { - "line": 8, - "column": 29 + "column": 29, + "line": 8 + }, + "start": { + "column": 28, + "line": 8 } - } + }, + "range": [138, 139], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "in it", - "type": "Str", - "raw": "in it", - "range": [139, 144], "loc": { - "start": { - "line": 8, - "column": 29 - }, "end": { - "line": 8, - "column": 34 + "column": 34, + "line": 8 + }, + "start": { + "column": 29, + "line": 8 } - } + }, + "range": [139, 144], + "raw": "in it", + "type": "Str", + "value": "in it" }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [144, 145], "loc": { - "start": { - "line": 8, - "column": 34 - }, "end": { - "line": 9, - "column": 0 + "column": 0, + "line": 9 + }, + "start": { + "column": 34, + "line": 8 } - } + }, + "range": [144, 145], + "raw": "\n", + "type": "Str", + "value": "\n" }, { - "value": "(but the spaces are trimmed). And", - "type": "Str", - "raw": "(but the spaces are trimmed). And", - "range": [145, 178], "loc": { - "start": { - "line": 9, - "column": 0 - }, "end": { - "line": 9, - "column": 33 + "column": 33, + "line": 9 + }, + "start": { + "column": 0, + "line": 9 } - } + }, + "range": [145, 178], + "raw": "(but the spaces are trimmed). And", + "type": "Str", + "value": "(but the spaces are trimmed). And" }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [178, 179], "loc": { - "start": { - "line": 9, - "column": 33 - }, "end": { - "line": 10, - "column": 0 + "column": 0, + "line": 10 + }, + "start": { + "column": 33, + "line": 9 } - } + }, + "range": [178, 179], + "raw": "\n", + "type": "Str", + "value": "\n" }, { - "type": "Code", - "raw": "``` here```", - "range": [179, 190], "loc": { - "start": { - "line": 10, - "column": 0 - }, "end": { - "line": 10, - "column": 11 + "column": 11, + "line": 10 + }, + "start": { + "column": 0, + "line": 10 } }, + "range": [179, 190], + "raw": "``` here```", + "type": "Code", "value": "here" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [190, 191], "loc": { - "start": { - "line": 10, - "column": 11 - }, "end": { - "line": 10, - "column": 12 + "column": 12, + "line": 10 + }, + "start": { + "column": 11, + "line": 10 } - } + }, + "range": [190, 191], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "the leading space is", - "type": "Str", - "raw": "the leading space is", - "range": [191, 211], "loc": { - "start": { - "line": 10, - "column": 12 - }, "end": { - "line": 10, - "column": 32 + "column": 32, + "line": 10 + }, + "start": { + "column": 12, + "line": 10 } - } + }, + "range": [191, 211], + "raw": "the leading space is", + "type": "Str", + "value": "the leading space is" }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [211, 212], "loc": { - "start": { - "line": 10, - "column": 32 - }, "end": { - "line": 11, - "column": 0 + "column": 0, + "line": 11 + }, + "start": { + "column": 32, + "line": 10 } - } + }, + "range": [211, 212], + "raw": "\n", + "type": "Str", + "value": "\n" }, { - "value": "also trimmed.", - "type": "Str", - "raw": "also trimmed.", - "range": [212, 225], "loc": { - "start": { - "line": 11, - "column": 0 - }, "end": { - "line": 11, - "column": 13 + "column": 13, + "line": 11 + }, + "start": { + "column": 0, + "line": 11 } - } + }, + "range": [212, 225], + "raw": "also trimmed.", + "type": "Str", + "value": "also trimmed." + } + ], + "loc": { + "end": { + "column": 13, + "line": 11 + }, + "start": { + "column": 0, + "line": 8 } - ] + }, + "range": [110, 225], + "raw": "This has ``` `backticks` ``` in it\n(but the spaces are trimmed). And\n``` here``` the leading space is\nalso trimmed.", + "type": "Paragraph" } ], - "type": "Document", - "raw": "`inline code`\n\naaa `inline code` bbb\n\nWhat is ```rust fn main()``` in Rust\nwould be ```c int main()``` in C.\n\nThis has ``` `backticks` ``` in it\n(but the spaces are trimmed). And\n``` here``` the leading space is\nalso trimmed.", - "range": [0, 225], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 11, - "column": 13 + "column": 13, + "line": 11 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 225], + "raw": "`inline code`\n\naaa `inline code` bbb\n\nWhat is ```rust fn main()``` in Rust\nwould be ```c int main()``` in C.\n\nThis has ``` `backticks` ``` in it\n(but the spaces are trimmed). And\n``` here``` the leading space is\nalso trimmed.", + "type": "Document" } diff --git a/test/unit/fixtures/CodeBlock/output.json b/test/unit/fixtures/CodeBlock/output.json index c623ac6..6a73642 100644 --- a/test/unit/fixtures/CodeBlock/output.json +++ b/test/unit/fixtures/CodeBlock/output.json @@ -1,67 +1,67 @@ { "children": [ { - "type": "CodeBlock", - "raw": "```rust\nfn main() {\n println!(\"Hello World!\");\n}\n```", - "range": [0, 55], + "lang": "rust", "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 5, - "column": 3 + "column": 3, + "line": 5 + }, + "start": { + "column": 0, + "line": 1 } }, - "value": "fn main() {\n println!(\"Hello World!\");\n}", - "lang": "rust" + "range": [0, 55], + "raw": "```rust\nfn main() {\n println!(\"Hello World!\");\n}\n```", + "type": "CodeBlock", + "value": "fn main() {\n println!(\"Hello World!\");\n}" }, { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [55, 57], "loc": { - "start": { - "line": 5, - "column": 3 - }, "end": { - "line": 7, - "column": 0 + "column": 0, + "line": 7 + }, + "start": { + "column": 3, + "line": 5 } - } + }, + "range": [55, 57], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" }, { - "type": "CodeBlock", - "raw": "```\nlanguage is undefined.\n```", - "range": [57, 87], + "lang": null, "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { - "line": 9, - "column": 3 + "column": 3, + "line": 9 + }, + "start": { + "column": 0, + "line": 7 } }, - "value": "language is undefined.", - "lang": null + "range": [57, 87], + "raw": "```\nlanguage is undefined.\n```", + "type": "CodeBlock", + "value": "language is undefined." } ], - "type": "Document", - "raw": "```rust\nfn main() {\n println!(\"Hello World!\");\n}\n```\n\n```\nlanguage is undefined.\n```", - "range": [0, 87], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 9, - "column": 3 + "column": 3, + "line": 9 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 87], + "raw": "```rust\nfn main() {\n println!(\"Hello World!\");\n}\n```\n\n```\nlanguage is undefined.\n```", + "type": "Document" } diff --git a/test/unit/fixtures/Comment/output.json b/test/unit/fixtures/Comment/output.json index 42339be..507ccea 100644 --- a/test/unit/fixtures/Comment/output.json +++ b/test/unit/fixtures/Comment/output.json @@ -1,276 +1,276 @@ { "children": [ { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 2, - "column": 27 - } - }, - "range": [0, 49], - "raw": "// This is a comment.\n// This is another comment.", - "type": "Paragraph", "children": [ { - "value": "This is a comment.", - "type": "Comment", - "raw": "// This is a comment.", - "range": [0, 21], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 21 + "column": 21, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 21], + "raw": "// This is a comment.", + "type": "Comment", + "value": "This is a comment." }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [21, 22], "loc": { - "start": { - "line": 1, - "column": 21 - }, "end": { - "line": 2, - "column": 0 + "column": 0, + "line": 2 + }, + "start": { + "column": 21, + "line": 1 } - } + }, + "range": [21, 22], + "raw": "\n", + "type": "Str", + "value": "\n" }, { - "value": "This is another comment.", - "type": "Comment", - "raw": "// This is another comment.", - "range": [22, 49], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { - "line": 2, - "column": 27 + "column": 27, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 } - } + }, + "range": [22, 49], + "raw": "// This is another comment.", + "type": "Comment", + "value": "This is another comment." } - ] - }, - { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [49, 51], + ], "loc": { - "start": { - "line": 2, - "column": 27 - }, "end": { - "line": 4, - "column": 0 + "column": 27, + "line": 2 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 49], + "raw": "// This is a comment.\n// This is another comment.", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 4, - "column": 0 - }, "end": { - "line": 4, - "column": 24 + "column": 0, + "line": 4 + }, + "start": { + "column": 27, + "line": 2 } }, - "range": [51, 75], - "raw": "This is a /* comment */.", - "type": "Paragraph", + "range": [49, 51], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { "children": [ { - "value": "This is a", - "type": "Str", - "raw": "This is a", - "range": [51, 60], "loc": { - "start": { - "line": 4, - "column": 0 - }, "end": { - "line": 4, - "column": 9 + "column": 9, + "line": 4 + }, + "start": { + "column": 0, + "line": 4 } - } + }, + "range": [51, 60], + "raw": "This is a", + "type": "Str", + "value": "This is a" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [60, 61], "loc": { - "start": { - "line": 4, - "column": 9 - }, "end": { - "line": 4, - "column": 10 + "column": 10, + "line": 4 + }, + "start": { + "column": 9, + "line": 4 } - } + }, + "range": [60, 61], + "raw": " ", + "type": "Str", + "value": " " }, { - "value": "comment", - "type": "Comment", - "raw": "/* comment */", - "range": [61, 74], "loc": { - "start": { - "line": 4, - "column": 10 - }, "end": { - "line": 4, - "column": 23 + "column": 23, + "line": 4 + }, + "start": { + "column": 10, + "line": 4 } - } + }, + "range": [61, 74], + "raw": "/* comment */", + "type": "Comment", + "value": "comment" }, { - "value": ".", - "type": "Str", - "raw": ".", - "range": [74, 75], "loc": { - "start": { - "line": 4, - "column": 23 - }, "end": { - "line": 4, - "column": 24 + "column": 24, + "line": 4 + }, + "start": { + "column": 23, + "line": 4 } - } + }, + "range": [74, 75], + "raw": ".", + "type": "Str", + "value": "." } - ] - }, - { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [75, 77], + ], "loc": { - "start": { - "line": 4, - "column": 24 - }, "end": { - "line": 6, - "column": 0 + "column": 24, + "line": 4 + }, + "start": { + "column": 0, + "line": 4 } - } + }, + "range": [51, 75], + "raw": "This is a /* comment */.", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 6, - "column": 0 - }, "end": { - "line": 9, - "column": 24 + "column": 0, + "line": 6 + }, + "start": { + "column": 24, + "line": 4 } }, - "range": [77, 184], - "raw": "Our study design is as follows:\n/* Somebody write this up:\n - 1000 participants.\n - 2x2 data design. */", - "type": "Paragraph", + "range": [75, 77], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { "children": [ { - "value": "Our study design is as follows", - "type": "Str", - "raw": "Our study design is as follows", - "range": [77, 107], "loc": { - "start": { - "line": 6, - "column": 0 - }, "end": { - "line": 6, - "column": 30 + "column": 30, + "line": 6 + }, + "start": { + "column": 0, + "line": 6 } - } + }, + "range": [77, 107], + "raw": "Our study design is as follows", + "type": "Str", + "value": "Our study design is as follows" }, { - "value": ":", - "type": "Str", - "raw": ":", - "range": [107, 108], "loc": { - "start": { - "line": 6, - "column": 30 - }, "end": { - "line": 6, - "column": 31 + "column": 31, + "line": 6 + }, + "start": { + "column": 30, + "line": 6 } - } + }, + "range": [107, 108], + "raw": ":", + "type": "Str", + "value": ":" }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [108, 109], "loc": { - "start": { - "line": 6, - "column": 31 - }, "end": { - "line": 7, - "column": 0 + "column": 0, + "line": 7 + }, + "start": { + "column": 31, + "line": 6 } - } + }, + "range": [108, 109], + "raw": "\n", + "type": "Str", + "value": "\n" }, { - "value": "Somebody write this up:\n - 1000 participants.\n - 2x2 data design.", - "type": "Comment", - "raw": "/* Somebody write this up:\n - 1000 participants.\n - 2x2 data design. */", - "range": [109, 184], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { - "line": 9, - "column": 24 + "column": 24, + "line": 9 + }, + "start": { + "column": 0, + "line": 7 } - } + }, + "range": [109, 184], + "raw": "/* Somebody write this up:\n - 1000 participants.\n - 2x2 data design. */", + "type": "Comment", + "value": "Somebody write this up:\n - 1000 participants.\n - 2x2 data design." + } + ], + "loc": { + "end": { + "column": 24, + "line": 9 + }, + "start": { + "column": 0, + "line": 6 } - ] + }, + "range": [77, 184], + "raw": "Our study design is as follows:\n/* Somebody write this up:\n - 1000 participants.\n - 2x2 data design. */", + "type": "Paragraph" } ], - "type": "Document", - "raw": "// This is a comment.\n// This is another comment.\n\nThis is a /* comment */.\n\nOur study design is as follows:\n/* Somebody write this up:\n - 1000 participants.\n - 2x2 data design. */", - "range": [0, 184], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 9, - "column": 24 + "column": 24, + "line": 9 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 184], + "raw": "// This is a comment.\n// This is another comment.\n\nThis is a /* comment */.\n\nOur study design is as follows:\n/* Somebody write this up:\n - 1000 participants.\n - 2x2 data design. */", + "type": "Document" } diff --git a/test/unit/fixtures/Emphasis/output.json b/test/unit/fixtures/Emphasis/output.json index a4f49dd..816f48a 100644 --- a/test/unit/fixtures/Emphasis/output.json +++ b/test/unit/fixtures/Emphasis/output.json @@ -1,359 +1,359 @@ { "children": [ { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 10 - } - }, - "range": [0, 10], - "raw": "_emphasis_", - "type": "Paragraph", "children": [ { "children": [ { - "value": "_", - "type": "Marked::Underscore", - "raw": "_", - "range": [0, 1], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 1 + "column": 1, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 1], + "raw": "_", + "type": "Marked::Underscore", + "value": "_" }, { - "type": "Str", - "raw": "emphasis", - "range": [1, 9], "loc": { - "start": { - "line": 1, - "column": 1 - }, "end": { - "line": 1, - "column": 9 + "column": 9, + "line": 1 + }, + "start": { + "column": 1, + "line": 1 } }, + "range": [1, 9], + "raw": "emphasis", + "type": "Str", "value": "emphasis" }, { - "value": "_", - "type": "Marked::Underscore", - "raw": "_", - "range": [9, 10], "loc": { - "start": { - "line": 1, - "column": 9 - }, "end": { - "line": 1, - "column": 10 + "column": 10, + "line": 1 + }, + "start": { + "column": 9, + "line": 1 } - } + }, + "range": [9, 10], + "raw": "_", + "type": "Marked::Underscore", + "value": "_" } ], - "type": "Emphasis", - "raw": "_emphasis_", - "range": [0, 10], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 10 + "column": 10, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 10], + "raw": "_emphasis_", + "type": "Emphasis" } - ] - }, - { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [10, 12], + ], "loc": { - "start": { - "line": 1, - "column": 10 - }, "end": { - "line": 3, - "column": 0 + "column": 10, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 10], + "raw": "_emphasis_", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 4, - "column": 0 + "column": 0, + "line": 3 + }, + "start": { + "column": 10, + "line": 1 } }, - "range": [12, 22], - "raw": "_ a b c _\n", - "type": "Paragraph", + "range": [10, 12], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { "children": [ { "children": [ { - "value": "_", - "type": "Marked::Underscore", - "raw": "_", - "range": [12, 13], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 1 + "column": 1, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [12, 13], + "raw": "_", + "type": "Marked::Underscore", + "value": "_" }, { - "type": "Str", - "raw": " a b c ", - "range": [13, 20], "loc": { - "start": { - "line": 3, - "column": 1 - }, "end": { - "line": 3, - "column": 8 + "column": 8, + "line": 3 + }, + "start": { + "column": 1, + "line": 3 } }, + "range": [13, 20], + "raw": " a b c ", + "type": "Str", "value": "a b c" }, { - "value": "_", - "type": "Marked::Underscore", - "raw": "_", - "range": [20, 21], "loc": { - "start": { - "line": 3, - "column": 8 - }, "end": { - "line": 3, - "column": 9 + "column": 9, + "line": 3 + }, + "start": { + "column": 8, + "line": 3 } - } + }, + "range": [20, 21], + "raw": "_", + "type": "Marked::Underscore", + "value": "_" } ], - "type": "Emphasis", - "raw": "_ a b c _", - "range": [12, 21], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 9 + "column": 9, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [12, 21], + "raw": "_ a b c _", + "type": "Emphasis" }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [21, 22], "loc": { - "start": { - "line": 3, - "column": 9 - }, "end": { - "line": 4, - "column": 0 + "column": 0, + "line": 4 + }, + "start": { + "column": 9, + "line": 3 } - } + }, + "range": [21, 22], + "raw": "\n", + "type": "Str", + "value": "\n" } - ] - }, - { - "value": "\\", - "type": "Break", - "raw": "\\", - "range": [22, 23], + ], "loc": { - "start": { - "line": 4, - "column": 0 - }, "end": { - "line": 4, - "column": 1 + "column": 0, + "line": 4 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [12, 22], + "raw": "_ a b c _\n", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 5, - "column": 21 + "column": 1, + "line": 4 + }, + "start": { + "column": 0, + "line": 4 } }, - "range": [23, 44], - "raw": "This is _emphasized_.", - "type": "Paragraph", + "range": [22, 23], + "raw": "\\", + "type": "Break", + "value": "\\" + }, + { "children": [ { - "value": "This is", - "type": "Str", - "raw": "This is", - "range": [23, 30], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 5, - "column": 7 + "column": 7, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 } - } + }, + "range": [24, 31], + "raw": "This is", + "type": "Str", + "value": "This is" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [30, 31], "loc": { - "start": { - "line": 5, - "column": 7 - }, "end": { - "line": 5, - "column": 8 + "column": 8, + "line": 5 + }, + "start": { + "column": 7, + "line": 5 } - } + }, + "range": [31, 32], + "raw": " ", + "type": "Str", + "value": " " }, { "children": [ { - "value": "_", - "type": "Marked::Underscore", - "raw": "_", - "range": [31, 32], "loc": { - "start": { - "line": 5, - "column": 8 - }, "end": { - "line": 5, - "column": 9 + "column": 9, + "line": 5 + }, + "start": { + "column": 8, + "line": 5 } - } + }, + "range": [32, 33], + "raw": "_", + "type": "Marked::Underscore", + "value": "_" }, { - "type": "Str", - "raw": "emphasized", - "range": [32, 42], "loc": { - "start": { - "line": 5, - "column": 9 - }, "end": { - "line": 5, - "column": 19 + "column": 19, + "line": 5 + }, + "start": { + "column": 9, + "line": 5 } }, + "range": [33, 43], + "raw": "emphasized", + "type": "Str", "value": "emphasized" }, { - "value": "_", - "type": "Marked::Underscore", - "raw": "_", - "range": [42, 43], "loc": { - "start": { - "line": 5, - "column": 19 - }, "end": { - "line": 5, - "column": 20 + "column": 20, + "line": 5 + }, + "start": { + "column": 19, + "line": 5 } - } + }, + "range": [43, 44], + "raw": "_", + "type": "Marked::Underscore", + "value": "_" } ], - "type": "Emphasis", - "raw": "_emphasized_", - "range": [31, 43], "loc": { - "start": { - "line": 5, - "column": 8 - }, "end": { - "line": 5, - "column": 20 + "column": 20, + "line": 5 + }, + "start": { + "column": 8, + "line": 5 } - } + }, + "range": [32, 44], + "raw": "_emphasized_", + "type": "Emphasis" }, { - "value": ".", - "type": "Str", - "raw": ".", - "range": [43, 44], "loc": { - "start": { - "line": 5, - "column": 20 - }, "end": { - "line": 5, - "column": 21 + "column": 21, + "line": 5 + }, + "start": { + "column": 20, + "line": 5 } - } + }, + "range": [44, 45], + "raw": ".", + "type": "Str", + "value": "." + } + ], + "loc": { + "end": { + "column": 21, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 } - ] + }, + "range": [24, 45], + "raw": "This is _emphasized_.", + "type": "Paragraph" } ], - "type": "Document", - "raw": "_emphasis_\n\n_ a b c _\n\\\nThis is _emphasized_.", - "range": [0, 45], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 5, - "column": 21 + "column": 21, + "line": 5 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 45], + "raw": "_emphasis_\n\n_ a b c _\n\\\nThis is _emphasized_.", + "type": "Document" } diff --git a/test/unit/fixtures/Header/output.json b/test/unit/fixtures/Header/output.json index 9c3a1bf..7e0f088 100644 --- a/test/unit/fixtures/Header/output.json +++ b/test/unit/fixtures/Header/output.json @@ -3,293 +3,293 @@ { "children": [ { - "value": "=", - "type": "Marked::HeadingMarker", - "raw": "=", - "range": [0, 1], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 1 + "column": 1, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 1], + "raw": "=", + "type": "Marked::HeadingMarker", + "value": "=" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [1, 2], "loc": { - "start": { - "line": 1, - "column": 1 - }, "end": { - "line": 1, - "column": 2 + "column": 2, + "line": 1 + }, + "start": { + "column": 1, + "line": 1 } - } + }, + "range": [1, 2], + "raw": " ", + "type": "Str", + "value": " " }, { "children": [ { - "value": "header 1", - "type": "Str", - "raw": "header 1", - "range": [2, 10], "loc": { - "start": { - "line": 1, - "column": 2 - }, "end": { - "line": 1, - "column": 10 + "column": 10, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 } - } + }, + "range": [2, 10], + "raw": "header 1", + "type": "Str", + "value": "header 1" } ], - "type": "Marked::Markup", - "raw": "header 1", - "range": [2, 10], "loc": { - "start": { - "line": 1, - "column": 2 - }, "end": { - "line": 1, - "column": 10 + "column": 10, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 } - } + }, + "range": [2, 10], + "raw": "header 1", + "type": "Marked::Markup" } ], - "type": "Header", - "raw": "= header 1", - "range": [0, 10], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 10 + "column": 10, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 10], + "raw": "= header 1", + "type": "Header" }, { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [10, 12], "loc": { - "start": { - "line": 1, - "column": 10 - }, "end": { - "line": 3, - "column": 0 + "column": 0, + "line": 3 + }, + "start": { + "column": 10, + "line": 1 } - } + }, + "range": [10, 12], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" }, { "children": [ { - "value": "==", - "type": "Marked::HeadingMarker", - "raw": "==", - "range": [12, 14], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 2 + "column": 2, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [12, 14], + "raw": "==", + "type": "Marked::HeadingMarker", + "value": "==" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [14, 15], "loc": { - "start": { - "line": 3, - "column": 2 - }, "end": { - "line": 3, - "column": 3 + "column": 3, + "line": 3 + }, + "start": { + "column": 2, + "line": 3 } - } + }, + "range": [14, 15], + "raw": " ", + "type": "Str", + "value": " " }, { "children": [ { - "value": "header 2", - "type": "Str", - "raw": "header 2", - "range": [15, 23], "loc": { - "start": { - "line": 3, - "column": 3 - }, "end": { - "line": 3, - "column": 11 + "column": 11, + "line": 3 + }, + "start": { + "column": 3, + "line": 3 } - } + }, + "range": [15, 23], + "raw": "header 2", + "type": "Str", + "value": "header 2" } ], - "type": "Marked::Markup", - "raw": "header 2", - "range": [15, 23], "loc": { - "start": { - "line": 3, - "column": 3 - }, "end": { - "line": 3, - "column": 11 + "column": 11, + "line": 3 + }, + "start": { + "column": 3, + "line": 3 } - } + }, + "range": [15, 23], + "raw": "header 2", + "type": "Marked::Markup" } ], - "type": "Header", - "raw": "== header 2", - "range": [12, 23], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 11 + "column": 11, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [12, 23], + "raw": "== header 2", + "type": "Header" }, { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [23, 25], "loc": { - "start": { - "line": 3, - "column": 11 - }, "end": { - "line": 5, - "column": 0 + "column": 0, + "line": 5 + }, + "start": { + "column": 11, + "line": 3 } - } + }, + "range": [23, 25], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" }, { "children": [ { - "value": "===", - "type": "Marked::HeadingMarker", - "raw": "===", - "range": [25, 28], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 5, - "column": 3 + "column": 3, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 } - } + }, + "range": [25, 28], + "raw": "===", + "type": "Marked::HeadingMarker", + "value": "===" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [28, 29], "loc": { - "start": { - "line": 5, - "column": 3 - }, "end": { - "line": 5, - "column": 4 + "column": 4, + "line": 5 + }, + "start": { + "column": 3, + "line": 5 } - } + }, + "range": [28, 29], + "raw": " ", + "type": "Str", + "value": " " }, { "children": [ { - "value": "header 3", - "type": "Str", - "raw": "header 3", - "range": [29, 37], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { - "line": 5, - "column": 12 + "column": 12, + "line": 5 + }, + "start": { + "column": 4, + "line": 5 } - } + }, + "range": [29, 37], + "raw": "header 3", + "type": "Str", + "value": "header 3" } ], - "type": "Marked::Markup", - "raw": "header 3", - "range": [29, 37], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { - "line": 5, - "column": 12 + "column": 12, + "line": 5 + }, + "start": { + "column": 4, + "line": 5 } - } + }, + "range": [29, 37], + "raw": "header 3", + "type": "Marked::Markup" } ], - "type": "Header", - "raw": "=== header 3", - "range": [25, 37], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 5, - "column": 12 + "column": 12, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 } - } + }, + "range": [25, 37], + "raw": "=== header 3", + "type": "Header" } ], - "type": "Document", - "raw": "= header 1\n\n== header 2\n\n=== header 3", - "range": [0, 37], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 5, - "column": 12 + "column": 12, + "line": 5 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 37], + "raw": "= header 1\n\n== header 2\n\n=== header 3", + "type": "Document" } diff --git a/test/unit/fixtures/Link/output.json b/test/unit/fixtures/Link/output.json index 25a06aa..f5b8588 100644 --- a/test/unit/fixtures/Link/output.json +++ b/test/unit/fixtures/Link/output.json @@ -1,69 +1,69 @@ { "children": [ { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, - "range": [0, 19], - "raw": "https://example.com", - "type": "Paragraph", "children": [ { - "type": "Link", - "raw": "https://example.com", - "range": [0, 19], - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 19 - } - }, - "title": null, - "url": "https://example.com", "children": [ { - "type": "Str", - "value": "https://example.com", "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 19 + "column": 19, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } }, "range": [0, 19], - "raw": "https://example.com" + "raw": "https://example.com", + "type": "Str", + "value": "https://example.com" + } + ], + "loc": { + "end": { + "column": 19, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - ] + }, + "range": [0, 19], + "raw": "https://example.com", + "title": null, + "type": "Link", + "url": "https://example.com" } - ] + ], + "loc": { + "end": { + "column": 19, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 19], + "raw": "https://example.com", + "type": "Paragraph" } ], - "type": "Document", - "raw": "https://example.com", - "range": [0, 19], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 19 + "column": 19, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 19], + "raw": "https://example.com", + "type": "Document" } diff --git a/test/unit/fixtures/List/input.typ b/test/unit/fixtures/List/input.typ new file mode 100644 index 0000000..8c169c7 --- /dev/null +++ b/test/unit/fixtures/List/input.typ @@ -0,0 +1,7 @@ +- a +- b +- c + +1. x +2. y +3. z diff --git a/test/unit/fixtures/List/output.json b/test/unit/fixtures/List/output.json new file mode 100644 index 0000000..4902219 --- /dev/null +++ b/test/unit/fixtures/List/output.json @@ -0,0 +1,385 @@ +{ + "children": [ + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 + } + }, + "range": [2, 3], + "raw": "a", + "type": "Str", + "value": "a" + } + ], + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 + } + }, + "range": [2, 3], + "raw": "a", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 3], + "raw": "- a", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 2, + "line": 2 + } + }, + "range": [6, 7], + "raw": "b", + "type": "Str", + "value": "b" + } + ], + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 2, + "line": 2 + } + }, + "range": [6, 7], + "raw": "b", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 + } + }, + "range": [4, 7], + "raw": "- b", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 3 + }, + "start": { + "column": 2, + "line": 3 + } + }, + "range": [10, 11], + "raw": "c", + "type": "Str", + "value": "c" + } + ], + "loc": { + "end": { + "column": 3, + "line": 3 + }, + "start": { + "column": 2, + "line": 3 + } + }, + "range": [10, 11], + "raw": "c", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 + } + }, + "range": [8, 11], + "raw": "- c", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 3, + "line": 3 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "ordered": false, + "range": [0, 11], + "raw": "- a\n- b\n- c", + "spread": false, + "start": null, + "type": "List" + }, + { + "loc": { + "end": { + "column": 0, + "line": 5 + }, + "start": { + "column": 3, + "line": 3 + } + }, + "range": [11, 13], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 4, + "line": 5 + }, + "start": { + "column": 3, + "line": 5 + } + }, + "range": [16, 17], + "raw": "x", + "type": "Str", + "value": "x" + } + ], + "loc": { + "end": { + "column": 4, + "line": 5 + }, + "start": { + "column": 3, + "line": 5 + } + }, + "range": [16, 17], + "raw": "x", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 4, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 + } + }, + "range": [13, 17], + "raw": "1. x", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 4, + "line": 6 + }, + "start": { + "column": 3, + "line": 6 + } + }, + "range": [21, 22], + "raw": "y", + "type": "Str", + "value": "y" + } + ], + "loc": { + "end": { + "column": 4, + "line": 6 + }, + "start": { + "column": 3, + "line": 6 + } + }, + "range": [21, 22], + "raw": "y", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 4, + "line": 6 + }, + "start": { + "column": 0, + "line": 6 + } + }, + "range": [18, 22], + "raw": "2. y", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 4, + "line": 7 + }, + "start": { + "column": 3, + "line": 7 + } + }, + "range": [26, 27], + "raw": "z", + "type": "Str", + "value": "z" + } + ], + "loc": { + "end": { + "column": 4, + "line": 7 + }, + "start": { + "column": 3, + "line": 7 + } + }, + "range": [26, 27], + "raw": "z", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 4, + "line": 7 + }, + "start": { + "column": 0, + "line": 7 + } + }, + "range": [23, 27], + "raw": "3. z", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 4, + "line": 7 + }, + "start": { + "column": 0, + "line": 5 + } + }, + "ordered": true, + "range": [13, 27], + "raw": "1. x\n2. y\n3. z", + "spread": false, + "start": 1, + "type": "List" + } + ], + "loc": { + "end": { + "column": 4, + "line": 7 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 27], + "raw": "- a\n- b\n- c\n\n1. x\n2. y\n3. z", + "type": "Document" +} diff --git a/test/unit/fixtures/Strong/output.json b/test/unit/fixtures/Strong/output.json index 0dad9e4..c01a65c 100644 --- a/test/unit/fixtures/Strong/output.json +++ b/test/unit/fixtures/Strong/output.json @@ -1,359 +1,359 @@ { "children": [ { - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 8 - } - }, - "range": [0, 8], - "raw": "*strong*", - "type": "Paragraph", "children": [ { "children": [ { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [0, 1], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 1 + "column": 1, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 1], + "raw": "*", + "type": "Marked::Star", + "value": "*" }, { - "type": "Str", - "raw": "strong", - "range": [1, 7], "loc": { - "start": { - "line": 1, - "column": 1 - }, "end": { - "line": 1, - "column": 7 + "column": 7, + "line": 1 + }, + "start": { + "column": 1, + "line": 1 } }, + "range": [1, 7], + "raw": "strong", + "type": "Str", "value": "strong" }, { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [7, 8], "loc": { - "start": { - "line": 1, - "column": 7 - }, "end": { - "line": 1, - "column": 8 + "column": 8, + "line": 1 + }, + "start": { + "column": 7, + "line": 1 } - } + }, + "range": [7, 8], + "raw": "*", + "type": "Marked::Star", + "value": "*" } ], - "type": "Strong", - "raw": "*strong*", - "range": [0, 8], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 8 + "column": 8, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 8], + "raw": "*strong*", + "type": "Strong" } - ] - }, - { - "value": "\n\n", - "type": "Break", - "raw": "\n\n", - "range": [8, 10], + ], "loc": { - "start": { - "line": 1, - "column": 8 - }, "end": { - "line": 3, - "column": 0 + "column": 8, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 8], + "raw": "*strong*", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 4, - "column": 0 + "column": 0, + "line": 3 + }, + "start": { + "column": 8, + "line": 1 } }, - "range": [10, 20], - "raw": "* a b c *\n", - "type": "Paragraph", + "range": [8, 10], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { "children": [ { "children": [ { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [10, 11], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 1 + "column": 1, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [10, 11], + "raw": "*", + "type": "Marked::Star", + "value": "*" }, { - "type": "Str", - "raw": " a b c ", - "range": [11, 18], "loc": { - "start": { - "line": 3, - "column": 1 - }, "end": { - "line": 3, - "column": 8 + "column": 8, + "line": 3 + }, + "start": { + "column": 1, + "line": 3 } }, + "range": [11, 18], + "raw": " a b c ", + "type": "Str", "value": "a b c" }, { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [18, 19], "loc": { - "start": { - "line": 3, - "column": 8 - }, "end": { - "line": 3, - "column": 9 + "column": 9, + "line": 3 + }, + "start": { + "column": 8, + "line": 3 } - } + }, + "range": [18, 19], + "raw": "*", + "type": "Marked::Star", + "value": "*" } ], - "type": "Strong", - "raw": "* a b c *", - "range": [10, 19], "loc": { - "start": { - "line": 3, - "column": 0 - }, "end": { - "line": 3, - "column": 9 + "column": 9, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [10, 19], + "raw": "* a b c *", + "type": "Strong" }, { - "type": "Str", - "raw": "\n", - "value": "\n", - "range": [19, 20], "loc": { - "start": { - "line": 3, - "column": 9 - }, "end": { - "line": 4, - "column": 0 + "column": 0, + "line": 4 + }, + "start": { + "column": 9, + "line": 3 } - } + }, + "range": [19, 20], + "raw": "\n", + "type": "Str", + "value": "\n" } - ] - }, - { - "value": "\\", - "type": "Break", - "raw": "\\", - "range": [20, 21], + ], "loc": { - "start": { - "line": 4, - "column": 0 - }, "end": { - "line": 4, - "column": 1 + "column": 0, + "line": 4 + }, + "start": { + "column": 0, + "line": 3 } - } + }, + "range": [10, 20], + "raw": "* a b c *\n", + "type": "Paragraph" }, { "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 5, - "column": 17 + "column": 1, + "line": 4 + }, + "start": { + "column": 0, + "line": 4 } }, - "range": [21, 38], - "raw": "This is *strong*.", - "type": "Paragraph", + "range": [20, 21], + "raw": "\\", + "type": "Break", + "value": "\\" + }, + { "children": [ { - "value": "This is", - "type": "Str", - "raw": "This is", - "range": [21, 28], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { - "line": 5, - "column": 7 + "column": 7, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 } - } + }, + "range": [22, 29], + "raw": "This is", + "type": "Str", + "value": "This is" }, { - "type": "Str", - "raw": " ", - "value": " ", - "range": [28, 29], "loc": { - "start": { - "line": 5, - "column": 7 - }, "end": { - "line": 5, - "column": 8 + "column": 8, + "line": 5 + }, + "start": { + "column": 7, + "line": 5 } - } + }, + "range": [29, 30], + "raw": " ", + "type": "Str", + "value": " " }, { "children": [ { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [29, 30], "loc": { - "start": { - "line": 5, - "column": 8 - }, "end": { - "line": 5, - "column": 9 + "column": 9, + "line": 5 + }, + "start": { + "column": 8, + "line": 5 } - } + }, + "range": [30, 31], + "raw": "*", + "type": "Marked::Star", + "value": "*" }, { - "type": "Str", - "raw": "strong", - "range": [30, 36], "loc": { - "start": { - "line": 5, - "column": 9 - }, "end": { - "line": 5, - "column": 15 + "column": 15, + "line": 5 + }, + "start": { + "column": 9, + "line": 5 } }, + "range": [31, 37], + "raw": "strong", + "type": "Str", "value": "strong" }, { - "value": "*", - "type": "Marked::Star", - "raw": "*", - "range": [36, 37], "loc": { - "start": { - "line": 5, - "column": 15 - }, "end": { - "line": 5, - "column": 16 + "column": 16, + "line": 5 + }, + "start": { + "column": 15, + "line": 5 } - } + }, + "range": [37, 38], + "raw": "*", + "type": "Marked::Star", + "value": "*" } ], - "type": "Strong", - "raw": "*strong*", - "range": [29, 37], "loc": { - "start": { - "line": 5, - "column": 8 - }, "end": { - "line": 5, - "column": 16 + "column": 16, + "line": 5 + }, + "start": { + "column": 8, + "line": 5 } - } + }, + "range": [30, 38], + "raw": "*strong*", + "type": "Strong" }, { - "value": ".", - "type": "Str", - "raw": ".", - "range": [37, 38], "loc": { - "start": { - "line": 5, - "column": 16 - }, "end": { - "line": 5, - "column": 17 + "column": 17, + "line": 5 + }, + "start": { + "column": 16, + "line": 5 } - } + }, + "range": [38, 39], + "raw": ".", + "type": "Str", + "value": "." + } + ], + "loc": { + "end": { + "column": 17, + "line": 5 + }, + "start": { + "column": 0, + "line": 5 } - ] + }, + "range": [22, 39], + "raw": "This is *strong*.", + "type": "Paragraph" } ], - "type": "Document", - "raw": "*strong*\n\n* a b c *\n\\\nThis is *strong*.", - "range": [0, 39], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 5, - "column": 17 + "column": 17, + "line": 5 + }, + "start": { + "column": 0, + "line": 1 } - } + }, + "range": [0, 39], + "raw": "*strong*\n\n* a b c *\n\\\nThis is *strong*.", + "type": "Document" } diff --git a/test/unit/fixtures/empty-file/output.json b/test/unit/fixtures/empty-file/output.json index 68fb996..3abfd4a 100644 --- a/test/unit/fixtures/empty-file/output.json +++ b/test/unit/fixtures/empty-file/output.json @@ -1,16 +1,16 @@ { "children": [], - "raw": "", - "range": [0, 0], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 0 + "column": 0, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } }, + "range": [0, 0], + "raw": "", "type": "Document" } diff --git a/test/unit/fixtures/list-with-paragraph-between/input.typ b/test/unit/fixtures/list-with-paragraph-between/input.typ new file mode 100644 index 0000000..c27fbb7 --- /dev/null +++ b/test/unit/fixtures/list-with-paragraph-between/input.typ @@ -0,0 +1,7 @@ +- a +- b + +paragraph. + +- c +- d diff --git a/test/unit/fixtures/list-with-paragraph-between/output.json b/test/unit/fixtures/list-with-paragraph-between/output.json new file mode 100644 index 0000000..7f1300e --- /dev/null +++ b/test/unit/fixtures/list-with-paragraph-between/output.json @@ -0,0 +1,330 @@ +{ + "children": [ + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 + } + }, + "range": [2, 3], + "raw": "a", + "type": "Str", + "value": "a" + } + ], + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 + } + }, + "range": [2, 3], + "raw": "a", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 3], + "raw": "- a", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 2, + "line": 2 + } + }, + "range": [6, 7], + "raw": "b", + "type": "Str", + "value": "b" + } + ], + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 2, + "line": 2 + } + }, + "range": [6, 7], + "raw": "b", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 + } + }, + "range": [4, 7], + "raw": "- b", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "ordered": false, + "range": [0, 7], + "raw": "- a\n- b", + "spread": false, + "start": null, + "type": "List" + }, + { + "loc": { + "end": { + "column": 0, + "line": 4 + }, + "start": { + "column": 3, + "line": 2 + } + }, + "range": [7, 9], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { + "children": [ + { + "loc": { + "end": { + "column": 10, + "line": 4 + }, + "start": { + "column": 0, + "line": 4 + } + }, + "range": [9, 19], + "raw": "paragraph.", + "type": "Str", + "value": "paragraph." + } + ], + "loc": { + "end": { + "column": 10, + "line": 4 + }, + "start": { + "column": 0, + "line": 4 + } + }, + "range": [9, 19], + "raw": "paragraph.", + "type": "Paragraph" + }, + { + "loc": { + "end": { + "column": 0, + "line": 6 + }, + "start": { + "column": 10, + "line": 4 + } + }, + "range": [19, 21], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 6 + }, + "start": { + "column": 2, + "line": 6 + } + }, + "range": [23, 24], + "raw": "c", + "type": "Str", + "value": "c" + } + ], + "loc": { + "end": { + "column": 3, + "line": 6 + }, + "start": { + "column": 2, + "line": 6 + } + }, + "range": [23, 24], + "raw": "c", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 6 + }, + "start": { + "column": 0, + "line": 6 + } + }, + "range": [21, 24], + "raw": "- c", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 7 + }, + "start": { + "column": 2, + "line": 7 + } + }, + "range": [27, 28], + "raw": "d", + "type": "Str", + "value": "d" + } + ], + "loc": { + "end": { + "column": 3, + "line": 7 + }, + "start": { + "column": 2, + "line": 7 + } + }, + "range": [27, 28], + "raw": "d", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 7 + }, + "start": { + "column": 0, + "line": 7 + } + }, + "range": [25, 28], + "raw": "- d", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 3, + "line": 7 + }, + "start": { + "column": 0, + "line": 6 + } + }, + "ordered": false, + "range": [21, 28], + "raw": "- c\n- d", + "spread": false, + "start": null, + "type": "List" + } + ], + "loc": { + "end": { + "column": 3, + "line": 7 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 28], + "raw": "- a\n- b\n\nparagraph.\n\n- c\n- d", + "type": "Document" +} diff --git a/test/unit/fixtures/nested-list/input.typ b/test/unit/fixtures/nested-list/input.typ new file mode 100644 index 0000000..9773d7a --- /dev/null +++ b/test/unit/fixtures/nested-list/input.typ @@ -0,0 +1,9 @@ +- a +- b + - ba + - bb + - bba + - bbb + - bbc + - bc +- c diff --git a/test/unit/fixtures/nested-list/output.json b/test/unit/fixtures/nested-list/output.json new file mode 100644 index 0000000..3c8667a --- /dev/null +++ b/test/unit/fixtures/nested-list/output.json @@ -0,0 +1,565 @@ +{ + "children": [ + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 + } + }, + "range": [2, 3], + "raw": "a", + "type": "Str", + "value": "a" + } + ], + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 2, + "line": 1 + } + }, + "range": [2, 3], + "raw": "a", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 3], + "raw": "- a", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 2, + "line": 2 + } + }, + "range": [6, 7], + "raw": "b", + "type": "Str", + "value": "b" + } + ], + "loc": { + "end": { + "column": 3, + "line": 2 + }, + "start": { + "column": 2, + "line": 2 + } + }, + "range": [6, 7], + "raw": "b", + "type": "Paragraph" + }, + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 6, + "line": 3 + }, + "start": { + "column": 4, + "line": 3 + } + }, + "range": [12, 14], + "raw": "ba", + "type": "Str", + "value": "ba" + } + ], + "loc": { + "end": { + "column": 6, + "line": 3 + }, + "start": { + "column": 4, + "line": 3 + } + }, + "range": [12, 14], + "raw": "ba", + "type": "Paragraph" + }, + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 8, + "line": 4 + }, + "start": { + "column": 6, + "line": 4 + } + }, + "range": [21, 23], + "raw": "bb", + "type": "Str", + "value": "bb" + } + ], + "loc": { + "end": { + "column": 8, + "line": 4 + }, + "start": { + "column": 6, + "line": 4 + } + }, + "range": [21, 23], + "raw": "bb", + "type": "Paragraph" + }, + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 11, + "line": 5 + }, + "start": { + "column": 8, + "line": 5 + } + }, + "range": [32, 35], + "raw": "bba", + "type": "Str", + "value": "bba" + } + ], + "loc": { + "end": { + "column": 11, + "line": 5 + }, + "start": { + "column": 8, + "line": 5 + } + }, + "range": [32, 35], + "raw": "bba", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 11, + "line": 5 + }, + "start": { + "column": 6, + "line": 5 + } + }, + "range": [30, 35], + "raw": "- bba", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 11, + "line": 6 + }, + "start": { + "column": 8, + "line": 6 + } + }, + "range": [44, 47], + "raw": "bbb", + "type": "Str", + "value": "bbb" + } + ], + "loc": { + "end": { + "column": 11, + "line": 6 + }, + "start": { + "column": 8, + "line": 6 + } + }, + "range": [44, 47], + "raw": "bbb", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 11, + "line": 6 + }, + "start": { + "column": 6, + "line": 6 + } + }, + "range": [42, 47], + "raw": "- bbb", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 11, + "line": 7 + }, + "start": { + "column": 8, + "line": 7 + } + }, + "range": [56, 59], + "raw": "bbc", + "type": "Str", + "value": "bbc" + } + ], + "loc": { + "end": { + "column": 11, + "line": 7 + }, + "start": { + "column": 8, + "line": 7 + } + }, + "range": [56, 59], + "raw": "bbc", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 11, + "line": 7 + }, + "start": { + "column": 6, + "line": 7 + } + }, + "range": [54, 59], + "raw": "- bbc", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 11, + "line": 7 + }, + "start": { + "column": 6, + "line": 5 + } + }, + "ordered": false, + "range": [30, 59], + "raw": "- bba\n- bbb\n- bbc", + "spread": false, + "start": null, + "type": "List" + } + ], + "loc": { + "end": { + "column": 11, + "line": 7 + }, + "start": { + "column": 4, + "line": 4 + } + }, + "range": [19, 59], + "raw": "- bb\n - bba\n - bbb\n - bbc", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 8, + "line": 8 + }, + "start": { + "column": 6, + "line": 8 + } + }, + "range": [66, 68], + "raw": "bc", + "type": "Str", + "value": "bc" + } + ], + "loc": { + "end": { + "column": 8, + "line": 8 + }, + "start": { + "column": 6, + "line": 8 + } + }, + "range": [66, 68], + "raw": "bc", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 8, + "line": 8 + }, + "start": { + "column": 4, + "line": 8 + } + }, + "range": [64, 68], + "raw": "- bc", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 8, + "line": 8 + }, + "start": { + "column": 4, + "line": 4 + } + }, + "ordered": false, + "range": [19, 68], + "raw": "- bb\n - bba\n - bbb\n - bbc\n- bc", + "spread": false, + "start": null, + "type": "List" + } + ], + "loc": { + "end": { + "column": 8, + "line": 8 + }, + "start": { + "column": 2, + "line": 3 + } + }, + "range": [10, 68], + "raw": "- ba\n - bb\n - bba\n - bbb\n - bbc\n - bc", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 8, + "line": 8 + }, + "start": { + "column": 2, + "line": 3 + } + }, + "ordered": false, + "range": [10, 68], + "raw": "- ba\n - bb\n - bba\n - bbb\n - bbc\n - bc", + "spread": false, + "start": null, + "type": "List" + } + ], + "loc": { + "end": { + "column": 8, + "line": 8 + }, + "start": { + "column": 0, + "line": 2 + } + }, + "range": [4, 68], + "raw": "- b\n - ba\n - bb\n - bba\n - bbb\n - bbc\n - bc", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 2, + "line": 9 + } + }, + "range": [71, 72], + "raw": "c", + "type": "Str", + "value": "c" + } + ], + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 2, + "line": 9 + } + }, + "range": [71, 72], + "raw": "c", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 0, + "line": 9 + } + }, + "range": [69, 72], + "raw": "- c", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "ordered": false, + "range": [0, 72], + "raw": "- a\n- b\n - ba\n - bb\n - bba\n - bbb\n - bbc\n - bc\n- c", + "spread": false, + "start": null, + "type": "List" + } + ], + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 72], + "raw": "- a\n- b\n - ba\n - bb\n - bba\n - bbb\n - bbc\n - bc\n- c", + "type": "Document" +} diff --git a/test/unit/fixtures/paragraph-with-list-between/input.typ b/test/unit/fixtures/paragraph-with-list-between/input.typ new file mode 100644 index 0000000..35f9e9e --- /dev/null +++ b/test/unit/fixtures/paragraph-with-list-between/input.typ @@ -0,0 +1,11 @@ +paragraph1. + +- a +- b + +paragraph2. + +- c +- d + +paragraph3. diff --git a/test/unit/fixtures/paragraph-with-list-between/output.json b/test/unit/fixtures/paragraph-with-list-between/output.json new file mode 100644 index 0000000..f3579c2 --- /dev/null +++ b/test/unit/fixtures/paragraph-with-list-between/output.json @@ -0,0 +1,428 @@ +{ + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 11, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 11], + "raw": "paragraph1.", + "type": "Str", + "value": "paragraph1." + } + ], + "loc": { + "end": { + "column": 11, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 11], + "raw": "paragraph1.", + "type": "Paragraph" + }, + { + "loc": { + "end": { + "column": 0, + "line": 3 + }, + "start": { + "column": 11, + "line": 1 + } + }, + "range": [11, 13], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 3 + }, + "start": { + "column": 2, + "line": 3 + } + }, + "range": [15, 16], + "raw": "a", + "type": "Str", + "value": "a" + } + ], + "loc": { + "end": { + "column": 3, + "line": 3 + }, + "start": { + "column": 2, + "line": 3 + } + }, + "range": [15, 16], + "raw": "a", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 3 + }, + "start": { + "column": 0, + "line": 3 + } + }, + "range": [13, 16], + "raw": "- a", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 4 + }, + "start": { + "column": 2, + "line": 4 + } + }, + "range": [19, 20], + "raw": "b", + "type": "Str", + "value": "b" + } + ], + "loc": { + "end": { + "column": 3, + "line": 4 + }, + "start": { + "column": 2, + "line": 4 + } + }, + "range": [19, 20], + "raw": "b", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 4 + }, + "start": { + "column": 0, + "line": 4 + } + }, + "range": [17, 20], + "raw": "- b", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 3, + "line": 4 + }, + "start": { + "column": 0, + "line": 3 + } + }, + "ordered": false, + "range": [13, 20], + "raw": "- a\n- b", + "spread": false, + "start": null, + "type": "List" + }, + { + "loc": { + "end": { + "column": 0, + "line": 6 + }, + "start": { + "column": 3, + "line": 4 + } + }, + "range": [20, 22], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { + "children": [ + { + "loc": { + "end": { + "column": 11, + "line": 6 + }, + "start": { + "column": 0, + "line": 6 + } + }, + "range": [22, 33], + "raw": "paragraph2.", + "type": "Str", + "value": "paragraph2." + } + ], + "loc": { + "end": { + "column": 11, + "line": 6 + }, + "start": { + "column": 0, + "line": 6 + } + }, + "range": [22, 33], + "raw": "paragraph2.", + "type": "Paragraph" + }, + { + "loc": { + "end": { + "column": 0, + "line": 8 + }, + "start": { + "column": 11, + "line": 6 + } + }, + "range": [33, 35], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { + "children": [ + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 8 + }, + "start": { + "column": 2, + "line": 8 + } + }, + "range": [37, 38], + "raw": "c", + "type": "Str", + "value": "c" + } + ], + "loc": { + "end": { + "column": 3, + "line": 8 + }, + "start": { + "column": 2, + "line": 8 + } + }, + "range": [37, 38], + "raw": "c", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 8 + }, + "start": { + "column": 0, + "line": 8 + } + }, + "range": [35, 38], + "raw": "- c", + "spread": false, + "type": "ListItem" + }, + { + "checked": null, + "children": [ + { + "children": [ + { + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 2, + "line": 9 + } + }, + "range": [41, 42], + "raw": "d", + "type": "Str", + "value": "d" + } + ], + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 2, + "line": 9 + } + }, + "range": [41, 42], + "raw": "d", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 0, + "line": 9 + } + }, + "range": [39, 42], + "raw": "- d", + "spread": false, + "type": "ListItem" + } + ], + "loc": { + "end": { + "column": 3, + "line": 9 + }, + "start": { + "column": 0, + "line": 8 + } + }, + "ordered": false, + "range": [35, 42], + "raw": "- c\n- d", + "spread": false, + "start": null, + "type": "List" + }, + { + "loc": { + "end": { + "column": 0, + "line": 11 + }, + "start": { + "column": 3, + "line": 9 + } + }, + "range": [42, 44], + "raw": "\n\n", + "type": "Break", + "value": "\n\n" + }, + { + "children": [ + { + "loc": { + "end": { + "column": 11, + "line": 11 + }, + "start": { + "column": 0, + "line": 11 + } + }, + "range": [44, 55], + "raw": "paragraph3.", + "type": "Str", + "value": "paragraph3." + } + ], + "loc": { + "end": { + "column": 11, + "line": 11 + }, + "start": { + "column": 0, + "line": 11 + } + }, + "range": [44, 55], + "raw": "paragraph3.", + "type": "Paragraph" + } + ], + "loc": { + "end": { + "column": 11, + "line": 11 + }, + "start": { + "column": 0, + "line": 1 + } + }, + "range": [0, 55], + "raw": "paragraph1.\n\n- a\n- b\n\nparagraph2.\n\n- c\n- d\n\nparagraph3.", + "type": "Document" +} diff --git a/test/unit/fixtures/start-with-single-newline/output.json b/test/unit/fixtures/start-with-single-newline/output.json index 262ce66..3014b2a 100644 --- a/test/unit/fixtures/start-with-single-newline/output.json +++ b/test/unit/fixtures/start-with-single-newline/output.json @@ -1,66 +1,66 @@ { "children": [ { - "value": "\n", - "raw": "\n", - "range": [0, 1], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 2, - "column": 0 + "column": 0, + "line": 2 + }, + "start": { + "column": 0, + "line": 1 } }, - "type": "Break" + "range": [0, 1], + "raw": "\n", + "type": "Break", + "value": "\n" }, { - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 2, - "column": 47 - } - }, - "range": [1, 48], - "raw": "This is test that starts with a single newline.", - "type": "Paragraph", "children": [ { - "value": "This is test that starts with a single newline.", - "raw": "This is test that starts with a single newline.", - "range": [1, 48], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { - "line": 2, - "column": 47 + "column": 47, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 } }, - "type": "Str" + "range": [1, 48], + "raw": "This is test that starts with a single newline.", + "type": "Str", + "value": "This is test that starts with a single newline." + } + ], + "loc": { + "end": { + "column": 47, + "line": 2 + }, + "start": { + "column": 0, + "line": 2 } - ] + }, + "range": [1, 48], + "raw": "This is test that starts with a single newline.", + "type": "Paragraph" } ], - "raw": "\nThis is test that starts with a single newline.", - "range": [0, 48], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 2, - "column": 47 + "column": 47, + "line": 2 + }, + "start": { + "column": 0, + "line": 1 } }, + "range": [0, 48], + "raw": "\nThis is test that starts with a single newline.", "type": "Document" } diff --git a/test/unit/paragraphizedTextlintAstObject.json b/test/unit/paragraphizedTextlintAstObject.json index ca36750..536525d 100644 --- a/test/unit/paragraphizedTextlintAstObject.json +++ b/test/unit/paragraphizedTextlintAstObject.json @@ -2085,7 +2085,7 @@ { "value": "phi", "raw": "phi", - "range": [269, 272], + "range": [271, 274], "loc": { "start": { "line": 10, @@ -2101,7 +2101,7 @@ { "value": ".", "raw": ".", - "range": [272, 273], + "range": [274, 275], "loc": { "start": { "line": 10, @@ -2117,7 +2117,7 @@ { "value": "alt", "raw": "alt", - "range": [273, 276], + "range": [275, 278], "loc": { "start": { "line": 10, @@ -2132,7 +2132,7 @@ } ], "raw": "phi.alt", - "range": [269, 276], + "range": [271, 278], "loc": { "start": { "line": 10, @@ -2149,7 +2149,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [276, 277], + "range": [278, 279], "loc": { "start": { "line": 10, @@ -2164,7 +2164,7 @@ { "value": "=", "raw": "=", - "range": [277, 278], + "range": [279, 280], "loc": { "start": { "line": 10, @@ -2181,7 +2181,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [278, 279], + "range": [280, 281], "loc": { "start": { "line": 10, @@ -2200,7 +2200,7 @@ { "value": "(", "raw": "(", - "range": [279, 280], + "range": [281, 282], "loc": { "start": { "line": 10, @@ -2218,7 +2218,7 @@ { "value": "1", "raw": "1", - "range": [280, 281], + "range": [282, 283], "loc": { "start": { "line": 10, @@ -2235,7 +2235,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [281, 282], + "range": [283, 284], "loc": { "start": { "line": 10, @@ -2250,7 +2250,7 @@ { "value": "+", "raw": "+", - "range": [282, 283], + "range": [284, 285], "loc": { "start": { "line": 10, @@ -2267,7 +2267,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [283, 284], + "range": [285, 286], "loc": { "start": { "line": 10, @@ -2284,7 +2284,7 @@ { "value": "sqrt", "raw": "sqrt", - "range": [284, 288], + "range": [286, 290], "loc": { "start": { "line": 10, @@ -2302,7 +2302,7 @@ { "value": "(", "raw": "(", - "range": [288, 289], + "range": [290, 291], "loc": { "start": { "line": 10, @@ -2318,7 +2318,7 @@ { "value": "5", "raw": "5", - "range": [289, 290], + "range": [291, 292], "loc": { "start": { "line": 10, @@ -2334,7 +2334,7 @@ { "value": ")", "raw": ")", - "range": [290, 291], + "range": [292, 293], "loc": { "start": { "line": 10, @@ -2349,7 +2349,7 @@ } ], "raw": "(5)", - "range": [288, 291], + "range": [290, 293], "loc": { "start": { "line": 10, @@ -2364,7 +2364,7 @@ } ], "raw": "sqrt(5)", - "range": [284, 291], + "range": [286, 293], "loc": { "start": { "line": 10, @@ -2379,7 +2379,7 @@ } ], "raw": "1 + sqrt(5)", - "range": [280, 291], + "range": [282, 293], "loc": { "start": { "line": 10, @@ -2395,7 +2395,7 @@ { "value": ")", "raw": ")", - "range": [291, 292], + "range": [293, 294], "loc": { "start": { "line": 10, @@ -2410,7 +2410,7 @@ } ], "raw": "(1 + sqrt(5))", - "range": [279, 292], + "range": [281, 294], "loc": { "start": { "line": 10, @@ -2427,7 +2427,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [292, 293], + "range": [294, 295], "loc": { "start": { "line": 10, @@ -2442,7 +2442,7 @@ { "value": "/", "raw": "/", - "range": [293, 294], + "range": [295, 296], "loc": { "start": { "line": 10, @@ -2459,7 +2459,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [294, 295], + "range": [296, 297], "loc": { "start": { "line": 10, @@ -2474,7 +2474,7 @@ { "value": "2", "raw": "2", - "range": [295, 296], + "range": [297, 298], "loc": { "start": { "line": 10, @@ -2489,7 +2489,7 @@ } ], "raw": "(1 + sqrt(5)) / 2", - "range": [279, 296], + "range": [281, 298], "loc": { "start": { "line": 10, @@ -3335,7 +3335,7 @@ { "value": "if", "raw": "if", - "range": [365, 367], + "range": [367, 369], "loc": { "start": { "line": 15, @@ -3352,7 +3352,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [367, 368], + "range": [369, 370], "loc": { "start": { "line": 15, @@ -3369,7 +3369,7 @@ { "value": "n", "raw": "n", - "range": [368, 369], + "range": [370, 371], "loc": { "start": { "line": 15, @@ -3386,7 +3386,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [369, 370], + "range": [371, 372], "loc": { "start": { "line": 15, @@ -3401,7 +3401,7 @@ { "value": "<=", "raw": "<=", - "range": [370, 372], + "range": [372, 374], "loc": { "start": { "line": 15, @@ -3418,7 +3418,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [372, 373], + "range": [374, 375], "loc": { "start": { "line": 15, @@ -3433,7 +3433,7 @@ { "value": "2", "raw": "2", - "range": [373, 374], + "range": [375, 376], "loc": { "start": { "line": 15, @@ -3448,7 +3448,7 @@ } ], "raw": "n <= 2", - "range": [368, 374], + "range": [370, 376], "loc": { "start": { "line": 15, @@ -3465,7 +3465,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [374, 375], + "range": [376, 377], "loc": { "start": { "line": 15, @@ -3482,7 +3482,7 @@ { "value": "{", "raw": "{", - "range": [375, 376], + "range": [377, 378], "loc": { "start": { "line": 15, @@ -3499,7 +3499,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [376, 377], + "range": [378, 379], "loc": { "start": { "line": 15, @@ -3516,7 +3516,7 @@ { "value": "1", "raw": "1", - "range": [377, 378], + "range": [379, 380], "loc": { "start": { "line": 15, @@ -3531,7 +3531,7 @@ } ], "raw": "1", - "range": [377, 378], + "range": [379, 380], "loc": { "start": { "line": 15, @@ -3548,7 +3548,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [378, 379], + "range": [380, 381], "loc": { "start": { "line": 15, @@ -3563,7 +3563,7 @@ { "value": "}", "raw": "}", - "range": [379, 380], + "range": [381, 382], "loc": { "start": { "line": 15, @@ -3578,7 +3578,7 @@ } ], "raw": "{ 1 }", - "range": [375, 380], + "range": [377, 382], "loc": { "start": { "line": 15, @@ -3595,7 +3595,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [380, 381], + "range": [382, 383], "loc": { "start": { "line": 15, @@ -3610,7 +3610,7 @@ { "value": "else", "raw": "else", - "range": [381, 385], + "range": [385, 389], "loc": { "start": { "line": 16, @@ -3627,7 +3627,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [385, 386], + "range": [389, 390], "loc": { "start": { "line": 16, @@ -3644,7 +3644,7 @@ { "value": "{", "raw": "{", - "range": [386, 387], + "range": [390, 391], "loc": { "start": { "line": 16, @@ -3661,7 +3661,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [387, 388], + "range": [391, 392], "loc": { "start": { "line": 16, @@ -3682,7 +3682,7 @@ { "value": "fib", "raw": "fib", - "range": [388, 391], + "range": [392, 395], "loc": { "start": { "line": 16, @@ -3700,7 +3700,7 @@ { "value": "(", "raw": "(", - "range": [391, 392], + "range": [395, 396], "loc": { "start": { "line": 16, @@ -3718,7 +3718,7 @@ { "value": "n", "raw": "n", - "range": [392, 393], + "range": [396, 397], "loc": { "start": { "line": 16, @@ -3735,7 +3735,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [393, 394], + "range": [397, 398], "loc": { "start": { "line": 16, @@ -3750,7 +3750,7 @@ { "value": "-", "raw": "-", - "range": [394, 395], + "range": [398, 399], "loc": { "start": { "line": 16, @@ -3767,7 +3767,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [395, 396], + "range": [399, 400], "loc": { "start": { "line": 16, @@ -3782,7 +3782,7 @@ { "value": "1", "raw": "1", - "range": [396, 397], + "range": [400, 401], "loc": { "start": { "line": 16, @@ -3797,7 +3797,7 @@ } ], "raw": "n - 1", - "range": [392, 397], + "range": [396, 401], "loc": { "start": { "line": 16, @@ -3813,7 +3813,7 @@ { "value": ")", "raw": ")", - "range": [397, 398], + "range": [401, 402], "loc": { "start": { "line": 16, @@ -3828,7 +3828,7 @@ } ], "raw": "(n - 1)", - "range": [391, 398], + "range": [395, 402], "loc": { "start": { "line": 16, @@ -3843,7 +3843,7 @@ } ], "raw": "fib(n - 1)", - "range": [388, 398], + "range": [392, 402], "loc": { "start": { "line": 16, @@ -3860,7 +3860,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [398, 399], + "range": [402, 403], "loc": { "start": { "line": 16, @@ -3875,7 +3875,7 @@ { "value": "+", "raw": "+", - "range": [399, 400], + "range": [403, 404], "loc": { "start": { "line": 16, @@ -3892,7 +3892,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [400, 401], + "range": [404, 405], "loc": { "start": { "line": 16, @@ -3909,7 +3909,7 @@ { "value": "fib", "raw": "fib", - "range": [401, 404], + "range": [405, 408], "loc": { "start": { "line": 16, @@ -3927,7 +3927,7 @@ { "value": "(", "raw": "(", - "range": [404, 405], + "range": [408, 409], "loc": { "start": { "line": 16, @@ -3945,7 +3945,7 @@ { "value": "n", "raw": "n", - "range": [405, 406], + "range": [409, 410], "loc": { "start": { "line": 16, @@ -3962,7 +3962,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [406, 407], + "range": [410, 411], "loc": { "start": { "line": 16, @@ -3977,7 +3977,7 @@ { "value": "-", "raw": "-", - "range": [407, 408], + "range": [411, 412], "loc": { "start": { "line": 16, @@ -3994,7 +3994,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [408, 409], + "range": [412, 413], "loc": { "start": { "line": 16, @@ -4009,7 +4009,7 @@ { "value": "2", "raw": "2", - "range": [409, 410], + "range": [413, 414], "loc": { "start": { "line": 16, @@ -4024,7 +4024,7 @@ } ], "raw": "n - 2", - "range": [405, 410], + "range": [409, 414], "loc": { "start": { "line": 16, @@ -4040,7 +4040,7 @@ { "value": ")", "raw": ")", - "range": [410, 411], + "range": [414, 415], "loc": { "start": { "line": 16, @@ -4055,7 +4055,7 @@ } ], "raw": "(n - 2)", - "range": [404, 411], + "range": [408, 415], "loc": { "start": { "line": 16, @@ -4070,7 +4070,7 @@ } ], "raw": "fib(n - 2)", - "range": [401, 411], + "range": [405, 415], "loc": { "start": { "line": 16, @@ -4085,7 +4085,7 @@ } ], "raw": "fib(n - 1) + fib(n - 2)", - "range": [388, 411], + "range": [392, 415], "loc": { "start": { "line": 16, @@ -4100,7 +4100,7 @@ } ], "raw": "fib(n - 1) + fib(n - 2)", - "range": [388, 411], + "range": [392, 415], "loc": { "start": { "line": 16, @@ -4117,7 +4117,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [411, 412], + "range": [415, 416], "loc": { "start": { "line": 16, @@ -4132,7 +4132,7 @@ { "value": "}", "raw": "}", - "range": [412, 413], + "range": [416, 417], "loc": { "start": { "line": 16, @@ -4147,7 +4147,7 @@ } ], "raw": "{ fib(n - 1) + fib(n - 2) }", - "range": [386, 413], + "range": [390, 417], "loc": { "start": { "line": 16, @@ -4162,7 +4162,7 @@ } ], "raw": "if n <= 2 { 1 }\n else { fib(n - 1) + fib(n - 2) }", - "range": [365, 415], + "range": [367, 417], "loc": { "start": { "line": 15, @@ -4179,7 +4179,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [415, 416], + "range": [417, 418], "loc": { "start": { "line": 16, @@ -4194,7 +4194,7 @@ { "value": ")", "raw": ")", - "range": [416, 417], + "range": [418, 419], "loc": { "start": { "line": 17, @@ -4570,7 +4570,7 @@ { "value": "columns", "raw": "columns", - "range": [490, 497], + "range": [492, 499], "loc": { "start": { "line": 22, @@ -4586,7 +4586,7 @@ { "value": ":", "raw": ":", - "range": [497, 498], + "range": [499, 500], "loc": { "start": { "line": 22, @@ -4603,7 +4603,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [498, 499], + "range": [500, 501], "loc": { "start": { "line": 22, @@ -4618,7 +4618,7 @@ { "value": "count", "raw": "count", - "range": [499, 504], + "range": [501, 506], "loc": { "start": { "line": 22, @@ -4633,7 +4633,7 @@ } ], "raw": "columns: count", - "range": [490, 504], + "range": [492, 506], "loc": { "start": { "line": 22, @@ -4649,7 +4649,7 @@ { "value": ",", "raw": ",", - "range": [504, 505], + "range": [506, 507], "loc": { "start": { "line": 22, @@ -4666,7 +4666,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [505, 506], + "range": [507, 508], "loc": { "start": { "line": 22, @@ -4683,7 +4683,7 @@ { "value": "..", "raw": "..", - "range": [506, 508], + "range": [510, 512], "loc": { "start": { "line": 23, @@ -4703,7 +4703,7 @@ { "value": "nums", "raw": "nums", - "range": [508, 512], + "range": [512, 516], "loc": { "start": { "line": 23, @@ -4719,7 +4719,7 @@ { "value": ".", "raw": ".", - "range": [512, 513], + "range": [516, 517], "loc": { "start": { "line": 23, @@ -4735,7 +4735,7 @@ { "value": "map", "raw": "map", - "range": [513, 516], + "range": [517, 520], "loc": { "start": { "line": 23, @@ -4750,7 +4750,7 @@ } ], "raw": "nums.map", - "range": [508, 516], + "range": [512, 520], "loc": { "start": { "line": 23, @@ -4768,7 +4768,7 @@ { "value": "(", "raw": "(", - "range": [516, 517], + "range": [520, 521], "loc": { "start": { "line": 23, @@ -4788,7 +4788,7 @@ { "value": "n", "raw": "n", - "range": [517, 518], + "range": [521, 522], "loc": { "start": { "line": 23, @@ -4803,7 +4803,7 @@ } ], "raw": "n", - "range": [517, 518], + "range": [521, 522], "loc": { "start": { "line": 23, @@ -4820,7 +4820,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [518, 519], + "range": [522, 523], "loc": { "start": { "line": 23, @@ -4835,7 +4835,7 @@ { "value": "=>", "raw": "=>", - "range": [519, 521], + "range": [523, 525], "loc": { "start": { "line": 23, @@ -4852,7 +4852,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [521, 522], + "range": [525, 526], "loc": { "start": { "line": 23, @@ -4869,7 +4869,7 @@ { "value": "$", "raw": "$", - "range": [522, 523], + "range": [526, 527], "loc": { "start": { "line": 23, @@ -4889,7 +4889,7 @@ { "value": "F", "raw": "F", - "range": [523, 524], + "range": [527, 528], "loc": { "start": { "line": 23, @@ -4905,7 +4905,7 @@ { "value": "_", "raw": "_", - "range": [524, 525], + "range": [528, 529], "loc": { "start": { "line": 23, @@ -4921,7 +4921,7 @@ { "value": "#", "raw": "#", - "range": [525, 526], + "range": [529, 530], "loc": { "start": { "line": 23, @@ -4937,7 +4937,7 @@ { "value": "n", "raw": "n", - "range": [526, 527], + "range": [530, 531], "loc": { "start": { "line": 23, @@ -4952,7 +4952,7 @@ } ], "raw": "F_#n", - "range": [523, 527], + "range": [527, 531], "loc": { "start": { "line": 23, @@ -4967,7 +4967,7 @@ } ], "raw": "F_#n", - "range": [523, 527], + "range": [527, 531], "loc": { "start": { "line": 23, @@ -4983,7 +4983,7 @@ { "value": "$", "raw": "$", - "range": [527, 528], + "range": [531, 532], "loc": { "start": { "line": 23, @@ -4998,7 +4998,7 @@ } ], "raw": "$F_#n$", - "range": [522, 528], + "range": [526, 532], "loc": { "start": { "line": 23, @@ -5013,7 +5013,7 @@ } ], "raw": "n => $F_#n$", - "range": [517, 528], + "range": [521, 532], "loc": { "start": { "line": 23, @@ -5029,7 +5029,7 @@ { "value": ")", "raw": ")", - "range": [528, 529], + "range": [532, 533], "loc": { "start": { "line": 23, @@ -5044,7 +5044,7 @@ } ], "raw": "(n => $F_#n$)", - "range": [516, 529], + "range": [520, 533], "loc": { "start": { "line": 23, @@ -5059,7 +5059,7 @@ } ], "raw": "nums.map(n => $F_#n$)", - "range": [508, 529], + "range": [512, 533], "loc": { "start": { "line": 23, @@ -5074,7 +5074,7 @@ } ], "raw": "..nums.map(n => $F_#n$)", - "range": [506, 529], + "range": [510, 533], "loc": { "start": { "line": 23, @@ -5090,7 +5090,7 @@ { "value": ",", "raw": ",", - "range": [529, 530], + "range": [533, 534], "loc": { "start": { "line": 23, @@ -5107,7 +5107,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [530, 531], + "range": [534, 535], "loc": { "start": { "line": 23, @@ -5124,7 +5124,7 @@ { "value": "..", "raw": "..", - "range": [531, 533], + "range": [537, 539], "loc": { "start": { "line": 24, @@ -5144,7 +5144,7 @@ { "value": "nums", "raw": "nums", - "range": [533, 537], + "range": [539, 543], "loc": { "start": { "line": 24, @@ -5160,7 +5160,7 @@ { "value": ".", "raw": ".", - "range": [537, 538], + "range": [543, 544], "loc": { "start": { "line": 24, @@ -5176,7 +5176,7 @@ { "value": "map", "raw": "map", - "range": [538, 541], + "range": [544, 547], "loc": { "start": { "line": 24, @@ -5191,7 +5191,7 @@ } ], "raw": "nums.map", - "range": [533, 541], + "range": [539, 547], "loc": { "start": { "line": 24, @@ -5209,7 +5209,7 @@ { "value": "(", "raw": "(", - "range": [541, 542], + "range": [547, 548], "loc": { "start": { "line": 24, @@ -5229,7 +5229,7 @@ { "value": "n", "raw": "n", - "range": [542, 543], + "range": [548, 549], "loc": { "start": { "line": 24, @@ -5244,7 +5244,7 @@ } ], "raw": "n", - "range": [542, 543], + "range": [548, 549], "loc": { "start": { "line": 24, @@ -5261,7 +5261,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [543, 544], + "range": [549, 550], "loc": { "start": { "line": 24, @@ -5276,7 +5276,7 @@ { "value": "=>", "raw": "=>", - "range": [544, 546], + "range": [550, 552], "loc": { "start": { "line": 24, @@ -5293,7 +5293,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [546, 547], + "range": [552, 553], "loc": { "start": { "line": 24, @@ -5310,7 +5310,7 @@ { "value": "str", "raw": "str", - "range": [547, 550], + "range": [553, 556], "loc": { "start": { "line": 24, @@ -5328,7 +5328,7 @@ { "value": "(", "raw": "(", - "range": [550, 551], + "range": [556, 557], "loc": { "start": { "line": 24, @@ -5346,7 +5346,7 @@ { "value": "fib", "raw": "fib", - "range": [551, 554], + "range": [557, 560], "loc": { "start": { "line": 24, @@ -5364,7 +5364,7 @@ { "value": "(", "raw": "(", - "range": [554, 555], + "range": [560, 561], "loc": { "start": { "line": 24, @@ -5380,7 +5380,7 @@ { "value": "n", "raw": "n", - "range": [555, 556], + "range": [561, 562], "loc": { "start": { "line": 24, @@ -5396,7 +5396,7 @@ { "value": ")", "raw": ")", - "range": [556, 557], + "range": [562, 563], "loc": { "start": { "line": 24, @@ -5411,7 +5411,7 @@ } ], "raw": "(n)", - "range": [554, 557], + "range": [560, 563], "loc": { "start": { "line": 24, @@ -5426,7 +5426,7 @@ } ], "raw": "fib(n)", - "range": [551, 557], + "range": [557, 563], "loc": { "start": { "line": 24, @@ -5442,7 +5442,7 @@ { "value": ")", "raw": ")", - "range": [557, 558], + "range": [563, 564], "loc": { "start": { "line": 24, @@ -5457,7 +5457,7 @@ } ], "raw": "(fib(n))", - "range": [550, 558], + "range": [556, 564], "loc": { "start": { "line": 24, @@ -5472,7 +5472,7 @@ } ], "raw": "str(fib(n))", - "range": [547, 558], + "range": [553, 564], "loc": { "start": { "line": 24, @@ -5487,7 +5487,7 @@ } ], "raw": "n => str(fib(n))", - "range": [542, 558], + "range": [548, 564], "loc": { "start": { "line": 24, @@ -5503,7 +5503,7 @@ { "value": ")", "raw": ")", - "range": [558, 559], + "range": [564, 565], "loc": { "start": { "line": 24, @@ -5518,7 +5518,7 @@ } ], "raw": "(n => str(fib(n)))", - "range": [541, 559], + "range": [547, 565], "loc": { "start": { "line": 24, @@ -5533,7 +5533,7 @@ } ], "raw": "nums.map(n => str(fib(n)))", - "range": [533, 559], + "range": [539, 565], "loc": { "start": { "line": 24, @@ -5548,7 +5548,7 @@ } ], "raw": "..nums.map(n => str(fib(n)))", - "range": [531, 559], + "range": [537, 565], "loc": { "start": { "line": 24, @@ -5564,7 +5564,7 @@ { "value": ",", "raw": ",", - "range": [559, 560], + "range": [565, 566], "loc": { "start": { "line": 24, @@ -5581,7 +5581,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [560, 561], + "range": [566, 567], "loc": { "start": { "line": 24, @@ -5596,7 +5596,7 @@ { "value": ")", "raw": ")", - "range": [561, 562], + "range": [567, 568], "loc": { "start": { "line": 25, diff --git a/test/unit/textlintAstObject.json b/test/unit/textlintAstObject.json index aa4712a..0813a39 100644 --- a/test/unit/textlintAstObject.json +++ b/test/unit/textlintAstObject.json @@ -2053,7 +2053,7 @@ { "value": "phi", "raw": "phi", - "range": [269, 272], + "range": [271, 274], "loc": { "start": { "line": 10, @@ -2069,7 +2069,7 @@ { "value": ".", "raw": ".", - "range": [272, 273], + "range": [274, 275], "loc": { "start": { "line": 10, @@ -2085,7 +2085,7 @@ { "value": "alt", "raw": "alt", - "range": [273, 276], + "range": [275, 278], "loc": { "start": { "line": 10, @@ -2100,7 +2100,7 @@ } ], "raw": "phi.alt", - "range": [269, 276], + "range": [271, 278], "loc": { "start": { "line": 10, @@ -2117,7 +2117,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [276, 277], + "range": [278, 279], "loc": { "start": { "line": 10, @@ -2132,7 +2132,7 @@ { "value": "=", "raw": "=", - "range": [277, 278], + "range": [279, 280], "loc": { "start": { "line": 10, @@ -2149,7 +2149,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [278, 279], + "range": [280, 281], "loc": { "start": { "line": 10, @@ -2168,7 +2168,7 @@ { "value": "(", "raw": "(", - "range": [279, 280], + "range": [281, 282], "loc": { "start": { "line": 10, @@ -2186,7 +2186,7 @@ { "value": "1", "raw": "1", - "range": [280, 281], + "range": [282, 283], "loc": { "start": { "line": 10, @@ -2203,7 +2203,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [281, 282], + "range": [283, 284], "loc": { "start": { "line": 10, @@ -2218,7 +2218,7 @@ { "value": "+", "raw": "+", - "range": [282, 283], + "range": [284, 285], "loc": { "start": { "line": 10, @@ -2235,7 +2235,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [283, 284], + "range": [285, 286], "loc": { "start": { "line": 10, @@ -2252,7 +2252,7 @@ { "value": "sqrt", "raw": "sqrt", - "range": [284, 288], + "range": [286, 290], "loc": { "start": { "line": 10, @@ -2270,7 +2270,7 @@ { "value": "(", "raw": "(", - "range": [288, 289], + "range": [290, 291], "loc": { "start": { "line": 10, @@ -2286,7 +2286,7 @@ { "value": "5", "raw": "5", - "range": [289, 290], + "range": [291, 292], "loc": { "start": { "line": 10, @@ -2302,7 +2302,7 @@ { "value": ")", "raw": ")", - "range": [290, 291], + "range": [292, 293], "loc": { "start": { "line": 10, @@ -2317,7 +2317,7 @@ } ], "raw": "(5)", - "range": [288, 291], + "range": [290, 293], "loc": { "start": { "line": 10, @@ -2332,7 +2332,7 @@ } ], "raw": "sqrt(5)", - "range": [284, 291], + "range": [286, 293], "loc": { "start": { "line": 10, @@ -2347,7 +2347,7 @@ } ], "raw": "1 + sqrt(5)", - "range": [280, 291], + "range": [282, 293], "loc": { "start": { "line": 10, @@ -2363,7 +2363,7 @@ { "value": ")", "raw": ")", - "range": [291, 292], + "range": [293, 294], "loc": { "start": { "line": 10, @@ -2378,7 +2378,7 @@ } ], "raw": "(1 + sqrt(5))", - "range": [279, 292], + "range": [281, 294], "loc": { "start": { "line": 10, @@ -2395,7 +2395,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [292, 293], + "range": [294, 295], "loc": { "start": { "line": 10, @@ -2410,7 +2410,7 @@ { "value": "/", "raw": "/", - "range": [293, 294], + "range": [295, 296], "loc": { "start": { "line": 10, @@ -2427,7 +2427,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [294, 295], + "range": [296, 297], "loc": { "start": { "line": 10, @@ -2442,7 +2442,7 @@ { "value": "2", "raw": "2", - "range": [295, 296], + "range": [297, 298], "loc": { "start": { "line": 10, @@ -2457,7 +2457,7 @@ } ], "raw": "(1 + sqrt(5)) / 2", - "range": [279, 296], + "range": [281, 298], "loc": { "start": { "line": 10, @@ -3301,7 +3301,7 @@ { "value": "if", "raw": "if", - "range": [365, 367], + "range": [367, 369], "loc": { "start": { "line": 15, @@ -3318,7 +3318,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [367, 368], + "range": [369, 370], "loc": { "start": { "line": 15, @@ -3335,7 +3335,7 @@ { "value": "n", "raw": "n", - "range": [368, 369], + "range": [370, 371], "loc": { "start": { "line": 15, @@ -3352,7 +3352,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [369, 370], + "range": [371, 372], "loc": { "start": { "line": 15, @@ -3367,7 +3367,7 @@ { "value": "<=", "raw": "<=", - "range": [370, 372], + "range": [372, 374], "loc": { "start": { "line": 15, @@ -3384,7 +3384,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [372, 373], + "range": [374, 375], "loc": { "start": { "line": 15, @@ -3399,7 +3399,7 @@ { "value": "2", "raw": "2", - "range": [373, 374], + "range": [375, 376], "loc": { "start": { "line": 15, @@ -3414,7 +3414,7 @@ } ], "raw": "n <= 2", - "range": [368, 374], + "range": [370, 376], "loc": { "start": { "line": 15, @@ -3431,7 +3431,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [374, 375], + "range": [376, 377], "loc": { "start": { "line": 15, @@ -3448,7 +3448,7 @@ { "value": "{", "raw": "{", - "range": [375, 376], + "range": [377, 378], "loc": { "start": { "line": 15, @@ -3465,7 +3465,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [376, 377], + "range": [378, 379], "loc": { "start": { "line": 15, @@ -3482,7 +3482,7 @@ { "value": "1", "raw": "1", - "range": [377, 378], + "range": [379, 380], "loc": { "start": { "line": 15, @@ -3497,7 +3497,7 @@ } ], "raw": "1", - "range": [377, 378], + "range": [379, 380], "loc": { "start": { "line": 15, @@ -3514,7 +3514,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [378, 379], + "range": [380, 381], "loc": { "start": { "line": 15, @@ -3529,7 +3529,7 @@ { "value": "}", "raw": "}", - "range": [379, 380], + "range": [381, 382], "loc": { "start": { "line": 15, @@ -3544,7 +3544,7 @@ } ], "raw": "{ 1 }", - "range": [375, 380], + "range": [377, 382], "loc": { "start": { "line": 15, @@ -3561,7 +3561,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [380, 381], + "range": [382, 383], "loc": { "start": { "line": 15, @@ -3576,7 +3576,7 @@ { "value": "else", "raw": "else", - "range": [381, 385], + "range": [385, 389], "loc": { "start": { "line": 16, @@ -3593,7 +3593,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [385, 386], + "range": [389, 390], "loc": { "start": { "line": 16, @@ -3610,7 +3610,7 @@ { "value": "{", "raw": "{", - "range": [386, 387], + "range": [390, 391], "loc": { "start": { "line": 16, @@ -3627,7 +3627,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [387, 388], + "range": [391, 392], "loc": { "start": { "line": 16, @@ -3648,7 +3648,7 @@ { "value": "fib", "raw": "fib", - "range": [388, 391], + "range": [392, 395], "loc": { "start": { "line": 16, @@ -3666,7 +3666,7 @@ { "value": "(", "raw": "(", - "range": [391, 392], + "range": [395, 396], "loc": { "start": { "line": 16, @@ -3684,7 +3684,7 @@ { "value": "n", "raw": "n", - "range": [392, 393], + "range": [396, 397], "loc": { "start": { "line": 16, @@ -3701,7 +3701,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [393, 394], + "range": [397, 398], "loc": { "start": { "line": 16, @@ -3716,7 +3716,7 @@ { "value": "-", "raw": "-", - "range": [394, 395], + "range": [398, 399], "loc": { "start": { "line": 16, @@ -3733,7 +3733,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [395, 396], + "range": [399, 400], "loc": { "start": { "line": 16, @@ -3748,7 +3748,7 @@ { "value": "1", "raw": "1", - "range": [396, 397], + "range": [400, 401], "loc": { "start": { "line": 16, @@ -3763,7 +3763,7 @@ } ], "raw": "n - 1", - "range": [392, 397], + "range": [396, 401], "loc": { "start": { "line": 16, @@ -3779,7 +3779,7 @@ { "value": ")", "raw": ")", - "range": [397, 398], + "range": [401, 402], "loc": { "start": { "line": 16, @@ -3794,7 +3794,7 @@ } ], "raw": "(n - 1)", - "range": [391, 398], + "range": [395, 402], "loc": { "start": { "line": 16, @@ -3809,7 +3809,7 @@ } ], "raw": "fib(n - 1)", - "range": [388, 398], + "range": [392, 402], "loc": { "start": { "line": 16, @@ -3826,7 +3826,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [398, 399], + "range": [402, 403], "loc": { "start": { "line": 16, @@ -3841,7 +3841,7 @@ { "value": "+", "raw": "+", - "range": [399, 400], + "range": [403, 404], "loc": { "start": { "line": 16, @@ -3858,7 +3858,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [400, 401], + "range": [404, 405], "loc": { "start": { "line": 16, @@ -3875,7 +3875,7 @@ { "value": "fib", "raw": "fib", - "range": [401, 404], + "range": [405, 408], "loc": { "start": { "line": 16, @@ -3893,7 +3893,7 @@ { "value": "(", "raw": "(", - "range": [404, 405], + "range": [408, 409], "loc": { "start": { "line": 16, @@ -3911,7 +3911,7 @@ { "value": "n", "raw": "n", - "range": [405, 406], + "range": [409, 410], "loc": { "start": { "line": 16, @@ -3928,7 +3928,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [406, 407], + "range": [410, 411], "loc": { "start": { "line": 16, @@ -3943,7 +3943,7 @@ { "value": "-", "raw": "-", - "range": [407, 408], + "range": [411, 412], "loc": { "start": { "line": 16, @@ -3960,7 +3960,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [408, 409], + "range": [412, 413], "loc": { "start": { "line": 16, @@ -3975,7 +3975,7 @@ { "value": "2", "raw": "2", - "range": [409, 410], + "range": [413, 414], "loc": { "start": { "line": 16, @@ -3990,7 +3990,7 @@ } ], "raw": "n - 2", - "range": [405, 410], + "range": [409, 414], "loc": { "start": { "line": 16, @@ -4006,7 +4006,7 @@ { "value": ")", "raw": ")", - "range": [410, 411], + "range": [414, 415], "loc": { "start": { "line": 16, @@ -4021,7 +4021,7 @@ } ], "raw": "(n - 2)", - "range": [404, 411], + "range": [408, 415], "loc": { "start": { "line": 16, @@ -4036,7 +4036,7 @@ } ], "raw": "fib(n - 2)", - "range": [401, 411], + "range": [405, 415], "loc": { "start": { "line": 16, @@ -4051,7 +4051,7 @@ } ], "raw": "fib(n - 1) + fib(n - 2)", - "range": [388, 411], + "range": [392, 415], "loc": { "start": { "line": 16, @@ -4066,7 +4066,7 @@ } ], "raw": "fib(n - 1) + fib(n - 2)", - "range": [388, 411], + "range": [392, 415], "loc": { "start": { "line": 16, @@ -4083,7 +4083,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [411, 412], + "range": [415, 416], "loc": { "start": { "line": 16, @@ -4098,7 +4098,7 @@ { "value": "}", "raw": "}", - "range": [412, 413], + "range": [416, 417], "loc": { "start": { "line": 16, @@ -4113,7 +4113,7 @@ } ], "raw": "{ fib(n - 1) + fib(n - 2) }", - "range": [386, 413], + "range": [390, 417], "loc": { "start": { "line": 16, @@ -4128,7 +4128,7 @@ } ], "raw": "if n <= 2 { 1 }\n else { fib(n - 1) + fib(n - 2) }", - "range": [365, 415], + "range": [367, 417], "loc": { "start": { "line": 15, @@ -4145,7 +4145,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [415, 416], + "range": [417, 418], "loc": { "start": { "line": 16, @@ -4160,7 +4160,7 @@ { "value": ")", "raw": ")", - "range": [416, 417], + "range": [418, 419], "loc": { "start": { "line": 17, @@ -4519,7 +4519,7 @@ { "value": "columns", "raw": "columns", - "range": [490, 497], + "range": [492, 499], "loc": { "start": { "line": 22, @@ -4535,7 +4535,7 @@ { "value": ":", "raw": ":", - "range": [497, 498], + "range": [499, 500], "loc": { "start": { "line": 22, @@ -4552,7 +4552,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [498, 499], + "range": [500, 501], "loc": { "start": { "line": 22, @@ -4567,7 +4567,7 @@ { "value": "count", "raw": "count", - "range": [499, 504], + "range": [501, 506], "loc": { "start": { "line": 22, @@ -4582,7 +4582,7 @@ } ], "raw": "columns: count", - "range": [490, 504], + "range": [492, 506], "loc": { "start": { "line": 22, @@ -4598,7 +4598,7 @@ { "value": ",", "raw": ",", - "range": [504, 505], + "range": [506, 507], "loc": { "start": { "line": 22, @@ -4615,7 +4615,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [505, 506], + "range": [507, 508], "loc": { "start": { "line": 22, @@ -4632,7 +4632,7 @@ { "value": "..", "raw": "..", - "range": [506, 508], + "range": [510, 512], "loc": { "start": { "line": 23, @@ -4652,7 +4652,7 @@ { "value": "nums", "raw": "nums", - "range": [508, 512], + "range": [512, 516], "loc": { "start": { "line": 23, @@ -4668,7 +4668,7 @@ { "value": ".", "raw": ".", - "range": [512, 513], + "range": [516, 517], "loc": { "start": { "line": 23, @@ -4684,7 +4684,7 @@ { "value": "map", "raw": "map", - "range": [513, 516], + "range": [517, 520], "loc": { "start": { "line": 23, @@ -4699,7 +4699,7 @@ } ], "raw": "nums.map", - "range": [508, 516], + "range": [512, 520], "loc": { "start": { "line": 23, @@ -4717,7 +4717,7 @@ { "value": "(", "raw": "(", - "range": [516, 517], + "range": [520, 521], "loc": { "start": { "line": 23, @@ -4737,7 +4737,7 @@ { "value": "n", "raw": "n", - "range": [517, 518], + "range": [521, 522], "loc": { "start": { "line": 23, @@ -4752,7 +4752,7 @@ } ], "raw": "n", - "range": [517, 518], + "range": [521, 522], "loc": { "start": { "line": 23, @@ -4769,7 +4769,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [518, 519], + "range": [522, 523], "loc": { "start": { "line": 23, @@ -4784,7 +4784,7 @@ { "value": "=>", "raw": "=>", - "range": [519, 521], + "range": [523, 525], "loc": { "start": { "line": 23, @@ -4801,7 +4801,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [521, 522], + "range": [525, 526], "loc": { "start": { "line": 23, @@ -4818,7 +4818,7 @@ { "value": "$", "raw": "$", - "range": [522, 523], + "range": [526, 527], "loc": { "start": { "line": 23, @@ -4838,7 +4838,7 @@ { "value": "F", "raw": "F", - "range": [523, 524], + "range": [527, 528], "loc": { "start": { "line": 23, @@ -4854,7 +4854,7 @@ { "value": "_", "raw": "_", - "range": [524, 525], + "range": [528, 529], "loc": { "start": { "line": 23, @@ -4870,7 +4870,7 @@ { "value": "#", "raw": "#", - "range": [525, 526], + "range": [529, 530], "loc": { "start": { "line": 23, @@ -4886,7 +4886,7 @@ { "value": "n", "raw": "n", - "range": [526, 527], + "range": [530, 531], "loc": { "start": { "line": 23, @@ -4901,7 +4901,7 @@ } ], "raw": "F_#n", - "range": [523, 527], + "range": [527, 531], "loc": { "start": { "line": 23, @@ -4916,7 +4916,7 @@ } ], "raw": "F_#n", - "range": [523, 527], + "range": [527, 531], "loc": { "start": { "line": 23, @@ -4932,7 +4932,7 @@ { "value": "$", "raw": "$", - "range": [527, 528], + "range": [531, 532], "loc": { "start": { "line": 23, @@ -4947,7 +4947,7 @@ } ], "raw": "$F_#n$", - "range": [522, 528], + "range": [526, 532], "loc": { "start": { "line": 23, @@ -4962,7 +4962,7 @@ } ], "raw": "n => $F_#n$", - "range": [517, 528], + "range": [521, 532], "loc": { "start": { "line": 23, @@ -4978,7 +4978,7 @@ { "value": ")", "raw": ")", - "range": [528, 529], + "range": [532, 533], "loc": { "start": { "line": 23, @@ -4993,7 +4993,7 @@ } ], "raw": "(n => $F_#n$)", - "range": [516, 529], + "range": [520, 533], "loc": { "start": { "line": 23, @@ -5008,7 +5008,7 @@ } ], "raw": "nums.map(n => $F_#n$)", - "range": [508, 529], + "range": [512, 533], "loc": { "start": { "line": 23, @@ -5023,7 +5023,7 @@ } ], "raw": "..nums.map(n => $F_#n$)", - "range": [506, 529], + "range": [510, 533], "loc": { "start": { "line": 23, @@ -5039,7 +5039,7 @@ { "value": ",", "raw": ",", - "range": [529, 530], + "range": [533, 534], "loc": { "start": { "line": 23, @@ -5056,7 +5056,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [530, 531], + "range": [534, 535], "loc": { "start": { "line": 23, @@ -5073,7 +5073,7 @@ { "value": "..", "raw": "..", - "range": [531, 533], + "range": [537, 539], "loc": { "start": { "line": 24, @@ -5093,7 +5093,7 @@ { "value": "nums", "raw": "nums", - "range": [533, 537], + "range": [539, 543], "loc": { "start": { "line": 24, @@ -5109,7 +5109,7 @@ { "value": ".", "raw": ".", - "range": [537, 538], + "range": [543, 544], "loc": { "start": { "line": 24, @@ -5125,7 +5125,7 @@ { "value": "map", "raw": "map", - "range": [538, 541], + "range": [544, 547], "loc": { "start": { "line": 24, @@ -5140,7 +5140,7 @@ } ], "raw": "nums.map", - "range": [533, 541], + "range": [539, 547], "loc": { "start": { "line": 24, @@ -5158,7 +5158,7 @@ { "value": "(", "raw": "(", - "range": [541, 542], + "range": [547, 548], "loc": { "start": { "line": 24, @@ -5178,7 +5178,7 @@ { "value": "n", "raw": "n", - "range": [542, 543], + "range": [548, 549], "loc": { "start": { "line": 24, @@ -5193,7 +5193,7 @@ } ], "raw": "n", - "range": [542, 543], + "range": [548, 549], "loc": { "start": { "line": 24, @@ -5210,7 +5210,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [543, 544], + "range": [549, 550], "loc": { "start": { "line": 24, @@ -5225,7 +5225,7 @@ { "value": "=>", "raw": "=>", - "range": [544, 546], + "range": [550, 552], "loc": { "start": { "line": 24, @@ -5242,7 +5242,7 @@ "type": "Str", "raw": " ", "value": " ", - "range": [546, 547], + "range": [552, 553], "loc": { "start": { "line": 24, @@ -5259,7 +5259,7 @@ { "value": "str", "raw": "str", - "range": [547, 550], + "range": [553, 556], "loc": { "start": { "line": 24, @@ -5277,7 +5277,7 @@ { "value": "(", "raw": "(", - "range": [550, 551], + "range": [556, 557], "loc": { "start": { "line": 24, @@ -5295,7 +5295,7 @@ { "value": "fib", "raw": "fib", - "range": [551, 554], + "range": [557, 560], "loc": { "start": { "line": 24, @@ -5313,7 +5313,7 @@ { "value": "(", "raw": "(", - "range": [554, 555], + "range": [560, 561], "loc": { "start": { "line": 24, @@ -5329,7 +5329,7 @@ { "value": "n", "raw": "n", - "range": [555, 556], + "range": [561, 562], "loc": { "start": { "line": 24, @@ -5345,7 +5345,7 @@ { "value": ")", "raw": ")", - "range": [556, 557], + "range": [562, 563], "loc": { "start": { "line": 24, @@ -5360,7 +5360,7 @@ } ], "raw": "(n)", - "range": [554, 557], + "range": [560, 563], "loc": { "start": { "line": 24, @@ -5375,7 +5375,7 @@ } ], "raw": "fib(n)", - "range": [551, 557], + "range": [557, 563], "loc": { "start": { "line": 24, @@ -5391,7 +5391,7 @@ { "value": ")", "raw": ")", - "range": [557, 558], + "range": [563, 564], "loc": { "start": { "line": 24, @@ -5406,7 +5406,7 @@ } ], "raw": "(fib(n))", - "range": [550, 558], + "range": [556, 564], "loc": { "start": { "line": 24, @@ -5421,7 +5421,7 @@ } ], "raw": "str(fib(n))", - "range": [547, 558], + "range": [553, 564], "loc": { "start": { "line": 24, @@ -5436,7 +5436,7 @@ } ], "raw": "n => str(fib(n))", - "range": [542, 558], + "range": [548, 564], "loc": { "start": { "line": 24, @@ -5452,7 +5452,7 @@ { "value": ")", "raw": ")", - "range": [558, 559], + "range": [564, 565], "loc": { "start": { "line": 24, @@ -5467,7 +5467,7 @@ } ], "raw": "(n => str(fib(n)))", - "range": [541, 559], + "range": [547, 565], "loc": { "start": { "line": 24, @@ -5482,7 +5482,7 @@ } ], "raw": "nums.map(n => str(fib(n)))", - "range": [533, 559], + "range": [539, 565], "loc": { "start": { "line": 24, @@ -5497,7 +5497,7 @@ } ], "raw": "..nums.map(n => str(fib(n)))", - "range": [531, 559], + "range": [537, 565], "loc": { "start": { "line": 24, @@ -5513,7 +5513,7 @@ { "value": ",", "raw": ",", - "range": [559, 560], + "range": [565, 566], "loc": { "start": { "line": 24, @@ -5530,7 +5530,7 @@ "type": "Str", "raw": "\n", "value": "\n", - "range": [560, 561], + "range": [566, 567], "loc": { "start": { "line": 24, @@ -5545,7 +5545,7 @@ { "value": ")", "raw": ")", - "range": [561, 562], + "range": [567, 568], "loc": { "start": { "line": 25, diff --git a/test/unit/update-fixtures.ts b/test/unit/update-fixtures.ts index acdedad..c606feb 100644 --- a/test/unit/update-fixtures.ts +++ b/test/unit/update-fixtures.ts @@ -3,6 +3,31 @@ import path from "node:path"; import { test } from "@textlint/ast-tester"; import { convertTypstSourceToTextlintAstObject } from "../../src/typstToTextlintAst"; +/** + * Sort JSON object keys recursively for consistent output + * @param obj The object to sort + * @returns The object with sorted keys + */ + +// biome-ignore lint/suspicious/noExplicitAny: JSON structure is not known. +const sortJsonKeys = (obj: any): any => { + if (obj === null || typeof obj !== "object") { + return obj; + } + + if (Array.isArray(obj)) { + return obj.map(sortJsonKeys); + } + + // biome-ignore lint/suspicious/noExplicitAny: JSON structure is not known. + const sorted: any = {}; + for (const key of Object.keys(obj).sort()) { + sorted[key] = sortJsonKeys(obj[key]); + } + + return sorted; +}; + const fixtureDir = path.join(__dirname, "fixtures"); for (const filePath of fs.readdirSync(fixtureDir)) { const dirName = path.basename(filePath); @@ -10,7 +35,7 @@ for (const filePath of fs.readdirSync(fixtureDir)) { path.join(fixtureDir, filePath, "input.typ"), "utf-8", ); - const AST = await convertTypstSourceToTextlintAstObject(input); + const AST = sortJsonKeys(await convertTypstSourceToTextlintAstObject(input)); test(AST); fs.writeFileSync( path.join(fixtureDir, filePath, "output.json"),