(text)
| 969 | } |
| 970 | |
| 971 | var _DoCodeBlocks = function(text) { |
| 972 | // |
| 973 | // Process Markdown `<pre><code>` blocks. |
| 974 | // |
| 975 | |
| 976 | // |
| 977 | // mk2: support code block |
| 978 | // ```javascript |
| 979 | // console.log('markdown'); |
| 980 | // ``` |
| 981 | text = text.replace(/```(\w+)?\n*((.|\n)*?)```/g, |
| 982 | function (wholeMatch, lang, codeblock) { |
| 983 | lang = lang ? 'lang-' + lang : ''; |
| 984 | |
| 985 | // codeblock = _EncodeCode(codeblock).replace(/^\s+|\s+$/g,""); |
| 986 | codeblock = "<pre class=\"prettyprint " + lang + "\"><code>" + codeblock + "</code></pre>"; |
| 987 | return hashBlock(codeblock); |
| 988 | } |
| 989 | ); |
| 990 | |
| 991 | /* |
| 992 | text = text.replace(text, |
| 993 | /(?:\n\n|^) |
| 994 | ( // $1 = the code block -- one or more lines, starting with a space/tab |
| 995 | (?: |
| 996 | (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width |
| 997 | .*\n+ |
| 998 | )+ |
| 999 | ) |
| 1000 | (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width |
| 1001 | /g,function(){...}); |
| 1002 | */ |
| 1003 | |
| 1004 | // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug |
| 1005 | text += "~0"; |
| 1006 | |
| 1007 | text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g, |
| 1008 | function (wholeMatch,m1,m2) { |
| 1009 | var codeblock = m1; |
| 1010 | var nextChar = m2; |
| 1011 | |
| 1012 | codeblock = _EncodeCode( _Outdent(codeblock)); |
| 1013 | |
| 1014 | codeblock = _Detab(codeblock); |
| 1015 | codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines |
| 1016 | codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace |
| 1017 | |
| 1018 | codeblock = "<pre class=\"prettyprint\"><code>" + codeblock + "\n</code></pre>"; |
| 1019 | return hashBlock(codeblock) + nextChar; |
| 1020 | } |
| 1021 | ); |
| 1022 | |
| 1023 | // attacklab: strip sentinel |
| 1024 | text = text.replace(/~0/,""); |
| 1025 | |
| 1026 | return text; |
| 1027 | } |
| 1028 |
no test coverage detected