remove toplevel html block check, change language class

This commit is contained in:
Christopher Jeffrey 2012-01-04 00:54:45 -06:00
parent e207549e9d
commit 60de96800e
3 changed files with 13 additions and 16 deletions

View File

@ -23,17 +23,6 @@ var block = {
paragraph: /^/
};
block.html = (function() {
var elements = '' // from: github.com/Kroc/ReMarkable
+ '(article|aside|audio|blockquote|canvas|caption|col|colgroup|dialog|div'
+ '|d[ltd]|embed|fieldset|figure|figcaption|footer|form|h[1-6r]|header'
+ '|hgroup|input|label|legend|li|nav|noscript|object|[ou]l|optgroup|option'
+ '|p|param|pre|script|section|select|source|table|t(?:body|foot|head)'
+ '|t[dhr]|textarea|video)';
return new RegExp(block.html.source.replace('(\\w+)', elements));
})();
block.paragraph = (function() {
var body = [];
@ -41,7 +30,7 @@ block.paragraph = (function() {
// immediately follow a line of text on the top level.
// everything below conforms to markdown.pl.
(function push(rule) {
rule = block[rule].source.replace('\\1', '\\w+');
rule = rule.source || block[rule].source;
body.push(rule.replace(/(^|[^\[])\^/g, '$1'));
return push;
})
@ -52,7 +41,15 @@ block.paragraph = (function() {
('lheading')
('blockquote')
// no list
('html');
// html - stop before block-level elements only
// from: github.com/Kroc/ReMarkable
(new RegExp('<'
+ '(?:article|aside|audio|blockquote|canvas|caption|col|colgroup|dialog|div'
+ '|d[ltd]|embed|fieldset|figure|figcaption|footer|form|h[1-6r]|header'
+ '|hgroup|input|label|legend|li|nav|noscript|object|[ou]l|optgroup|option'
+ '|p|param|pre|script|section|select|source|table|t(?:body|foot|head)'
+ '|t[dhr]|textarea|video)'));
body = body.join('|');
@ -493,7 +490,7 @@ var tok = function() {
case 'code': {
return '<pre><code'
+ (token.lang
? ' class="lang-'
? ' class="'
+ token.lang
+ '"'
: '')

View File

@ -1,3 +1,3 @@
<pre><code class="lang-js">var a = &apos;hello&apos;;
<pre><code class="js">var a = &apos;hello&apos;;
console.log(a + &apos; world&apos;);
</code></pre>

View File

@ -1,3 +1,3 @@
<pre><code class="lang-js">var a = &apos;hello&apos;;
<pre><code class="js">var a = &apos;hello&apos;;
console.log(a + &apos; world&apos;);
</code></pre>