diff --git a/lib/markdown.js b/lib/markdown.js
index c31bbe0d..b9bcfd3f 100644
--- a/lib/markdown.js
+++ b/lib/markdown.js
@@ -310,6 +310,11 @@ Markdown.dialects = {};
**/
Markdown.dialects.Gruber = {
block: {
+ htmlBlock: function htmlBlock( block, next ) {
+ if ( block.match( /^<\w/ ) && block.match( /\/>\s*$|<\/\s*\w+\s*>\s*$/ ) )
+ return [["__RAW", block.toString()]];
+ },
+
atxHeader: function atxHeader( block, next ) {
var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ );
@@ -1445,6 +1450,10 @@ function render_tree( jsonml ) {
return escapeHTML( jsonml );
}
+ if ( jsonml[0] == "__RAW" ) {
+ return jsonml[1];
+ }
+
var tag = jsonml.shift(),
attributes = {},
content = [];
diff --git a/test/features.t.js b/test/features.t.js
index 5d6c969f..0dbe2753 100644
--- a/test/features.t.js
+++ b/test/features.t.js
@@ -63,6 +63,7 @@ dialects.Gruber = [
"emphasis",
"headers",
"horizontal_rules",
+ "html_blocks",
"images",
"linebreaks",
"links",
diff --git a/test/features/code/html_block.json b/test/features/code/html_block.json
new file mode 100644
index 00000000..7af0872a
--- /dev/null
+++ b/test/features/code/html_block.json
@@ -0,0 +1,8 @@
+["html",
+ ["p", "This should not render as a block since it's indented (code):"],
+ ["pre",
+ ["code",
+ "
This should be escaped as HTML code.
"
+ ]
+ ]
+]
diff --git a/test/features/code/html_block.text b/test/features/code/html_block.text
new file mode 100644
index 00000000..9b8c13d6
--- /dev/null
+++ b/test/features/code/html_block.text
@@ -0,0 +1,3 @@
+This should not render as a block since it's indented (code):
+
+ This should be escaped as HTML code.
diff --git a/test/features/html_blocks/embedded_markdown.json b/test/features/html_blocks/embedded_markdown.json
new file mode 100644
index 00000000..70299efe
--- /dev/null
+++ b/test/features/html_blocks/embedded_markdown.json
@@ -0,0 +1,5 @@
+["html",
+ ["__RAW",
+ "**Embedded Markdown** is *not* supported.
"
+ ]
+]
diff --git a/test/features/html_blocks/embedded_markdown.text b/test/features/html_blocks/embedded_markdown.text
new file mode 100644
index 00000000..d5b50759
--- /dev/null
+++ b/test/features/html_blocks/embedded_markdown.text
@@ -0,0 +1 @@
+**Embedded Markdown** is *not* supported.
diff --git a/test/features/html_blocks/html_block.json b/test/features/html_blocks/html_block.json
new file mode 100644
index 00000000..3661a156
--- /dev/null
+++ b/test/features/html_blocks/html_block.json
@@ -0,0 +1,6 @@
+["html",
+ ["p", "The following is an HTML block:"],
+ ["__RAW",
+ "I am an HTML block.
"
+ ]
+]
diff --git a/test/features/html_blocks/html_block.text b/test/features/html_blocks/html_block.text
new file mode 100644
index 00000000..f749633e
--- /dev/null
+++ b/test/features/html_blocks/html_block.text
@@ -0,0 +1,3 @@
+The following is an HTML block:
+
+I am an HTML block.
diff --git a/test/features/html_blocks/self_closing.json b/test/features/html_blocks/self_closing.json
new file mode 100644
index 00000000..2fbd1fe2
--- /dev/null
+++ b/test/features/html_blocks/self_closing.json
@@ -0,0 +1,6 @@
+["html",
+ ["p", "The following is a self-closing HTML block:"],
+ ["__RAW",
+ "
"
+ ]
+]
diff --git a/test/features/html_blocks/self_closing.text b/test/features/html_blocks/self_closing.text
new file mode 100644
index 00000000..c5fbb7ad
--- /dev/null
+++ b/test/features/html_blocks/self_closing.text
@@ -0,0 +1,3 @@
+The following is a self-closing HTML block:
+
+