Skip to content

Commit f2fb25c

Browse files
authored
fix multi-paragraph blockquotes (markdoc#322)
Closes markdoc#321
1 parent dcc4d46 commit f2fb25c

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/formatter.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,4 +693,19 @@ ${'`'.repeat(4)}
693693

694694
stable(source);
695695
});
696+
it('multi-paragraph blockquotes', () => {
697+
const source = `
698+
> Blockquote {% .class %}
699+
>
700+
> with two paragraphs`;
701+
702+
const expected = `
703+
> Blockquote {% .class %}
704+
>
705+
> with two paragraphs
706+
`;
707+
708+
check(source, expected);
709+
stable(expected);
710+
});
696711
});

src/formatter.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ function* formatNode(n: Node, o: Options = {}) {
215215
break;
216216
}
217217
case 'blockquote': {
218-
yield NL;
219-
yield indent;
220-
yield '> ';
221-
yield* trimStart(formatChildren(n, no));
218+
const prefix = '>' + SPACE;
219+
yield n.children
220+
.map((child) => format(child, no).trimStart())
221+
.map((d) => NL + indent + prefix + d)
222+
.join(indent + prefix);
222223
break;
223224
}
224225
case 'hr': {

0 commit comments

Comments
 (0)