diff --git a/src/lib/converter/comments/blockLexer.ts b/src/lib/converter/comments/blockLexer.ts index 0680c2ca6..80f33e365 100644 --- a/src/lib/converter/comments/blockLexer.ts +++ b/src/lib/converter/comments/blockLexer.ts @@ -283,7 +283,7 @@ function* lexBlockComment2( } function lookaheadExactlyNTicks(pos: number, n: number) { - if (pos + n >= end) { + if (pos + n > end) { return false; } diff --git a/src/lib/converter/comments/lineLexer.ts b/src/lib/converter/comments/lineLexer.ts index f753a137a..f0fb023fa 100644 --- a/src/lib/converter/comments/lineLexer.ts +++ b/src/lib/converter/comments/lineLexer.ts @@ -248,7 +248,7 @@ function* lexBlockComment2( } function lookaheadExactlyNTicks(pos: number, n: number) { - if (pos + n >= end) { + if (pos + n > end) { return false; } diff --git a/src/lib/converter/comments/rawLexer.ts b/src/lib/converter/comments/rawLexer.ts index e66318e20..f2dcc4751 100644 --- a/src/lib/converter/comments/rawLexer.ts +++ b/src/lib/converter/comments/rawLexer.ts @@ -232,7 +232,7 @@ function* lexCommentString2( } function lookaheadExactlyNTicks(pos: number, n: number) { - if (pos + n >= end) { + if (pos + n > end) { return false; } diff --git a/src/test/comments.test.ts b/src/test/comments.test.ts index 61cde5114..de83d894b 100644 --- a/src/test/comments.test.ts +++ b/src/test/comments.test.ts @@ -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, [