From 71a5873902568a169d59da6b78ee42e7d97b5dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Estev=C3=A3o=20Soares=20dos=20Santos?= Date: Mon, 25 Jan 2016 03:01:54 +0000 Subject: [PATCH] fix(HTMLParser): fix code tags parsing Closes #231 --- dist/showdown.js | Bin 71622 -> 72405 bytes dist/showdown.js.map | Bin 229327 -> 228797 bytes dist/showdown.min.js | Bin 27848 -> 28235 bytes dist/showdown.min.js.map | Bin 31636 -> 31964 bytes src/converter.js | 1 + src/subParsers/hashPreCodeTags.js | 15 +++++++++++++++ src/subParsers/paragraphs.js | 9 ++++++--- .../pre-code-tags-inside-code-block.html | 7 +++++++ test/cases/pre-code-tags-inside-code-block.md | 8 ++++++++ test/cases/pre-code-tags.html | 16 ++++++++++++++++ test/cases/pre-code-tags.md | 17 +++++++++++++++++ ...de-being-parsed-inside-HTML-code-tags.html | 12 ++++++------ ...de-being-parsed-inside-HTML-code-tags.html | 2 +- ...agraphs-are-ignored-between-code-tags.html | 12 ++++++++++++ ...aragraphs-are-ignored-between-code-tags.md | 12 ++++++++++++ 15 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 src/subParsers/hashPreCodeTags.js create mode 100644 test/cases/pre-code-tags-inside-code-block.html create mode 100644 test/cases/pre-code-tags-inside-code-block.md create mode 100644 test/cases/pre-code-tags.html create mode 100644 test/cases/pre-code-tags.md create mode 100644 test/issues/#230.paragraphs-are-ignored-between-code-tags.html create mode 100644 test/issues/#230.paragraphs-are-ignored-between-code-tags.md diff --git a/dist/showdown.js b/dist/showdown.js index 6d30511fb82a765d452f5cf44ca5cbdedff58999..cbf5522c01565e25068070d3f1bd61dcee7f867d 100644 GIT binary patch delta 388 zcmX@Mp5^LRmJP>Z_%afUGXjcIo%2&tLlV;`FZeD$*)~>o^19`Mo3F=Qj+s1RGW%rK z?V(&qY98*entb6O8+(CUXZ1j1isudJ->xZemGthNgnHLQ!UVMv3)gp*8tT)?AaV=1NVr-(v1n zP?Q=IlN23i7pr9#6H}~Z12PpZqOPN$9;ab%rBD+SQ=(aIpkrKXqYqL6QL7KsZ3j}5 zo|&sYIq|Ia=6yRIOeWv{z_nTaoin3vW}1QqNVQu|V!Eb6HJ1V$06kDzoC@_sib7dx zQE_H|oZHVec)iJ4qqCbBtakAn$MMrKZmf~`VYVoq`D=7k?37$>j%#KWtR zoS%~FmXnySsbH@#Irozsvw{_fmYRJ2li=o8p9~oJ6%>-8dP|B*Q>{0PemS590EGrA AP5=M^ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index a64543d2667c561947b5103bb1fc8743242bec5c..79e29c978f21037b403f85206ea4458bba7c533f 100644 GIT binary patch delta 10327 zcmcIq3sjUxmOfQY3*8_MLL&_VzltJ=G#w&D@zD*UCL!7;I*w5cEux^P5*yY-MaU?-+ffc#jl2*{$gn7-}z8aLyg;CU0T1qdcJ2Rcp_{sf5|I0;oE5} z1Dk)r5~0#=#=c*(H0XUbBFR^pTk3L^=9al!WySPmw)k-2TWKt%6_R1&(p0D{j4+C~ z^C5oGZFt{rS+sog$(`$R z%?+tLAI=T6Vz+~tQq-{cbcJmM=TcJe@I+>U_AR4_$ayp1YO(c(P4YndOGJF&Ci&Ca z(xqre$)KVut5Q%qOD61V%ax)FzPo5QD$xali;g#^pmP;dIIJTa{sB}newPC64@TI9 z&i1c zGf%kP<+?p2d}66`pP;1>>CTnI`eQk^k0l*rR}tpD@evYpUkSL%t*w{M_~kwp0~fcA z5*tC<)M3zl&?vNl=Fv3$U(8^C)(VxmkgmCVg4Z9Xtp{L0N zo#oM_nHk$x(N^>Ye8-H?(`m%+dCX$gQMQ-C-sh*upq(^BxlJY>ok1&L#}~S9%ocrB zjp8rNdto{F8jbMbA5-D2G0GZ?Zp|bWFt}?BPY37l2y}kNBH{k*beOaI%}fE*`q|&k z-V|agxTg>)UsObW^6@BG*^x*QYqaUX46w<_?wiZkj7JaY6j=Gokq| z+UiaV^f-;+cBpV^EL9Fa`=}YB_aH<&abF;FT8a_@Ax?hJ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o8SWhP% zU8igUayq#ZuV`$` uiFH*=hAQK6eWhkVn5=4}#OL9iuT^SFnTdL=fEGF#xJP$>f1l<|?*9UQmHw0f diff --git a/dist/showdown.min.js b/dist/showdown.min.js index 6fe4aeea7a2ef29f6a5c4ee58ce074a26d22fed0..780bf15a975510a43b9403d6bc64bf539ca8d472 100644 GIT binary patch delta 361 zcmX?clkxN&#tocm{27VG839G9&iN^+A&Ke5lN(eeH*>0eQ{Y1rKjKo$0;X2IlDMIKh`Q2B$VNtpOOj}(<@1>D6v8po*Wlj&6R7b QXrQT+10*-!i_H}P0C6TVbN~PV diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index d3e6f24ef613c333047f26463ec57ada73f47345..6482e8cb031e65c04d1b93e8e67431c2858029c5 100644 GIT binary patch delta 2364 zcmbVN%}-=S5D$sTPL>1|Vfk2OB@o$_x6TlTuVcNQp62lw-aKXocGjq2ahWe*KA0IE zLpCHHym@MGMm^{sU_!j={uACzhDZ8dJ~Mp!Eas2vPyEG*1K=DaETx0B z@q~;DOQE5aq)$FbS`xskN%~|Cgp~uxS=#{H(|j&dv@HRmEHMpuw3{y^^rvpT#|NjV z(3*fH45f44-GNd9ppvlm1VB|-8E_gav#x&q@$hMS{m#G*H?S=SR&={?|HdZflj{ln zePQAxCJBnakm4MRDO`yiL4f?Iu@%;ErOI{#tAIq_N&#$OA_*ebRD4iad4$$dxUc5y zWwgoM40&BEitF@ij!Lb%z~_R& z>716z_g{+?n2dZ;f3@%Tlt?k<^6{;r{&WAVFHU8HZ*79yz<KE0K{=GC~Lm?p7 zG<>%7Xl=AB&`Y&@{qbe1V1wA;qFqXx3v|1dnOY=DmlcqA%(h&Bvd!sID4+*w0~5j4 zq5ictHPGg`8KP)Gpn_CMOI!7c_XCd>7cE76mw4ZuqbT6-vT~U`9!p{Wd61NtS^c-n zxAfEcV5F1ggfV?qzkR#S2_3YEl|zqU`(+XqQWgE`AiTii3=tjTOBRvA8x6_dsV_DvN%Y<5WDk3#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#d|KY(Z zb_}rg02ch?W(QFv*$T2Aq|<=POEZQ+PHh_>mX>8K-%(OqL?Q>rk}Q<( zH|}0v-PDeC#&?M^3nAu1`DG(JvH<+bZ<`ZWLmk46UBJMKr*geHf1^j)vp|Be#@B3W zvMbxoxs}ktmu!o}9?O$5723DfFbi{iQY~A6FuN{bDJ2%ZL0I%-@gW*WqO z+{TBqE;}c4qftO0KR%fr4WHZZk0*EfLj;W{ zmeKY?w6+NQ4zRWr|nETE<*eui^a?DeTu$CX0Nd4%ub-X=l1$ zQXZk(VEf3o$f-3eRE}tG5_s*9vBw$^Smg_8EEmlLh=M_JAAMpj;eX^9wq2YA3{%3x zguKk?(gbSit0;mBlj-jGD==fw;#y5-;t?cDvOw0lGqI|C+MT*pp>)_UiyEMN?$o!5 zsD}Ky``Yad#L9h44RH?538Nn64PZFKux!3tYH03m3%ls6f6&V z@vCY)TWG9YOMcXwdBNM3U-V|Kt2v0U07(w{up080-ee!h$9dL3Cit?h3P8^&j8@TM z;-gY2c1&Q*sDS!vILgPiQuf@4G>*&yve@BD42}g|5|Hl>2`E1}z1fc>yBKv8C}}P< zlv<}`mz94EW%SFULzDMGZxnYJap02JTcl}(IM$Lg;bh-KZdjJ~gNza#Sg?UQXeBN# zwE|Je)37M=oYRpXfT03yjVaV>G;n{vkK0Ld1&BO1ukw-t^($llMZ%aeOx6b3 SeUHIOanwpupFRDJCw~GUvWs>A diff --git a/src/converter.js b/src/converter.js index 57d0a23..1213a6d 100644 --- a/src/converter.js +++ b/src/converter.js @@ -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); diff --git a/src/subParsers/hashPreCodeTags.js b/src/subParsers/hashPreCodeTags.js new file mode 100644 index 0000000..8315d95 --- /dev/null +++ b/src/subParsers/hashPreCodeTags.js @@ -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}]*>\\s*]*>', '^(?: |\\t){0,3}\\s*', 'gim'); + return text; +}); diff --git a/src/subParsers/paragraphs.js b/src/subParsers/paragraphs.js index 7f19c38..b5673df 100644 --- a/src/subParsers/paragraphs.js +++ b/src/subParsers/paragraphs.js @@ -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 (/^]*>\s*]*>/.test(grafsOutIt)) { codeFlag = true; } - child = true; } grafsOut[i] = grafsOutIt; } diff --git a/test/cases/pre-code-tags-inside-code-block.html b/test/cases/pre-code-tags-inside-code-block.html new file mode 100644 index 0000000..66544da --- /dev/null +++ b/test/cases/pre-code-tags-inside-code-block.html @@ -0,0 +1,7 @@ +

