Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not escape hyphens unnecessarily #255

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/turndown.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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