mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
parent
4c68452999
commit
71a5873902
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -276,6 +276,7 @@ showdown.Converter = function (converterOptions) {
|
|||
});
|
||||
|
||||
// run the sub parsers
|
||||
text = showdown.subParser('hashPreCodeTags')(text, options, globals);
|
||||
text = showdown.subParser('githubCodeBlocks')(text, options, globals);
|
||||
text = showdown.subParser('hashHTMLBlocks')(text, options, globals);
|
||||
text = showdown.subParser('hashHTMLSpans')(text, options, globals);
|
||||
|
|
15
src/subParsers/hashPreCodeTags.js
Normal file
15
src/subParsers/hashPreCodeTags.js
Normal file
|
@ -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;
|
||||
});
|
|
@ -31,7 +31,6 @@ showdown.subParser('paragraphs', function (text, options, globals) {
|
|||
for (i = 0; i < end; i++) {
|
||||
var blockText = '',
|
||||
grafsOutIt = grafsOut[i],
|
||||
child = false,
|
||||
codeFlag = false;
|
||||
// if this is a marker for an html block...
|
||||
while (grafsOutIt.search(/~(K|G)(\d+)\1/) >= 0) {
|
||||
|
@ -42,7 +41,12 @@ showdown.subParser('paragraphs', function (text, options, globals) {
|
|||
blockText = globals.gHtmlBlocks[num];
|
||||
} else {
|
||||
// we need to check if ghBlock is a false positive
|
||||
blockText = (codeFlag) ? globals.ghCodeBlocks[num].text : globals.ghCodeBlocks[num].codeblock;
|
||||
if (codeFlag) {
|
||||
// use encoded version of all text
|
||||
blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text);
|
||||
} else {
|
||||
blockText = globals.ghCodeBlocks[num].codeblock;
|
||||
}
|
||||
}
|
||||
blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
|
||||
|
||||
|
@ -51,7 +55,6 @@ showdown.subParser('paragraphs', function (text, options, globals) {
|
|||
if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) {
|
||||
codeFlag = true;
|
||||
}
|
||||
child = true;
|
||||
}
|
||||
grafsOut[i] = grafsOutIt;
|
||||
}
|
||||
|
|
7
test/cases/pre-code-tags-inside-code-block.html
Normal file
7
test/cases/pre-code-tags-inside-code-block.html
Normal file
|
@ -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>
|
||||
|
8
test/cases/pre-code-tags-inside-code-block.md
Normal file
8
test/cases/pre-code-tags-inside-code-block.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
code inception
|
||||
|
||||
```
|
||||
<pre><code>
|
||||
<div>some html code inside code html tags inside a fenced code block</div>
|
||||
</code></pre>
|
||||
```
|
||||
|
16
test/cases/pre-code-tags.html
Normal file
16
test/cases/pre-code-tags.html
Normal file
|
@ -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>
|
17
test/cases/pre-code-tags.md
Normal file
17
test/cases/pre-code-tags.md
Normal file
|
@ -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>
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
<pre lang="no-highlight"><code>
|
||||
foo
|
||||
foo
|
||||
|
||||
```javascript
|
||||
var s = "JavaScript syntax highlighting";
|
||||
alert(s);
|
||||
```
|
||||
```javascript
|
||||
var s = "JavaScript syntax highlighting";
|
||||
alert(s);
|
||||
```
|
||||
|
||||
bar
|
||||
bar
|
||||
</code></pre>
|
||||
|
||||
<p>this is a long paragraph</p>
|
||||
|
|
|
@ -11,6 +11,6 @@ print s
|
|||
|
||||
```
|
||||
No language indicated, so no syntax highlighting.
|
||||
But let's throw in a <b>tag</b>.
|
||||
But let's throw in a <b>tag</b>.
|
||||
```
|
||||
</code></pre>
|
||||
|
|
|
@ -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
test/issues/#230.paragraphs-are-ignored-between-code-tags.md
Normal file
12
test/issues/#230.paragraphs-are-ignored-between-code-tags.md
Normal file
|
@ -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>
|
Loading…
Reference in New Issue
Block a user