Skip to content

Commit

Permalink
fix(tokenizer): fix setext continuation in blockquote
Browse files Browse the repository at this point in the history
  • Loading branch information
wallpants committed May 11, 2024
1 parent ef62267 commit dec9af2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rules/block.ts
Expand Up @@ -106,7 +106,7 @@ const block_paragraph = edit(
)
.replace("hr", block_hr)
.replace("heading", " {0,3}#{1,6}(?:\\s|$)")
.replace("|lheading", "") // setex headings don't interrupt commonmark paragraphs
.replace("|lheading", "") // setext headings don't interrupt commonmark paragraphs
.replace("table", block_table) // interrupt paragraphs with table
.replace("blockquote", " {0,3}>")
.replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n")
Expand Down
4 changes: 3 additions & 1 deletion src/tokenizer.ts
Expand Up @@ -105,7 +105,9 @@ export class Tokenizer {
const cap = block.blockquote.exec(src);
if (!cap) return undefined;

let text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ""), "\n");
// precede setext continuation with 4 spaces so it isn't a setext
let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n $1");
text = rtrim(text.replace(/^ *>[ \t]?/gm, ""), "\n");
const top = this.lexer.state.top;
this.lexer.state.top = true;
const tokens = this.lexer.blockTokens(text, []);
Expand Down

0 comments on commit dec9af2

Please sign in to comment.