Skip to content

Commit

Permalink
Do not escape hyphens unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
domchristie committed Aug 28, 2018
1 parent 5bc8697 commit 07e36e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/turndown.js
Expand Up @@ -9,7 +9,7 @@ var trailingNewLinesRegExp = /\n*$/
var escapes = [
[/\\/g, '\\\\'],
[/\*/g, '\\*'],
[/-/g, '\\-'],
[/^-/g, '\\-'],
[/^\+ /g, '\\+ '],
[/^(=+)/g, '\\$1'],
[/^(#{1,6}) /g, '\\$1 '],
Expand Down
14 changes: 7 additions & 7 deletions test/index.html
Expand Up @@ -733,7 +733,7 @@ <h2>This is a header.</h2>

<div class="case" data-name="escaping hr markdown with -">
<div class="input">- - -</div>
<pre class="expected">\- \- \-</pre>
<pre class="expected">\- - -</pre>
</div>

<div class="case" data-name="escaping hr markdown with _">
Expand Down Expand Up @@ -776,6 +776,11 @@ <h2>This is a header.</h2>
<pre class="expected">\+ An unordered list item</pre>
</div>

<div class="case" data-name="not escaping - outside of a ul">
<div class="input">Hello-world, 45 - 3 is 42</div>
<pre class="expected">Hello-world, 45 - 3 is 42</pre>
</div>

<div class="case" data-name="not escaping + outside of a ul">
<div class="input">+1 and another +</div>
<pre class="expected">+1 and another +</pre>
Expand All @@ -796,11 +801,6 @@ <h2>This is a header.</h2>
<pre class="expected">_test\_italics_</pre>
</div>

<div class="case" data-name="escaping -">
<div class="input">45 - 3 is 42</div>
<pre class="expected">45 \- 3 is 42</pre>
</div>

<div class="case" data-name="escaping > as blockquote">
<div class="input">> Blockquote in markdown</div>
<pre class="expected">\> Blockquote in markdown</pre>
Expand Down Expand Up @@ -844,7 +844,7 @@ <h2>This is a header.</h2>

<div class="case" data-name="escaping delimiters around short words and numbers">
<div class="input"><p>_Really_? Is that what it _is_? A **2000** year-old computer?</p></div>
<pre class="expected">\_Really\_? Is that what it \_is\_? A \*\*2000\*\* year\-old computer?</pre>
<pre class="expected">\_Really\_? Is that what it \_is\_? A \*\*2000\*\* year-old computer?</pre>
</div>

<div class="case" data-name="non-markdown block elements">
Expand Down

0 comments on commit 07e36e0

Please sign in to comment.