From bab6b888efb0adb7c949334a39bbe3efc47b1ddc Mon Sep 17 00:00:00 2001 From: Titus Date: Thu, 14 Jun 2012 00:52:20 -0600 Subject: [PATCH] Added support for new HTML5 structural tags to "pass through" without being wrapped in a

--- src/showdown.js | 6 +++--- test/cases/html5-strutural-tags.html | 16 ++++++++++++++++ test/cases/html5-strutural-tags.md | 11 +++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 test/cases/html5-strutural-tags.html create mode 100644 test/cases/html5-strutural-tags.md diff --git a/src/showdown.js b/src/showdown.js index a5a88d0..612157f 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -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.: //

@@ -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
. It was easier to make a special case than // to make the other regex more complicated. diff --git a/test/cases/html5-strutural-tags.html b/test/cases/html5-strutural-tags.html new file mode 100644 index 0000000..b89207b --- /dev/null +++ b/test/cases/html5-strutural-tags.html @@ -0,0 +1,16 @@ + +

These HTML5 tags should pass through just fine.

+ +
hello
+ +
head
+ +
footsies
+ + + +
read me
+ + + +

the end

\ No newline at end of file diff --git a/test/cases/html5-strutural-tags.md b/test/cases/html5-strutural-tags.md new file mode 100644 index 0000000..15a9fbe --- /dev/null +++ b/test/cases/html5-strutural-tags.md @@ -0,0 +1,11 @@ + +These HTML5 tags should pass through just fine. + +
hello
+
head
+
footsies
+ +
read me
+ + +the end \ No newline at end of file