Skip to content

Commit

Permalink
Fix parse error if a code block ends a string
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Jun 25, 2022
1 parent 90ce55e commit 75cbf1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/converter/comments/blockLexer.ts
Expand Up @@ -283,7 +283,7 @@ function* lexBlockComment2(
}

function lookaheadExactlyNTicks(pos: number, n: number) {
if (pos + n >= end) {
if (pos + n > end) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/comments/lineLexer.ts
Expand Up @@ -248,7 +248,7 @@ function* lexBlockComment2(
}

function lookaheadExactlyNTicks(pos: number, n: number) {
if (pos + n >= end) {
if (pos + n > end) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/comments/rawLexer.ts
Expand Up @@ -232,7 +232,7 @@ function* lexCommentString2(
}

function lookaheadExactlyNTicks(pos: number, n: number) {
if (pos + n >= end) {
if (pos + n > end) {
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions src/test/comments.test.ts
Expand Up @@ -886,6 +886,18 @@ describe("Raw Lexer", () => {
]);
});

// https://github.com/TypeStrong/typedoc/issues/1922#issuecomment-1166278275
it("Should handle code blocks ending a string", () => {
const tokens = lex("`code`");

equal(tokens, [
{
kind: "code",
text: "`code`",
},
]);
});

it("Should allow inline code with multiple ticks", () => {
const tokens = lex("test ```not ```` closed``` after");
equal(tokens, [
Expand Down

0 comments on commit 75cbf1f

Please sign in to comment.