Skip to content

Commit

Permalink
fix(makeMarkdown): handle <br> tags converting html to markdown
Browse files Browse the repository at this point in the history
Convert <br> tags to 2 spaces + newline rather than leaving the tag
in place when converting HTML to MD
  • Loading branch information
dchester authored and tivie committed Jan 1, 2019
1 parent 82f90eb commit 2019694
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/subParsers/makemarkdown/break.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
showdown.subParser('makeMarkdown.break', function () {
'use strict';

return ' \n';
});
4 changes: 4 additions & 0 deletions src/subParsers/makemarkdown/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
txt = showdown.subParser('makeMarkdown.image')(node, globals);
break;

case 'br':
txt = showdown.subParser('makeMarkdown.break')(node, globals);
break;

default:
txt = node.outerHTML + '\n\n';
}
Expand Down
1 change: 1 addition & 0 deletions test/functional/makemarkdown/cases/standard/breaks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
first line<br />and the second
2 changes: 2 additions & 0 deletions test/functional/makemarkdown/cases/standard/breaks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
first line
and the second

0 comments on commit 2019694

Please sign in to comment.