diff --git a/packages/gitbook/src/components/DocumentView/Text.tsx b/packages/gitbook/src/components/DocumentView/Text.tsx index f70a69782..8b2669bcb 100644 --- a/packages/gitbook/src/components/DocumentView/Text.tsx +++ b/packages/gitbook/src/components/DocumentView/Text.tsx @@ -38,12 +38,21 @@ export function Text(props: { text: DocumentText }) { {children} ); - }, leaf.text)} + }, withSoftBreaks(leaf.text))} ); }); } +// Paragraphs with buttons are flex containers, where a `\n` alone can't move the next items to a new line. +function withSoftBreaks(text: string): React.ReactNode { + return text + .split('\n') + .flatMap((line, index) => + index === 0 ? line : ['\n', , line] + ); +} + const MARK_STYLES = { bold: Bold, italic: Italic,