Permalink
Browse files

Added support for new HTML5 structural tags to "pass through" without…

… being wrapped in a <p>
  • Loading branch information...
1 parent c2e28da commit bab6b888efb0adb7c949334a39bbe3efc47b1ddc @tstone tstone committed Jun 14, 2012
Showing with 30 additions and 3 deletions.
  1. +3 −3 src/showdown.js
  2. +16 −0 test/cases/html5-strutural-tags.html
  3. +11 −0 test/cases/html5-strutural-tags.md
View
@@ -215,8 +215,8 @@ var _HashHTMLBlocks = function(text) {
// "paragraphs" that are wrapped in non-block-level tags, such as anchors,
// phrase emphasis, and spans. The list of tags we're looking for is
// hard-coded:
- var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style";
- var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style";
+ var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|style|section|header|footer|nav|article|aside";
+ var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside";
// First, look for nested blocks, e.g.:
// <div>
@@ -265,7 +265,7 @@ var _HashHTMLBlocks = function(text) {
) // 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)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);
+ 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,hashElement);
// Special case just for <hr />. It was easier to make a special case than
// to make the other regex more complicated.
@@ -0,0 +1,16 @@
+
+<p>These HTML5 tags should pass through just fine.</p>
+
+<section>hello</section>
+
+<header>head</header>
+
+<footer>footsies</footer>
+
+<nav>navigation</nav>
+
+<article>read me</article>
+
+<aside>ignore me</aside>
+
+<p>the end</p>
@@ -0,0 +1,11 @@
+
+These HTML5 tags should pass through just fine.
+
+<section>hello</section>
+<header>head</header>
+<footer>footsies</footer>
+<nav>navigation</nav>
+<article>read me</article>
+<aside>ignore me</aside>
+
+the end

0 comments on commit bab6b88

Please sign in to comment.