Skip to content

Commit

Permalink
fix multi-paragraph blockquotes (markdoc#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfix-stripe authored Feb 1, 2023
1 parent dcc4d46 commit f2fb25c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,4 +693,19 @@ ${'`'.repeat(4)}

stable(source);
});
it('multi-paragraph blockquotes', () => {
const source = `
> Blockquote {% .class %}
>
> with two paragraphs`;

const expected = `
> Blockquote {% .class %}
>
> with two paragraphs
`;

check(source, expected);
stable(expected);
});
});
9 changes: 5 additions & 4 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,11 @@ function* formatNode(n: Node, o: Options = {}) {
break;
}
case 'blockquote': {
yield NL;
yield indent;
yield '> ';
yield* trimStart(formatChildren(n, no));
const prefix = '>' + SPACE;
yield n.children
.map((child) => format(child, no).trimStart())
.map((d) => NL + indent + prefix + d)
.join(indent + prefix);
break;
}
case 'hr': {
Expand Down

0 comments on commit f2fb25c

Please sign in to comment.