Skip to content

Commit

Permalink
Avoid converting "<p>12 </p>" to "1\\. "! Add tests for this.
Browse files Browse the repository at this point in the history
  • Loading branch information
jukka committed Jan 6, 2012
1 parent 5237c16 commit 0c0659f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/to-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var toMarkdown = function(string) {
// Lists

// Escape numbers that could trigger an ol
string = string.replace(/(\d+). /g, '$1\\. ');
string = string.replace(/(\d+)\. /g, '$1\\. ');

// Converts lists that have no child lists (of same type) first, then works it's way up
var noChildrenRegex = /<(ul|ol)\b[^>]*>(?:(?!<ul|<ol)[\s\S])*?<\/\1>/gi;
Expand Down
4 changes: 4 additions & 0 deletions test/nodejs/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ exports['converting list elements'] = function(test) {
].join('\n');
test.equal(toMarkdown(html), md, "We expect lists with blockquotes to be converted");


test.equal(toMarkdown("<p>12 </p>"), "12 ", "We expect plain numbers to remain unmodified");
test.equal(toMarkdown("<p>1. </p>"), "1\\. ", "We expect a period after a number to be escaped to avoid triggering an ordered list");

test.done();
};

Expand Down

0 comments on commit 0c0659f

Please sign in to comment.