-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(HTMLParser): fix code tags parsing
Closes #231
- Loading branch information
Showing
15 changed files
with
127 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Hash span elements that should not be parsed as markdown | ||
*/ | ||
showdown.subParser('hashPreCodeTags', function (text, config, globals) { | ||
'use strict'; | ||
|
||
var repFunc = function (wholeMatch, match, left, right) { | ||
// encode html entities | ||
var codeblock = left + showdown.subParser('encodeCode')(match) + right; | ||
return '\n\n~G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n'; | ||
}; | ||
|
||
text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^(?: |\\t){0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^(?: |\\t){0,3}</code>\\s*</pre>', 'gim'); | ||
return text; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p>code inception</p> | ||
|
||
<pre><code><pre><code> | ||
<div>some html code inside code html tags inside a fenced code block</div> | ||
</code></pre> | ||
</code></pre> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
code inception | ||
|
||
``` | ||
<pre><code> | ||
<div>some html code inside code html tags inside a fenced code block</div> | ||
</code></pre> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<pre> | ||
<code> | ||
foobar | ||
</code> | ||
</pre> | ||
|
||
<p>blabla</p> | ||
|
||
<pre nhaca="zulu"><code bla="bla"> | ||
foobar | ||
</code> | ||
</pre> | ||
|
||
<pre><code> | ||
<div>some html code</div> | ||
</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<pre> | ||
<code> | ||
foobar | ||
</code> | ||
</pre> | ||
|
||
blabla | ||
|
||
<pre nhaca="zulu"><code bla="bla"> | ||
foobar | ||
</code> | ||
</pre> | ||
|
||
<pre><code> | ||
<div>some html code</div> | ||
</code></pre> | ||
|
12 changes: 6 additions & 6 deletions
12
test/issues/#229.2.code-being-parsed-inside-HTML-code-tags.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/issues/#230.paragraphs-are-ignored-between-code-tags.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<pre lang="no-highlight"><code>```python | ||
var s; | ||
``` | ||
</code></pre> | ||
|
||
<p>this is a long paragraph</p> | ||
|
||
<pre lang="no-highlight"><code> | ||
```javascript | ||
var s; | ||
``` | ||
</code></pre> |
12 changes: 12 additions & 0 deletions
12
test/issues/#230.paragraphs-are-ignored-between-code-tags.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<pre lang="no-highlight"><code>```python | ||
var s; | ||
``` | ||
</code></pre> | ||
|
||
this is a long paragraph | ||
|
||
<pre lang="no-highlight"><code> | ||
```javascript | ||
var s; | ||
``` | ||
</code></pre> |