-
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.
Previously, `<code>` tags were not escaped. This was counter intuitive since ´<pre><code>` tags were being escaped. Now both pre code and code are escaped. Closes #339
- Loading branch information
Showing
9 changed files
with
52 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Hash and escape <code> elements that should not be parsed as markdown | ||
*/ | ||
showdown.subParser('hashCodeTags', function (text, options, globals) { | ||
'use strict'; | ||
text = globals.converter._dispatch('hashCodeTags.before', text, options, globals); | ||
|
||
var repFunc = function (wholeMatch, match, left, right) { | ||
var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right; | ||
return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C'; | ||
}; | ||
|
||
// Hash naked <code> | ||
text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim'); | ||
|
||
text = globals.converter._dispatch('hashCodeTags.after', text, options, globals); | ||
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,4 @@ | ||
<p>this is code <code>some <span>text</span></code> yeah!</p> | ||
<pre><code> | ||
<div>foo</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,5 @@ | ||
this is code <code>some <span>text</span></code> yeah! | ||
|
||
<pre><code> | ||
<div>foo</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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<p><code>some **code** yeah</code></p> | ||
<p>some <code>inline **code** block</code></p> | ||
<p><code>some inline **code**</code> block</p> | ||
<p>yo dawg <code start="true">some <code start="false">code</code> inception</code></p> | ||
<p>yo dawg <code start="true">some <code start="false">code</code> inception</code></p> | ||
<div>some **div** yeah</div> |