Skip to content

Commit

Permalink
Merge pull request #2608 from huridocs/2526_markdown_improvement
Browse files Browse the repository at this point in the history
markdown now ouputs single tags as self closed
  • Loading branch information
habbes authored Nov 6, 2019
2 parents 7cf2a74 + 05e83cb commit 21b80f6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/react/Markdown/markdownToReact.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const dynamicCustomContainersConfig = {
};


const markdownIt = instanceMarkdownIt().use(mdContainer, 'dynamic', dynamicCustomContainersConfig);
const markdownItWithHtml = instanceMarkdownIt({ html: true }).use(mdContainer, 'dynamic', dynamicCustomContainersConfig);
const markdownIt = instanceMarkdownIt({ xhtmlOut: true }).use(mdContainer, 'dynamic', dynamicCustomContainersConfig);
const markdownItWithHtml = instanceMarkdownIt({ html: true, xhtmlOut: true }).use(mdContainer, 'dynamic', dynamicCustomContainersConfig);
const customComponentTypeMatcher = /{(.+)}\(/;

const getConfig = (string) => {
Expand Down
11 changes: 11 additions & 0 deletions app/react/Markdown/specs/MarkdownViewer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ describe('MarkdownViewer', () => {
expect(component).toMatchSnapshot();
});

it('should render single tags as self closing', () => {
props.html = true;
props.markdown = '' +
'test\n\n' +
'***\n' +
'test';

render();
expect(component).toMatchSnapshot();
});

it('should render properly a selfclosing XML tags', () => {
props.html = true;
props.markdown = '' +
Expand Down
26 changes: 26 additions & 0 deletions app/react/Markdown/specs/__snapshots__/MarkdownViewer.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,32 @@ exports[`MarkdownViewer render should render properly a selfclosing XML tags 1`]
</div>
`;

exports[`MarkdownViewer render should render single tags as self closing 1`] = `
<div
className="markdown-viewer"
>
<p
key="0"
>
test
</p>
<hr
key="2"
/>
<p
key="4"
>
test
</p>
</div>
`;

exports[`MarkdownViewer render should support containers with custom classNames 1`] = `
<div
className="markdown-viewer"
Expand Down

0 comments on commit 21b80f6

Please sign in to comment.