Skip to content

Commit f26f215

Browse files
authored
Use <br> for inline text nodes with only a single newline. (#714)
DocC generates a single text node with a newline character to represent a hard line break that can be expressed in markdown using the "\" character to end a line that is followed immediately by a next line of text. Resolves: rdar://101684224
1 parent 6b19707 commit f26f215

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/components/ContentNode.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,11 @@ function renderNode(createElement, references) {
478478
renderChildren(node.inlineContent)
479479
));
480480
case InlineType.text:
481-
return node.text;
481+
return node.text === '\n' ? (
482+
createElement('br')
483+
) : (
484+
node.text
485+
);
482486
case InlineType.superscript:
483487
return createElement('sup', renderChildren(node.inlineContent));
484488
case InlineType.subscript:

tests/unit/components/ContentNode.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,15 @@ describe('ContentNode', () => {
13441344
const content = wrapper.find('.content');
13451345
expect(content.text()).toBe('foobar');
13461346
});
1347+
1348+
it('renders a <br> if the text is a single newline', () => {
1349+
const wrapper = mountWithItem({
1350+
type: 'text',
1351+
text: '\n',
1352+
});
1353+
const br = wrapper.find('.content br');
1354+
expect(br.exists()).toBe(true);
1355+
});
13471356
});
13481357

13491358
describe('with type="table"', () => {

0 commit comments

Comments
 (0)