Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix a failing test #7

Closed
wants to merge 2 commits into from

2 participants

@jukka

I was having trouble with a test failing apparently due to a change in the amount of whitespace added for a blockquote inside a list. This change fixes the test failure simply by modifying the assertion. I'm not sure if this should rather be fixed in the actual HTML->Markdown conversion code.

See Travis build result at: http://travis-ci.org/#!/jukka/to-markdown/builds/484922

jukka added some commits
@jukka jukka The "We expect lists with blockquotes to be converted" test was faili…
…ng apparently due to a change in the amount of whitespace added for a blockquote inside a list.
5237c16
@jukka jukka Avoid converting "<p>12 </p>" to "1\\. "! Add tests for this. 0c0659f
@jukka

Also added a commit (0c0659f) that fixes an incorrect regexp in the code.

@domchristie
Owner

I believe this should be fixed in the conversion. I'll add a comment in the test and add it as an issue.

I'd be happy to merge in the regex fix if added as a separate pull request.

Thanks for your contribution!

Edit: the issue was added a while ago: #2

@domchristie
Owner

Fixed in 47df7a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 6, 2012
  1. @jukka

    The "We expect lists with blockquotes to be converted" test was faili…

    jukka authored
    …ng apparently due to a change in the amount of whitespace added for a blockquote inside a list.
  2. @jukka
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +1 −1  src/to-markdown.js
  2. +5 −1 test/nodejs/convert.js
View
2  src/to-markdown.js
@@ -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;
View
6 test/nodejs/convert.js
@@ -189,10 +189,14 @@ exports['converting list elements'] = function(test) {
var md = [
"* A list item with a blockquote:",
"",
- " > This is a blockquote inside a list item."
+ " > This is a blockquote inside a list item."
].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();
};
Something went wrong with that request. Please try again.