code inception

+ +
<pre><code>
+<div>some html code inside code html tags inside a fenced code block</div>
+</code></pre>
+
+ diff --git a/test/cases/pre-code-tags-inside-code-block.md b/test/cases/pre-code-tags-inside-code-block.md new file mode 100644 index 0000000..79b57f2 --- /dev/null +++ b/test/cases/pre-code-tags-inside-code-block.md @@ -0,0 +1,8 @@ +code inception + +``` +

+
some html code inside code html tags inside a fenced code block
+
+``` + diff --git a/test/cases/pre-code-tags.html b/test/cases/pre-code-tags.html new file mode 100644 index 0000000..573b388 --- /dev/null +++ b/test/cases/pre-code-tags.html @@ -0,0 +1,16 @@ +
+
+foobar
+
+
+ +

blabla

+ +

+foobar
+
+
+ +

+<div>some html code</div>
+
diff --git a/test/cases/pre-code-tags.md b/test/cases/pre-code-tags.md new file mode 100644 index 0000000..ab1d543 --- /dev/null +++ b/test/cases/pre-code-tags.md @@ -0,0 +1,17 @@ +
+
+foobar
+
+
+ +blabla + +

+foobar
+
+
+ +

+
some html code
+
+ diff --git a/test/issues/#229.2.code-being-parsed-inside-HTML-code-tags.html b/test/issues/#229.2.code-being-parsed-inside-HTML-code-tags.html index 4f53c72..dff2c46 100644 --- a/test/issues/#229.2.code-being-parsed-inside-HTML-code-tags.html +++ b/test/issues/#229.2.code-being-parsed-inside-HTML-code-tags.html @@ -1,12 +1,12 @@

