Skip to content

Commit 515e8b7

Browse files
committed
Fix inline tag parsing
Ref: #2273
1 parent 26df2ac commit 515e8b7

5 files changed

Lines changed: 34 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Bug Fixes
88

99
- Category children are now sorted according to the `sort` option, #2272.
10+
- Inline tags no longer require a space after the tag name to be parsed as a tag, #2273.
1011

1112
## v0.24.6 (2023-04-24)
1213

src/lib/converter/comments/blockLexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function* lexBlockComment2(
251251

252252
if (
253253
lookahead !== pos + 1 &&
254-
(lookahead === end || /\s/.test(file[lookahead]))
254+
(lookahead === end || /[\s}]/.test(file[lookahead]))
255255
) {
256256
braceStartsType = true;
257257
const token = makeToken(

src/lib/converter/comments/lineLexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function* lexLineComments2(
169169

170170
if (
171171
lookahead !== pos + 1 &&
172-
(lookahead === end || /\s/.test(file[lookahead]))
172+
(lookahead === end || /[\s}]/.test(file[lookahead]))
173173
) {
174174
braceStartsType = true;
175175
yield makeToken(TokenSyntaxKind.Tag, lookahead - pos);

src/lib/converter/comments/rawLexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function* lexCommentString2(
167167

168168
if (
169169
lookahead !== pos + 1 &&
170-
(lookahead === end || /\s/.test(file[lookahead]))
170+
(lookahead === end || /[\s}]/.test(file[lookahead]))
171171
) {
172172
braceStartsType = true;
173173
yield makeToken(TokenSyntaxKind.Tag, lookahead - pos);

src/test/comments.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,16 @@ describe("Block Comment Lexer", () => {
564564
{ kind: TokenSyntaxKind.CloseBrace, text: "}", pos: 21 },
565565
]);
566566
});
567+
568+
it("Should allow inline tags directly next to braces", () => {
569+
const tokens = lex("/** {@inline} */");
570+
571+
equal(tokens, [
572+
{ kind: TokenSyntaxKind.OpenBrace, text: "{", pos: 4 },
573+
{ kind: TokenSyntaxKind.Tag, text: "@inline", pos: 5 },
574+
{ kind: TokenSyntaxKind.CloseBrace, text: "}", pos: 12 },
575+
]);
576+
});
567577
});
568578

569579
describe("Line Comment Lexer", () => {
@@ -881,6 +891,16 @@ describe("Line Comment Lexer", () => {
881891
{ kind: TokenSyntaxKind.CloseBrace, text: "}", pos: 21 },
882892
]);
883893
});
894+
895+
it("Should allow inline tags directly next to braces", () => {
896+
const tokens = lex("// {@inline}");
897+
898+
equal(tokens, [
899+
{ kind: TokenSyntaxKind.OpenBrace, text: "{", pos: 3 },
900+
{ kind: TokenSyntaxKind.Tag, text: "@inline", pos: 4 },
901+
{ kind: TokenSyntaxKind.CloseBrace, text: "}", pos: 11 },
902+
]);
903+
});
884904
});
885905

886906
describe("Raw Lexer", () => {
@@ -1197,6 +1217,16 @@ describe("Raw Lexer", () => {
11971217
{ kind: TokenSyntaxKind.CloseBrace, text: "}", pos: 18 },
11981218
]);
11991219
});
1220+
1221+
it("Should allow inline tags directly next to braces", () => {
1222+
const tokens = lex("{@inline}");
1223+
1224+
equal(tokens, [
1225+
{ kind: TokenSyntaxKind.OpenBrace, text: "{", pos: 0 },
1226+
{ kind: TokenSyntaxKind.Tag, text: "@inline", pos: 1 },
1227+
{ kind: TokenSyntaxKind.CloseBrace, text: "}", pos: 8 },
1228+
]);
1229+
});
12001230
});
12011231

12021232
describe("Comment Parser", () => {

0 commit comments

Comments
 (0)