Skip to content

Commit 9142f0d

Browse files
committed
fix: typecheckエラー修正・フォーマット適用
1 parent 4fe04fc commit 9142f0d

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

packages/parser/src/parser/rules/block/div.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import type { Element } from "@wdprlib/ast";
22
import type { BlockRule, ParseContext, RuleResult } from "../types";
33
import { currentToken } from "../types";
4-
import {
5-
parseBlockName,
6-
parseAttributes,
7-
parseBlocksUntil,
8-
} from "./utils";
4+
import { parseBlockName, parseAttributes, parseBlocksUntil } from "./utils";
95

106
export const divRule: BlockRule = {
117
name: "div",
@@ -177,10 +173,7 @@ function consumeFailedDiv(ctx: ParseContext): RuleResult<Element> {
177173
while (ctx.tokens[peekPos]?.type === "WHITESPACE") peekPos++;
178174
if (ctx.tokens[peekPos]?.type === "NEWLINE") {
179175
// Blank line — skip all newlines and whitespace
180-
while (
181-
ctx.tokens[pos]?.type === "NEWLINE" ||
182-
ctx.tokens[pos]?.type === "WHITESPACE"
183-
) {
176+
while (ctx.tokens[pos]?.type === "NEWLINE" || ctx.tokens[pos]?.type === "WHITESPACE") {
184177
pos++;
185178
consumed++;
186179
}

packages/parser/src/parser/rules/block/paragraph.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,18 @@ export const paragraphRule: BlockRule = {
9292
}
9393

9494
// Remove trailing whitespace-only text nodes
95-
while (
96-
elements.length > 0 &&
97-
elements[elements.length - 1]?.element === "text" &&
98-
typeof elements[elements.length - 1]?.data === "string" &&
99-
(elements[elements.length - 1]?.data as string).trim() === ""
100-
) {
101-
elements.pop();
95+
while (elements.length > 0) {
96+
const last = elements[elements.length - 1];
97+
if (
98+
last?.element === "text" &&
99+
"data" in last &&
100+
typeof last.data === "string" &&
101+
last.data.trim() === ""
102+
) {
103+
elements.pop();
104+
} else {
105+
break;
106+
}
102107
}
103108

104109
// Remove leading line-breaks

packages/parser/src/parser/rules/inline/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import { linkSingleRule } from "./link-single";
1111
import { linkAnchorRule } from "./link-anchor";
1212
import { linkStarRule } from "./link-star";
1313
import { colorRule } from "./color";
14-
import { backslashLineBreakRule, newlineLineBreakRule, underscoreLineBreakRule } from "./line-break";
14+
import {
15+
backslashLineBreakRule,
16+
newlineLineBreakRule,
17+
underscoreLineBreakRule,
18+
} from "./line-break";
1519
import { commentRule } from "./comment";
1620
import { rawRule } from "./raw";
1721
import { spanRule, closeSpanRule } from "./span";
@@ -39,7 +43,11 @@ export { linkSingleRule } from "./link-single";
3943
export { linkAnchorRule } from "./link-anchor";
4044
export { linkStarRule } from "./link-star";
4145
export { colorRule } from "./color";
42-
export { backslashLineBreakRule, newlineLineBreakRule, underscoreLineBreakRule } from "./line-break";
46+
export {
47+
backslashLineBreakRule,
48+
newlineLineBreakRule,
49+
underscoreLineBreakRule,
50+
} from "./line-break";
4351
export { commentRule } from "./comment";
4452
export { rawRule } from "./raw";
4553
export { spanRule, closeSpanRule } from "./span";

0 commit comments

Comments
 (0)