Skip to content
This repository

Fix a failing test #7

Closed
wants to merge 2 commits into from

2 participants

Jukka Zitting Dom Christie
Jukka Zitting

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 Zitting 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 Zitting jukka Avoid converting "<p>12 </p>" to "1\\. "! Add tests for this. 0c0659f
Jukka Zitting

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

Dom Christie
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

Dom Christie
Owner

Fixed in 47df7a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jan 06, 2012
Jukka Zitting 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 Zitting jukka Avoid converting "<p>12 </p>" to "1\\. "! Add tests for this. 0c0659f
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +1 1  src/to-markdown.js
  2. +5 1 test/nodejs/convert.js
2  src/to-markdown.js
@@ -114,7 +114,7 @@ var toMarkdown = function(string) {
114 114 // Lists
115 115
116 116 // Escape numbers that could trigger an ol
117   - string = string.replace(/(\d+). /g, '$1\\. ');
  117 + string = string.replace(/(\d+)\. /g, '$1\\. ');
118 118
119 119 // Converts lists that have no child lists (of same type) first, then works it's way up
120 120 var noChildrenRegex = /<(ul|ol)\b[^>]*>(?:(?!<ul|<ol)[\s\S])*?<\/\1>/gi;
6 test/nodejs/convert.js
@@ -189,10 +189,14 @@ exports['converting list elements'] = function(test) {
189 189 var md = [
190 190 "* A list item with a blockquote:",
191 191 "",
192   - " > This is a blockquote inside a list item."
  192 + " > This is a blockquote inside a list item."
193 193 ].join('\n');
194 194 test.equal(toMarkdown(html), md, "We expect lists with blockquotes to be converted");
195 195
  196 +
  197 + test.equal(toMarkdown("<p>12 </p>"), "12 ", "We expect plain numbers to remain unmodified");
  198 + test.equal(toMarkdown("<p>1. </p>"), "1\\. ", "We expect a period after a number to be escaped to avoid triggering an ordered list");
  199 +
196 200 test.done();
197 201 };
198 202

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.