-    foo
+foo
 
-    ```javascript
-    var s = "JavaScript syntax highlighting";
-    alert(s);
-    ```
+```javascript
+var s = "JavaScript syntax highlighting";
+alert(s);
+```
 
-    bar
+bar
 

this is a long paragraph

diff --git a/test/issues/#229.code-being-parsed-inside-HTML-code-tags.html b/test/issues/#229.code-being-parsed-inside-HTML-code-tags.html index 5a148ce..deba3d4 100644 --- a/test/issues/#229.code-being-parsed-inside-HTML-code-tags.html +++ b/test/issues/#229.code-being-parsed-inside-HTML-code-tags.html @@ -11,6 +11,6 @@ print s ``` No language indicated, so no syntax highlighting. -But let's throw in a tag. +But let's throw in a <b>tag</b>. ``` diff --git a/test/issues/#230.paragraphs-are-ignored-between-code-tags.html b/test/issues/#230.paragraphs-are-ignored-between-code-tags.html new file mode 100644 index 0000000..1f2492a --- /dev/null +++ b/test/issues/#230.paragraphs-are-ignored-between-code-tags.html @@ -0,0 +1,12 @@ +
```python
+var s;
+```
+
+ +

this is a long paragraph

+ +

+```javascript
+var s;
+```
+
diff --git a/test/issues/#230.paragraphs-are-ignored-between-code-tags.md b/test/issues/#230.paragraphs-are-ignored-between-code-tags.md new file mode 100644 index 0000000..9362a18 --- /dev/null +++ b/test/issues/#230.paragraphs-are-ignored-between-code-tags.md @@ -0,0 +1,12 @@ +
```python
+var s;
+```
+
+ +this is a long paragraph + +

+```javascript
+var s;
+```
+