Преглед на файлове

fix(subParsers/hashHTMLBlocks.js): fix rendering problems with html5 block elements.

Some HTML5 block elements were not being properly ignored. This caused problems in rendering markdown as showdown would add additional <br /> to some block elements.
This commit should fix this issue.

Closes #90, closes #140, closes #147
Estevão Soares dos Santos преди 10 години
родител
ревизия
fb3e0ba3bc
променени са 7 файла, в които са добавени 109 реда и са изтрити 3 реда
  1. 1 1
      dist/showdown.js
  2. 0 0
      dist/showdown.js.map
  3. 0 0
      dist/showdown.min.js
  4. 0 0
      dist/showdown.min.js.map
  5. 1 1
      src/subParsers/hashHTMLBlocks.js
  6. 53 0
      test/cases/html5-strutural-tags.html
  7. 54 1
      test/cases/html5-strutural-tags.md

+ 1 - 1
dist/showdown.js

@@ -1020,7 +1020,7 @@ showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
    )						// attacklab: there are sentinel newlines at end of document
    /gm,function(){...}};
    */
-  text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,
+  text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside|address|audio|canvas|figure|hgroup|output|video)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,
                       showdown.subParser('hashElement')(text, options, globals));
 
   // Special case just for <hr />. It was easier to make a special case than

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.js.map


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.min.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/showdown.min.js.map


+ 1 - 1
src/subParsers/hashHTMLBlocks.js

@@ -63,7 +63,7 @@ showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
    )						// attacklab: there are sentinel newlines at end of document
    /gm,function(){...}};
    */
-  text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,
+  text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside|address|audio|canvas|figure|hgroup|output|video)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,
                       showdown.subParser('hashElement')(text, options, globals));
 
   // Special case just for <hr />. It was easier to make a special case than

+ 53 - 0
test/cases/html5-strutural-tags.html

@@ -20,3 +20,56 @@
 </aside>
 
 <p>the end</p>
+
+<table class="test">
+  <tr>
+    <td>Foo</td>
+  </tr>
+  <tr>
+    <td>Bar</td>
+  </tr>
+</table>
+
+<table class="test">
+  <thead>
+  <tr>
+    <td>Foo</td>
+  </tr>
+  </thead>
+  <tr>
+    <td>Bar</td>
+  </tr>
+  <tfoot>
+  <tr>
+    <td>Bar</td>
+  </tr>
+  </tfoot>
+</table>
+
+<audio class="podcastplayer" controls>
+  <source src="foobar.mp3" type="audio/mp3" preload="none"></source>
+  <source src="foobar.off" type="audio/ogg" preload="none"></source>
+</audio>
+
+<video src="foo.ogg">
+  <track kind="subtitles" src="foo.en.vtt" srclang="en" label="English">
+  <track kind="subtitles" src="foo.sv.vtt" srclang="sv" label="Svenska">
+</video>
+
+<address>My street</address>
+
+<canvas id="canvas" width="300" height="300">
+  Sorry, your browser doesn't support the &lt;canvas&gt; element.
+</canvas>
+
+<figure>
+  <img src="mypic.png" alt="An awesome picture">
+  <figcaption>Caption for the awesome picture</figcaption>
+</figure>
+
+<hgroup>
+  <h1>Main title</h1>
+  <h2>Secondary title</h2>
+</hgroup>
+
+<output name="result"></output>

+ 54 - 1
test/cases/html5-strutural-tags.md

@@ -13,4 +13,57 @@ me</article>
 ignore me
 </aside>
 
-the end
+the end
+
+<table class="test">
+    <tr>
+        <td>Foo</td>
+    </tr>
+    <tr>
+        <td>Bar</td>
+    </tr>
+</table>
+
+<table class="test">
+    <thead>
+        <tr>
+            <td>Foo</td>
+        </tr>
+    </thead>
+    <tr>
+        <td>Bar</td>
+    </tr>
+    <tfoot>
+        <tr>
+            <td>Bar</td>
+        </tr>
+    </tfoot>
+</table>
+
+<audio class="podcastplayer" controls>
+    <source src="foobar.mp3" type="audio/mp3" preload="none"></source>
+    <source src="foobar.off" type="audio/ogg" preload="none"></source>
+</audio>
+
+<video src="foo.ogg">
+    <track kind="subtitles" src="foo.en.vtt" srclang="en" label="English">
+    <track kind="subtitles" src="foo.sv.vtt" srclang="sv" label="Svenska">
+</video>
+
+<address>My street</address>
+
+<canvas id="canvas" width="300" height="300">
+    Sorry, your browser doesn't support the &lt;canvas&gt; element.
+</canvas>
+
+<figure>
+    <img src="mypic.png" alt="An awesome picture">
+    <figcaption>Caption for the awesome picture</figcaption>
+</figure>
+
+<hgroup>
+  <h1>Main title</h1>
+  <h2>Secondary title</h2>
+</hgroup>
+
+<output name="result"></output>

Някои файлове не бяха показани, защото твърде много файлове са промени