Skip to content

Commit 75cbf1f

Browse files
committed
Fix parse error if a code block ends a string
1 parent 90ce55e commit 75cbf1f

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/lib/converter/comments/blockLexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function* lexBlockComment2(
283283
}
284284

285285
function lookaheadExactlyNTicks(pos: number, n: number) {
286-
if (pos + n >= end) {
286+
if (pos + n > end) {
287287
return false;
288288
}
289289

src/lib/converter/comments/lineLexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function* lexBlockComment2(
248248
}
249249

250250
function lookaheadExactlyNTicks(pos: number, n: number) {
251-
if (pos + n >= end) {
251+
if (pos + n > end) {
252252
return false;
253253
}
254254

src/lib/converter/comments/rawLexer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function* lexCommentString2(
232232
}
233233

234234
function lookaheadExactlyNTicks(pos: number, n: number) {
235-
if (pos + n >= end) {
235+
if (pos + n > end) {
236236
return false;
237237
}
238238

src/test/comments.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,18 @@ describe("Raw Lexer", () => {
886886
]);
887887
});
888888

889+
// https://github.com/TypeStrong/typedoc/issues/1922#issuecomment-1166278275
890+
it("Should handle code blocks ending a string", () => {
891+
const tokens = lex("`code`");
892+
893+
equal(tokens, [
894+
{
895+
kind: "code",
896+
text: "`code`",
897+
},
898+
]);
899+
});
900+
889901
it("Should allow inline code with multiple ticks", () => {
890902
const tokens = lex("test ```not ```` closed``` after");
891903
equal(tokens, [

0 commit comments

Comments
 (0)