From 541b3eccb1cd8d850696ae537ce8d23d2355e9af Mon Sep 17 00:00:00 2001 From: Titus Date: Thu, 9 Aug 2012 20:06:58 -0600 Subject: [PATCH 01/19] Fixed #26 -- Urls which contained matched parenthesis are now supported --- src/showdown.js | 2 +- test/cases/url-with-parenthesis.html | 2 ++ test/cases/url-with-parenthesis.md | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/cases/url-with-parenthesis.html create mode 100644 test/cases/url-with-parenthesis.md diff --git a/src/showdown.js b/src/showdown.js index 869d753..73f4e68 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -483,7 +483,7 @@ var _DoAnchors = function(text) { ) /g,writeAnchorTag); */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag); + text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag); // // Last, handle reference-style shortcuts: [link text] diff --git a/test/cases/url-with-parenthesis.html b/test/cases/url-with-parenthesis.html new file mode 100644 index 0000000..d42cee8 --- /dev/null +++ b/test/cases/url-with-parenthesis.html @@ -0,0 +1,2 @@ + +

There's an episode of Star Trek: The Next Generation

\ No newline at end of file diff --git a/test/cases/url-with-parenthesis.md b/test/cases/url-with-parenthesis.md new file mode 100644 index 0000000..f271d26 --- /dev/null +++ b/test/cases/url-with-parenthesis.md @@ -0,0 +1,2 @@ + +There's an [episode](http://en.memory-alpha.org/wiki/Darmok_(episode)) of Star Trek: The Next Generation \ No newline at end of file From 90e51e95cc147bba9657e47a837b73ed7cfc8384 Mon Sep 17 00:00:00 2001 From: Titus Date: Sat, 11 Aug 2012 07:02:41 -0600 Subject: [PATCH 02/19] Added test for #25. Looks to be working. --- test/cases/github-style-linebreaks.html | 4 ++++ test/cases/github-style-linebreaks.md | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 test/cases/github-style-linebreaks.html create mode 100644 test/cases/github-style-linebreaks.md diff --git a/test/cases/github-style-linebreaks.html b/test/cases/github-style-linebreaks.html new file mode 100644 index 0000000..d8210a4 --- /dev/null +++ b/test/cases/github-style-linebreaks.html @@ -0,0 +1,4 @@ + +
code can go here
+this is rendered on a second line
+
\ No newline at end of file diff --git a/test/cases/github-style-linebreaks.md b/test/cases/github-style-linebreaks.md new file mode 100644 index 0000000..c176eab --- /dev/null +++ b/test/cases/github-style-linebreaks.md @@ -0,0 +1,4 @@ +``` +code can go here +this is rendered on a second line +``` \ No newline at end of file From 3b9b743f90d4c808f50b54e0c5d408a7ac050704 Mon Sep 17 00:00:00 2001 From: Corey Innis Date: Tue, 14 Aug 2012 17:34:40 -0700 Subject: [PATCH 03/19] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f1fd74b..8df5c56 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ - NOTE -- Showdown on GitHub ========================== -Please note that I, Corey, am not the author of Showdown. Rather, I found it +**Please note** that I, Corey, am not the author of Showdown. Rather, I found it some time back at (website removed, see: ) and wanted to see it available on GitHub. From 9b297fa8777158e90190fe04685bbf0b42b49ea2 Mon Sep 17 00:00:00 2001 From: unwiredben Date: Sat, 8 Sep 2012 14:17:52 -0500 Subject: [PATCH 04/19] Remove unnecessary "match anything" test that caused excessive run time on some mixed content Update HTML5 structural tags test to also verify correctness this regexp and the previous one. Signed-off-by: unwiredben --- src/showdown.js | 4 ++-- test/cases/html5-strutural-tags.html | 7 +++++-- test/cases/html5-strutural-tags.md | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/showdown.js b/src/showdown.js index 869d753..e2023fb 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -259,13 +259,13 @@ var _HashHTMLBlocks = function(text) { \b // word break // attacklab: hack around khtml/pcre bug... [^\r]*? // any number of lines, minimally matching - .* // the matching end tag + // the matching end tag [ \t]* // trailing spaces/tabs (?=\n+) // followed by a newline ) // 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,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 index b89207b..5dc9316 100644 --- a/test/cases/html5-strutural-tags.html +++ b/test/cases/html5-strutural-tags.html @@ -9,8 +9,11 @@ -
read me
+
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 index 15a9fbe..640c018 100644 --- a/test/cases/html5-strutural-tags.md +++ b/test/cases/html5-strutural-tags.md @@ -5,7 +5,10 @@ These HTML5 tags should pass through just fine.
head
footsies
-
read me
- +
read +me
+ the end \ No newline at end of file From 6645ca173bab62a7ec530a5626522426a8f98935 Mon Sep 17 00:00:00 2001 From: Adam Backstrom Date: Fri, 19 Oct 2012 11:55:49 -0400 Subject: [PATCH 05/19] Apply sentinel fixes to _StripLinkDefinitions --- src/showdown.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/showdown.js b/src/showdown.js index 869d753..508d2c5 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -184,7 +184,11 @@ var _StripLinkDefinitions = function(text) { /gm, function(){...}); */ - var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm, + + // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug + text += "~0"; + + var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm, function (wholeMatch,m1,m2,m3,m4) { m1 = m1.toLowerCase(); g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive @@ -201,6 +205,9 @@ var _StripLinkDefinitions = function(text) { } ); + // attacklab: strip sentinel + text = text.replace(/~0/,""); + return text; } From 57fa69eff528af92f540876acedef0a3e30440da Mon Sep 17 00:00:00 2001 From: Corey Innis Date: Tue, 30 Oct 2012 23:37:53 -0700 Subject: [PATCH 06/19] minor README cleanup --- README.md | 87 +++++++++++++++++++++++-------------------------------- 1 file changed, 37 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 50a55a2..04ce7a3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -NOTE -- Showdown on GitHub -========================== +# NOTE -- Showdown on GitHub **Please note** that I, Corey, am not the author of Showdown. Rather, I found it some time back at @@ -20,8 +19,7 @@ Cheers,
Corey -Showdown -- A JavaScript port of Markdown -========================================= +# Showdown -- A JavaScript port of Markdown Showdown Copyright (c) 2007 John Fraser. @@ -33,32 +31,29 @@ Redistributable under a BSD-style open source license. See license.txt for more information. -Quick Example -------------- +## Quick Example -``` js +```js var Showdown = require('showdown'); var converter = new Showdown.converter(); converter.makeHtml('#hello markdown!'); //

hello, markdown

- ``` -What's it for? --------------- +## What's it for? Developers can use Showdown to: - * Add in-browser preview to existing Markdown apps + * Add in-browser preview to existing Markdown apps Showdown's output is (almost always) identical to markdown.pl's, so the server can reproduce exactly the output that the user saw. (See below for exceptions.) - * Add Markdown input to programs that don't support it + * Add Markdown input to programs that don't support it Any app that accepts HTML input can now be made to speak Markdown by modifying the input pages's HTML. If your @@ -68,7 +63,7 @@ Developers can use Showdown to: uses -- and you can do it with just a two-line `onsubmit` function! - * Add Markdown input to closed-source web apps + * Add Markdown input to closed-source web apps You can write bookmarklets or userscripts to extend any standard textarea on the web so that it accepts @@ -76,7 +71,7 @@ Developers can use Showdown to: the same can probably be done with many rich edit controls. - * Build new web apps from scratch + * Build new web apps from scratch A Showdown front-end can send back text in Markdown, HTML or both, so you can trade bandwidth for server @@ -89,23 +84,21 @@ Developers can use Showdown to: Markdown.) -Browser Compatibility ---------------------- +## Browser Compatibility Showdown has been tested successfully with: - - Firefox 1.5 and 2.0 - - Internet Explorer 6 and 7 - - Safari 2.0.4 - - Opera 8.54 and 9.10 - - Netscape 8.1.2 - - Konqueror 3.5.4 + * Firefox 1.5 and 2.0 + * Internet Explorer 6 and 7 + * Safari 2.0.4 + * Opera 8.54 and 9.10 + * Netscape 8.1.2 + * Konqueror 3.5.4 In theory, Showdown will work in any browser that supports ECMA 262 3rd Edition (JavaScript 1.5). The converter itself might even work in things that aren't web browsers, like Acrobat. No promises. -Extensions ----------- +## Extensions Showdown allows additional functionality to be loaded via extensions. @@ -131,14 +124,11 @@ var converter = new Showdown().converter({ extensions: ['twitter', mine] }); ``` +## Known Differences in Output -Known Differences in Output ---------------------------- +In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. What follows is a list of all known deviations. Please file an issue if you find more. -In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. What follows is a list of all known deviations. Please email me if you find more. - - - * This release uses the HTML parser from Markdown 1.0.2b2, + * This release uses the HTML parser from Markdown 1.0.2b2, which means it fails `Inline HTML (Advanced).text` from the Markdown test suite: @@ -148,8 +138,7 @@ In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. - - * Showdown doesn't support the markdown="1" attribute: + * Showdown doesn't support the markdown="1" attribute:
Markdown does *not* work in here. @@ -162,7 +151,7 @@ In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. way to make markdown="1" the default. - * You can only nest square brackets in link titles to a + * You can only nest square brackets in link titles to a depth of two levels: [[fine]](http://www.attacklab.net/) @@ -171,7 +160,7 @@ In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. If you need more, you can escape them with backslashes. - * When sublists have paragraphs, Showdown produces equivalent + * When sublists have paragraphs, Showdown produces equivalent HTML with a slightly different arrangement of newlines: + item @@ -192,7 +181,7 @@ In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. - * Markdown.pl creates empty title attributes for + * Markdown.pl creates empty title attributes for inline-style images: Here's an empty title on an inline-style @@ -208,7 +197,7 @@ In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. [images]: http://w3.org/Icons/valid-xhtml10 - * With crazy input, Markdown will mistakenly put + * With crazy input, Markdown will mistakenly put `` or `` tags in URLs: @@ -218,8 +207,7 @@ In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. Showdown won't. But still, don't do that. -Tests ---------------------------- +## Tests A suite of tests is available which require node.js. Once node is installed, run the following command from the project root to install the development dependencies: npm install --dev @@ -231,21 +219,20 @@ Once installed the tests can be run from the project root using: New test cases can easily be added. Create a markdown file (ending in `.md`) which contains the markdown to test. Create a `.html` file of the exact same name. It will automatically be tested when the tests are executed with `mocha`. -Creating Markdown Extensions ----------------------------- +## Creating Markdown Extensions A showdown extension is simply a function which returns an array of extensions. Each single extension can be one of two types: - - Language Extension -- Language extensions are ones that that add new markdown syntax to showdown. For example, say you wanted `^^youtube http://www.youtube.com/watch?v=oHg5SJYRHA0` to automatically render as an embedded YouTube video, that would be a language extension. - - Output Modifiers -- After showdown has run, and generated HTML, an output modifier would change that HTML. For example, say you wanted to change `
` to be `
`, that would be an output modifier. + * Language Extension -- Language extensions are ones that that add new markdown syntax to showdown. For example, say you wanted `^^youtube http://www.youtube.com/watch?v=oHg5SJYRHA0` to automatically render as an embedded YouTube video, that would be a language extension. + * Output Modifiers -- After showdown has run, and generated HTML, an output modifier would change that HTML. For example, say you wanted to change `
` to be `
`, that would be an output modifier. Each extension can provide two combinations of interfaces for showdown. -#### Regex/Replace +### Regex/Replace -Regex/replace style extensions are very similar to javascripts `string.replace` function. Two properties are given, `regex` and `replace`. `regex` is a string and `replace` can be either a string or a function. If `replace` is a string, it can use the `$1` syntax for group substituation, exactly as if it were making use of `string.replace` (internally it does this actually); The value of `regex` is assumed to be a global replacement. +Regex/replace style extensions are very similar to javascripts `string.replace` function. Two properties are given, `regex` and `replace`. `regex` is a string and `replace` can be either a string or a function. If `replace` is a string, it can use the `$1` syntax for group substitution, exactly as if it were making use of `string.replace` (internally it does this actually); The value of `regex` is assumed to be a global replacement. -#### Regex/Replace Example +**Example:** ``` js var demo = function(converter) { @@ -256,11 +243,11 @@ var demo = function(converter) { } ``` -#### Filter +### Filter Alternately, if you'd just like to do everything yourself, you can specify a filter which is a callback with a single input parameter, text (the current source text within the showdown engine). -#### Filter Example +**Example:** ``` js var demo = function(converter) { @@ -273,9 +260,9 @@ var demo = function(converter) { } ``` -#### Implementation Concerns +### Implementation Concerns -One bit which should be taken into account is maintaining both client-side and server-side compatibility. This can be achieved with a few lines of boilerplate code. First, to prevent polluting the global scope for client-side code, the extension definition should be wrapped in a self executing function. +One bit which should be taken into account is maintaining both client-side and server-side compatibility. This can be achieved with a few lines of boilerplate code. First, to prevent polluting the global scope for client-side code, the extension definition should be wrapped in a self-executing function. ``` js (function(){ @@ -298,7 +285,7 @@ Second, client-side extensions should add a property onto `Showdown.extensions` }()); ``` -#### Testing Extensions +### Testing Extensions The showdown test runner is setup to automatically test cases for extensions. To add test cases for an extension, create a new folder under `./test/extensions` which matches the name of the `.js` file in `./src/extensions`. Place any test cases into the filder using the md/html format and they will automatically be run when tests are run. From bf120d1d6700d06236f567ade167bf6422fb0eed Mon Sep 17 00:00:00 2001 From: Corey Innis Date: Wed, 31 Oct 2012 00:05:51 -0700 Subject: [PATCH 07/19] update contribution note for stone (you rock!) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04ce7a3..e647453 100644 --- a/README.md +++ b/README.md @@ -310,5 +310,5 @@ Credits * [Cat Chen](https://github.com/CatChen):
Export fix * [Titus Stone](https://github.com/tstone):
- Mocha tests + bug fixes + Mocha tests, **extension mechanism**, and bug fixes From d46f5b5de39126b3cdc9074edb13c5e093ab1564 Mon Sep 17 00:00:00 2001 From: Corey Innis Date: Wed, 31 Oct 2012 00:07:31 -0700 Subject: [PATCH 08/19] regenerate compressed showdown.js --- compressed/showdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compressed/showdown.js b/compressed/showdown.js index 3f280f4..23a1024 100644 --- a/compressed/showdown.js +++ b/compressed/showdown.js @@ -59,4 +59,4 @@ // // Showdown namespace // -var Showdown={};Showdown.converter=function(){var a,b,c,d=0;this.makeHtml=function(d){return a=new Array,b=new Array,c=new Array,d=d.replace(/~/g,"~T"),d=d.replace(/\$/g,"~D"),d=d.replace(/\r\n/g,"\n"),d=d.replace(/\r/g,"\n"),d="\n\n"+d+"\n\n",d=F(d),d=d.replace(/^[ \t]+$/mg,""),d=f(d),d=e(d),d=h(d),d=D(d),d=d.replace(/~D/g,"$$"),d=d.replace(/~T/g,"~"),d};var e=function(c){var c=c.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(c,d,e,f,g){return d=d.toLowerCase(),a[d]=z(e),f?f+g:(g&&(b[d]=g.replace(/"/g,""")),"")});return c},f=function(a){a=a.replace(/\n/g,"\n\n");var b="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del",c="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";return a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,g),a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,g),a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,g),a=a.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,g),a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,g),a=a.replace(/\n\n/g,"\n"),a},g=function(a,b){var d=b;return d=d.replace(/\n\n/g,"\n"),d=d.replace(/^\n/,""),d=d.replace(/\n+$/g,""),d="\n\n~K"+(c.push(d)-1)+"K\n\n",d},h=function(a){a=o(a);var b=t("
");return a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,b),a=q(a),a=s(a),a=r(a),a=x(a),a=f(a),a=y(a),a},i=function(a){return a=u(a),a=j(a),a=A(a),a=m(a),a=k(a),a=B(a),a=z(a),a=w(a),a=a.replace(/ +\n/g,"
\n"),a},j=function(a){var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=G(b,"\\`*_"),b}),a},k=function(a){return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,l),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,l),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,l),a},l=function(c,d,e,f,g,h,i,j){j==undefined&&(j="");var k=d,l=e,m=f.toLowerCase(),n=g,o=j;if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(a[m]!=undefined)n=a[m],b[m]!=undefined&&(o=b[m]);else{if(!(k.search(/\(\s*\)$/m)>-1))return k;n=""}}n=G(n,"*_");var p='
",p},m=function(a){return a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,n),a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,n),a},n=function(c,d,e,f,g,h,i,j){var k=d,l=e,m=f.toLowerCase(),n=g,o=j;o||(o="");if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(a[m]==undefined)return k;n=a[m],b[m]!=undefined&&(o=b[m])}l=l.replace(/"/g,"""),n=G(n,"*_");var p=''+l+''+i(c)+"")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return t('

'+i(c)+"

")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,d){var e=c.length;return t("'+i(d)+"")}),a},p,q=function(a){a+="~0";var b=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return d?a=a.replace(b,function(a,b,c){var d=b,e=c.search(/[*+-]/g)>-1?"ul":"ol";d=d.replace(/\n{2,}/g,"\n\n\n");var f=p(d);return f=f.replace(/\s+$/,""),f="<"+e+">"+f+"\n",f}):(b=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(b,function(a,b,c,d){var e=b,f=c,g=d.search(/[*+-]/g)>-1?"ul":"ol",f=f.replace(/\n{2,}/g,"\n\n\n"),h=p(f);return h=e+"<"+g+">\n"+h+"\n",h})),a=a.replace(/~0/,""),a};p=function(a){return d++,a=a.replace(/\n{2,}$/,"\n"),a+="~0",a=a.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(a,b,c,d,e){var f=e,g=b,j=c;return g||f.search(/\n{2,}/)>-1?f=h(E(f)):(f=q(E(f)),f=f.replace(/\n$/,""),f=i(f)),"
  • "+f+"
  • \n"}),a=a.replace(/~0/g,""),d--,a};var r=function(a){return a+="~0",a=a.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(a,b,c){var d=b,e=c;return d=v(E(d)),d=F(d),d=d.replace(/^\n+/g,""),d=d.replace(/\n+$/g,""),d="
    "+d+"\n
    ",t(d)+e}),a=a.replace(/~0/,""),a},s=function(a){return a+="~0",a=a.replace(/\n```(.*)\n([^`]+)\n```/g,function(a,b,c){var d=b,e=c;return e=v(e),e=F(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e="
    "+e+"\n
    ",t(e)}),a=a.replace(/~0/,""),a},t=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(c.push(a)-1)+"K\n\n"},u=function(a){return a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,d,e){var f=d;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=v(f),b+""+f+""}),a},v=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=G(a,"*_{}[]\\",!1),a},w=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},x=function(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c=b;return c=c.replace(/^[ \t]*>[ \t]?/gm,"~0"),c=c.replace(/~0/g,""),c=c.replace(/^[ \t]+$/gm,""),c=h(c),c=c.replace(/(^|\n)/g,"$1 "),c=c.replace(/(\s*
    [^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^  /mg,"~0"),c=c.replace(/~0/g,""),c}),t("
    \n"+c+"\n
    ")}),a},y=function(a){a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");var b=a.split(/\n{2,}/g),d=new Array,e=b.length;for(var f=0;f=0?d.push(g):g.search(/\S/)>=0&&(g=i(g),g=g.replace(/^([ \t]*)/g,"

    "),g+="

    ",d.push(g))}e=d.length;for(var f=0;f=0){var h=c[RegExp.$1];h=h.replace(/\$/g,"$$$$"),d[f]=d[f].replace(/~K\d+K/,h)}return d.join("\n\n")},z=function(a){return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"),a=a.replace(/<(?![a-z\/?\$!])/gi,"<"),a},A=function(a){return a=a.replace(/\\(\\)/g,H),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,H),a},B=function(a){return a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'
    $1'),a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){return C(D(b))}),a},C=function(a){function b(a){var b="0123456789ABCDEF",c=a.charCodeAt(0);return b.charAt(c>>4)+b.charAt(c&15)}var c=[function(a){return"&#"+a.charCodeAt(0)+";"},function(a){return"&#x"+b(a)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if(a=="@")a=c[Math.floor(Math.random()*2)](a);else if(a!=":"){var b=Math.random();a=b>.9?c[2](a):b>.45?c[1](a):c[0](a)}return a}),a=''+a+"",a=a.replace(/">.+:/g,'">'),a},D=function(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)}),a},E=function(a){return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,""),a},F=function(a){return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b,c){var d=b,e=4-d.length%4;for(var f=0;f?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(a,d,e,f,g){return d=d.toLowerCase(),b[d]=F(e),f?f+g:(g&&(c[d]=g.replace(/"/g,""")),"")});return a},l=function(a){a=a.replace(/\n/g,"\n\n");var b="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",c="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside";return a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,m),a=a.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,m),a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,m),a=a.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,m),a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,m),a=a.replace(/\n\n/g,"\n"),a},m=function(a,b){var c=b;return c=c.replace(/\n\n/g,"\n"),c=c.replace(/^\n/,""),c=c.replace(/\n+$/g,""),c="\n\n~K"+(d.push(c)-1)+"K\n\n",c},n=function(a){a=u(a);var b=z("
    ");return a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,b),a=a.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,b),a=w(a),a=x(a),a=D(a),a=l(a),a=E(a),a},o=function(a){return a=A(a),a=p(a),a=G(a),a=s(a),a=q(a),a=H(a),a=F(a),a=C(a),a=a.replace(/ +\n/g,"
    \n"),a},p=function(a){var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=M(b,"\\`*_"),b}),a},q=function(a){return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,r),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,r),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,r),a},r=function(a,d,e,f,g,h,i,j){j==undefined&&(j="");var k=d,l=e,m=f.toLowerCase(),n=g,o=j;if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]!=undefined)n=b[m],c[m]!=undefined&&(o=c[m]);else{if(!(k.search(/\(\s*\)$/m)>-1))return k;n=""}}n=M(n,"*_");var p='",p},s=function(a){return a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,t),a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,t),a},t=function(a,d,e,f,g,h,i,j){var k=d,l=e,m=f.toLowerCase(),n=g,o=j;o||(o="");if(n==""){m==""&&(m=l.toLowerCase().replace(/ ?\n/g," ")),n="#"+m;if(b[m]==undefined)return k;n=b[m],c[m]!=undefined&&(o=c[m])}l=l.replace(/"/g,"""),n=M(n,"*_");var p=''+l+''+o(c)+"")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return z('

    '+o(c)+"

    ")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,d){var e=c.length;return z("'+o(d)+"")}),a},v,w=function(a){a+="~0";var b=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return e?a=a.replace(b,function(a,b,c){var d=b,e=c.search(/[*+-]/g)>-1?"ul":"ol";d=d.replace(/\n{2,}/g,"\n\n\n");var f=v(d);return f=f.replace(/\s+$/,""),f="<"+e+">"+f+"\n",f}):(b=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(b,function(a,b,c,d){var e=b,f=c,g=d.search(/[*+-]/g)>-1?"ul":"ol",f=f.replace(/\n{2,}/g,"\n\n\n"),h=v(f);return h=e+"<"+g+">\n"+h+"\n",h})),a=a.replace(/~0/,""),a};v=function(a){return e++,a=a.replace(/\n{2,}$/,"\n"),a+="~0",a=a.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(a,b,c,d,e){var f=e,g=b,h=c;return g||f.search(/\n{2,}/)>-1?f=n(K(f)):(f=w(K(f)),f=f.replace(/\n$/,""),f=o(f)),"
  • "+f+"
  • \n"}),a=a.replace(/~0/g,""),e--,a};var x=function(a){return a+="~0",a=a.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(a,b,c){var d=b,e=c;return d=B(K(d)),d=L(d),d=d.replace(/^\n+/g,""),d=d.replace(/\n+$/g,""),d="
    "+d+"\n
    ",z(d)+e}),a=a.replace(/~0/,""),a},y=function(a){return a+="~0",a=a.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(a,b,c){var d=b,e=c;return e=B(e),e=L(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e="
    "+e+"\n
    ",z(e)}),a=a.replace(/~0/,""),a},z=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(d.push(a)-1)+"K\n\n"},A=function(a){return a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,d,e){var f=d;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=B(f),b+""+f+""}),a},B=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=M(a,"*_{}[]\\",!1),a},C=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},D=function(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c=b;return c=c.replace(/^[ \t]*>[ \t]?/gm,"~0"),c=c.replace(/~0/g,""),c=c.replace(/^[ \t]+$/gm,""),c=n(c),c=c.replace(/(^|\n)/g,"$1 "),c=c.replace(/(\s*
    [^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^  /mg,"~0"),c=c.replace(/~0/g,""),c}),z("
    \n"+c+"\n
    ")}),a},E=function(a){a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");var b=a.split(/\n{2,}/g),c=[],e=b.length;for(var f=0;f=0?c.push(g):g.search(/\S/)>=0&&(g=o(g),g=g.replace(/^([ \t]*)/g,"

    "),g+="

    ",c.push(g))}e=c.length;for(var f=0;f=0){var h=d[RegExp.$1];h=h.replace(/\$/g,"$$$$"),c[f]=c[f].replace(/~K\d+K/,h)}return c.join("\n\n")},F=function(a){return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"),a=a.replace(/<(?![a-z\/?\$!])/gi,"<"),a},G=function(a){return a=a.replace(/\\(\\)/g,N),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,N),a},H=function(a){return a=a.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'
    $1'),a=a.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(a,b){return I(J(b))}),a},I=function(a){var b=[function(a){return"&#"+a.charCodeAt(0)+";"},function(a){return"&#x"+a.charCodeAt(0).toString(16)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if(a=="@")a=b[Math.floor(Math.random()*2)](a);else if(a!=":"){var c=Math.random();a=c>.9?b[2](a):c>.45?b[1](a):b[0](a)}return a}),a=''+a+"",a=a.replace(/">.+:/g,'">'),a},J=function(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)}),a},K=function(a){return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,""),a},L=function(a){return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b,c){var d=b,e=4-d.length%4;for(var f=0;f Date: Wed, 31 Oct 2012 00:32:30 -0700 Subject: [PATCH 09/19] post-merge (unwiredben) update html5 structural tests to be sure the previous test incarnations continued to work. --- test/cases/html5-strutural-tags.html | 4 ++++ test/cases/html5-strutural-tags.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/test/cases/html5-strutural-tags.html b/test/cases/html5-strutural-tags.html index 5dc9316..98698e8 100644 --- a/test/cases/html5-strutural-tags.html +++ b/test/cases/html5-strutural-tags.html @@ -9,6 +9,10 @@ +
    read me
    + + +
    read me
    diff --git a/test/cases/html5-strutural-tags.md b/test/cases/html5-strutural-tags.md index 640c018..5b27728 100644 --- a/test/cases/html5-strutural-tags.md +++ b/test/cases/html5-strutural-tags.md @@ -5,6 +5,8 @@ These HTML5 tags should pass through just fine.
    head
    footsies
    +
    read me
    +
    read me