From e17e45f9d51a19e858062791bd5f59c536e797f5 Mon Sep 17 00:00:00 2001 From: jonghyo Date: Fri, 8 Aug 2025 16:30:42 +0900 Subject: [PATCH] chore: fix comment bugs --- package-lock.json | 4 ++-- src/asciidoc-to-ast.ts | 19 ++++++++++--------- test/__snapshots__/snapshots.test.ts.snap | 10 +++++----- test/asciidoc-to-ast.test.ts | 1 - tsconfig.json | 10 ++++++++-- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb8af38..e402d29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@jonghyo/textlint-plugin-asciidoc", - "version": "0.1.0", + "version": "0.1.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@jonghyo/textlint-plugin-asciidoc", - "version": "0.1.0", + "version": "0.1.2", "license": "MIT", "dependencies": { "@asciidoctor/core": "^2.2.8", diff --git a/src/asciidoc-to-ast.ts b/src/asciidoc-to-ast.ts index 8bd7927..6f36f54 100644 --- a/src/asciidoc-to-ast.ts +++ b/src/asciidoc-to-ast.ts @@ -628,7 +628,7 @@ export class Converter { findLocation( lines: string[], cursor: LineCursor, - type: string + _type: string ): TxtNodeLocation | null { if (lines.length === 0) { return null; @@ -647,14 +647,15 @@ export class Converter { found = false; break; } - while (type !== ASTNodeTypes.CodeBlock && line && line.match(/^\/\//)) { - offset++; - line = this.lines[i + j - 1 + offset]; - if (line === undefined) { - found = false; - break; - } - } + // Calicurate the offset for the line number + // while (type !== ASTNodeTypes.CodeBlock && line && line.match(/^\/\//)) { + // offset++; + // line = this.lines[i + j - 1 + offset]; + // if (line === undefined) { + // found = false; + // break; + // } + // } if ( !found || !line || diff --git a/test/__snapshots__/snapshots.test.ts.snap b/test/__snapshots__/snapshots.test.ts.snap index 81e1dea..b390c35 100644 --- a/test/__snapshots__/snapshots.test.ts.snap +++ b/test/__snapshots__/snapshots.test.ts.snap @@ -117,11 +117,11 @@ Object { }, "start": Object { "column": 0, - "line": 1, + "line": 2, }, }, "range": Array [ - 0, + 70, 87, ], "raw": "The Article Title", @@ -137,11 +137,11 @@ Object { }, "start": Object { "column": 0, - "line": 1, + "line": 2, }, }, "range": Array [ - 0, + 70, 87, ], "raw": "The Article Title", @@ -2067,7 +2067,7 @@ of AsciiDoc labeled lists.", }, "start": Object { "column": 0, - "line": 1, + "line": 2, }, }, "range": Array [ diff --git a/test/asciidoc-to-ast.test.ts b/test/asciidoc-to-ast.test.ts index 92c3c8c..ccb3fce 100644 --- a/test/asciidoc-to-ast.test.ts +++ b/test/asciidoc-to-ast.test.ts @@ -754,7 +754,6 @@ D `); testAST(node as any); expect((node as any).children).toEqual([ - oc({ type: "Paragraph", children: [oc({ type: "Str", value: "A B" })] }), oc({ type: "Paragraph", children: [oc({ type: "Str", value: "C" })] }), oc({ type: "Paragraph", diff --git a/tsconfig.json b/tsconfig.json index 55de857..bd67b07 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -38,6 +38,12 @@ } }, - "include": ["**/*.ts"], - "exclude": [".git", "node_modules"] + "include": ["src/**/*.ts"], + "exclude": [ + ".git", + "node_modules", + "test/**/*", + "**/*.test.ts", + "jest.config.ts" + ] }