var foo = 'bar';
+
+ ```
+ Becomes this:
+ ```html
+ var foo = 'bar';
+ ```
+
+ * **noHeaderId**: (boolean) [default false] Disable the automatic generation of header ids. Setting to true overrides **prefixHeaderId**
+
+ * **prefixHeaderId**: (string/boolean) [default false] Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to `true` will add a generic 'section' prefix.
+
+ * **parseImgDimensions**: (boolean) [default false] Enable support for setting image dimensions from within markdown syntax.
+ Examples:
+ ```
+ ![foo](foo.jpg =100x80) simple, assumes units are in px
+ ![bar](bar.jpg =100x*) sets the height to "auto"
+ ![baz](baz.jpg =80%x5em) Image with width of 80% and height of 5em
+ ```
+
+ * **headerLevelStart**: (integer) [default 1] Set the header starting level. For instance, setting this to 3 means that
+
+ ```md
+ # foo
+ ```
+ will be parsed as
+
+ ```html
+ some text www.google.com
+ ```
+
+ * **literalMidWordUnderscores**: (boolean) [default false] Turning this on will stop showdown from interpreting underscores in the middle of words as `` and `` and instead treat them as literal underscores.
+
+ Example:
+
+ ```md
+ some text with__underscores__in middle
+ ```
+ will be parsed as
+ ```html
+ some text with__underscores__in middle "),g+=" s around
- # "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:
- my $block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/;
- my $block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/;
-
- # First, look for nested blocks, e.g.:
- # Just type tags
-#
- my $text = shift;
-
- # Strip leading and trailing lines:
- $text =~ s/\A\n+//;
- $text =~ s/\n+\z//;
-
- my @grafs = split(/\n{2,}/, $text);
-
- #
- # Wrap tags.
- #
- foreach (@grafs) {
- unless (defined( $g_html_blocks{$_} )) {
- $_ = _RunSpanGamut($_);
- s/^([ \t]*)/ /;
- $_ .= "strikethrough`
+
+ * **tables**: (boolean) [default false] Enable support for tables syntax. Example:
+
+ ```md
+ | h1 | h2 | h3 |
+ |:------|:-------:|--------:|
+ | 100 | [a][1] | ![b][2] |
+ | *foo* | **bar** | ~~baz~~ |
+ ```
+
+ See the wiki for more info
+
+ * **tablesHeaderId**: (boolean) [default false] If enabled adds an id property to table headers tags.
+
+ * **ghCodeBlocks**: (boolean) [default true] Enable support for GFM code block style.
+
+ * **tasklists**:(boolean) [default false] Enable support for GFM takslists. Example:
+
+ ```md
+ - [x] This task is done
+ - [ ] This is still pending
+ ```
+ * **smoothLivePreview**: (boolean) [default false] Prevents weird effects in live previews due to incomplete input
+
+## CLI Tool
+
+Showdown also comes bundled with a Command Line Interface tool. You can check the [CLI wiki page][cli-wiki] for more info
+
+## Integration with AngularJS
+
+ShowdownJS project also provides seamlessly integration with AngularJS via a "plugin".
+Please visit https://github.com/showdownjs/ngShowdown for more information.
+
+## Integration with TypeScript
+
+If you're using TypeScript you maybe want to use the types from [DefinitelyTyped][definitely-typed]
+
+## XSS vulnerability
+
+Showdown doesn't sanitize the input. This is by design since markdown relies on it to allow certain features to be correctly parsed into HTML.
+This, however, means XSS injection is quite possible.
+
+Please refer to the wiki article [Markdown's XSS Vulnerability (and how to mitigate it)][xss-wiki]
+for more information.
+
+## Extensions
+
+Showdown allows additional functionality to be loaded via extensions. (you can find a list of known showdown extensions [here][ext-wiki])
+
+### Client-side Extension Usage
+
+```js
+
+
+
+var converter = new showdown.Converter({ extensions: 'twitter' });
+```
+
+### Server-side Extension Usage
+
+```js
+var showdown = require('showdown'),
+ myExtension = require('myExtension'),
+ converter = new showdown.Converter({ extensions: ['myExtension'] });
+```
+
+## 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 dependencies:
+
+ npm install
+
+Once installed the tests can be run from the project root using:
+
+ npm test
+
+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`.
+
+## Contributing
+
+If you wish to contribute please read the following quick guide.
+
+### Want a Feature?
+You can request a new feature by submitting an issue. If you would like to implement a new feature feel free to issue a
+Pull Request.
+
+
+### Pull requests (PRs)
+PRs are awesome. However, before you submit your pull request consider the following guidelines:
+
+ - Search GitHub for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort.
+ - When issuing PRs that change code, make your changes in a new git branch based on master:
+
+ ```bash
+ git checkout -b my-fix-branch master
+ ```
+
+ - Documentation (i.e: README.md) changes can be made directly against master.
+ - Run the full test suite before submitting and make sure all tests pass (obviously =P).
+ - Try to follow our [**coding style rules**][coding-rules].
+ Breaking them prevents the PR to pass the tests.
+ - Refrain from fixing multiple issues in the same pull request. It's preferable to open multiple small PRs instead of one
+ hard to review big one.
+ - If the PR introduces a new feature or fixes an issue, please add the appropriate test case.
+ - We use commit notes to generate the changelog. It's extremely helpful if your commit messages adhere to the
+ [**AngularJS Git Commit Guidelines**][ng-commit-guide].
+ - If we suggest changes then:
+ - Make the required updates.
+ - Re-run the Angular test suite to ensure tests are still passing.
+ - Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
+
+ ```bash
+ git rebase master -i
+ git push origin my-fix-branch -f
+ ```
+ - After your pull request is merged, you can safely delete your branch.
+
+If you have time to contribute to this project, we feel obliged that you get credit for it.
+These rules enable us to review your PR faster and will give you appropriate credit in your GitHub profile.
+We thank you in advance for your contribution!
+
+### Joining the team
+We're looking for members to help maintaining Showdown.
+Please see [this issue](https://github.com/showdownjs/showdown/issues/114) to express interest or comment on this note.
+
+## Credits
+Full credit list at https://github.com/showdownjs/showdown/blob/master/CREDITS.md
+
+Showdown is powered by:
+[![webstorm](https://www.jetbrains.com/webstorm/documentation/docs/logo_webstorm.png)](https://www.jetbrains.com/webstorm/)
+
+
+
+[sd-logo]: https://raw.githubusercontent.com/showdownjs/logo/master/dist/logo.readme.png
+[legacy-branch]: https://github.com/showdownjs/showdown/tree/legacy
+[releases]: https://github.com/showdownjs/showdown/releases
+[changelog]: https://github.com/showdownjs/showdown/blob/master/CHANGELOG.md
+[wiki]: https://github.com/showdownjs/showdown/wiki
+[cli-wiki]: https://github.com/showdownjs/showdown/wiki/CLI-tool
+[definitely-typed]: https://github.com/borisyankov/DefinitelyTyped/tree/master/showdown
+[xss-wiki]: https://github.com/showdownjs/showdown/wiki/Markdown's-XSS-Vulnerability-(and-how-to-mitigate-it)
+[ext-wiki]: https://github.com/showdownjs/showdown/wiki/extensions
+[coding-rules]: https://github.com/showdownjs/code-style/blob/master/README.md
+[ng-commit-guide]: https://github.com/showdownjs/code-style/blob/master/README.md#commit-message-convention
diff --git a/bin/showdown.js b/bin/showdown.js
new file mode 100644
index 0000000..4bacdaa
Binary files /dev/null and b/bin/showdown.js differ
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..f6a6f22
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,33 @@
+{
+ "name": "showdown",
+ "description": "A Markdown to HTML converter written in Javascript",
+ "homepage": "https://github.com/showdownjs/showdown",
+ "authors": [
+ "Estevão Santos (https://github.com/tivie)",
+ "Pascal Deschênes (https://github.com/pdeschen)"
+ ],
+ "main": ["dist/showdown.js"],
+ "ignore": [
+ ".editorconfig",
+ ".gitattributes",
+ ".gitignore",
+ ".jscs.json",
+ ".jshintignore",
+ ".jshintrc",
+ ".travis.yml",
+ "Gruntfile.js",
+ "package.json",
+ "src/*",
+ "test/*"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/showdownjs/showdown.git"
+ },
+ "keywords": [
+ "markdown",
+ "md",
+ "mdown"
+ ],
+ "license": "https://github.com/showdownjs/showdown/blob/master/license.txt"
+}
diff --git a/compressed/extensions/github.js b/compressed/extensions/github.js
deleted file mode 100644
index bec428e..0000000
--- a/compressed/extensions/github.js
+++ /dev/null
@@ -1,5 +0,0 @@
-//
-// Github Extension (WIP)
-// ~~strike-through~~ -> strike-through
-//
-(function(){var a=function(a){return[{type:"lang",regex:"(~T){2}([^~]+)(~T){2}",replace:function(a,b,c,d){return""+c+""}}]};typeof window!="undefined"&&window.Showdown&&window.Showdown.extensions&&(window.Showdown.extensions.github=a),typeof module!="undefined"&&(module.exports=a)})();
\ No newline at end of file
diff --git a/compressed/extensions/prettify.js b/compressed/extensions/prettify.js
deleted file mode 100644
index e3b6a0c..0000000
--- a/compressed/extensions/prettify.js
+++ /dev/null
@@ -1,6 +0,0 @@
-//
-// Google Prettify
-// A showdown extension to add Google Prettify (http://code.google.com/p/google-code-prettify/)
-// hints to showdown's HTML output.
-//
-(function(){var a=function(a){return[{type:"output",filter:function(a){return a.replace(/()?
/gi,function(a,b){return b?'
':'
'})}}]};typeof window!="undefined"&&window.Showdown&&window.Showdown.extensions&&(window.Showdown.extensions.prettify=a),typeof module!="undefined"&&(module.exports=a)})();
\ No newline at end of file
diff --git a/compressed/extensions/table.js b/compressed/extensions/table.js
deleted file mode 100644
index da75bf7..0000000
--- a/compressed/extensions/table.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/*global module:true*//*
- * Basic table support with re-entrant parsing, where cell content
- * can also specify markdown.
- *
- * Tables
- * ======
- *
- * | Col 1 | Col 2 |
- * |======== |====================================================|
- * |**bold** | ![Valid XHTML] (http://w3.org/Icons/valid-xhtml10) |
- * | Plain | Value |
- *
- */(function(){var a=function(a){var b={},c="text-align:left;",d;return b.th=function(a){if(a.trim()==="")return"";var b=a.trim().replace(/ /g,"_").toLowerCase();return'
'+a+" "},b.td=function(b){return''+a.makeHtml(b)+" "},b.ths=function(){var a="",c=0,d=[].slice.apply(arguments);for(c;c\n",a+=b.tds.apply(this,d),a+=" \n",a},d=function(a){var c=0,d=a.split("\n"),e=[],f,g,h,i=[];for(c;c
");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=x(a),a=y(a),a=E(a),a=m(a),a=F(a),a},p=function(a){return a=B(a),a=q(a),a=H(a),a=t(a),a=r(a),a=I(a),a=G(a),a=D(a),a=a.replace(/ +\n/g,"
\n"),a},q=function(a){var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=N(b,"\\`*_"),b}),a},r=function(a){return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,s),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,s),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,s),a},s=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=N(n,"*_");var p='"+l+"",p},t=function(a){return a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,u),a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,u),a},u=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=N(n,"*_");var p='",p},v=function(a){function b(a){return a.replace(/[^\w]/g,"").toLowerCase()}return a=a.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(a,c){return A(''+p(c)+"
")}),a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,c){return A(''+p(c)+"
")}),a=a.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(a,c,d){var e=c.length;return A("
",A(d)+e}),a=a.replace(/~0/,""),a},z=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=C(e),e=M(e),e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,""),e=""+d+"\n
",A(e)}),a=a.replace(/~0/,""),a},A=function(a){return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(d.push(a)-1)+"K\n\n"},B=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=C(f),b+""+e+"\n
"+f+"
"}),a},C=function(a){return a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=N(a,"*_{}[]\\",!1),a},D=function(a){return a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"$2"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"$2"),a},E=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=o(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}),A("
\n"+c+"\n
")}),a},F=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
. It was easier to make a special case than
- # to make the other regex more complicated.
- $text =~ s{
- (?:
- (?<=\n\n) # Starting after a blank line
- | # or
- \A\n? # the beginning of the doc
- )
- ( # save in $1
- [ ]{0,$less_than_tab}
- <(hr) # start tag = $2
- \b # word break
- ([^<>])*? #
- /?> # the matching end tag
- [ \t]*
- (?=\n{2,}|\Z) # followed by a blank line or end of document
- )
- }{
- my $key = md5_hex($1);
- $g_html_blocks{$key} = $1;
- "\n\n" . $key . "\n\n";
- }egx;
-
- # Special case for standalone HTML comments:
- $text =~ s{
- (?:
- (?<=\n\n) # Starting after a blank line
- | # or
- \A\n? # the beginning of the doc
- )
- ( # save in $1
- [ ]{0,$less_than_tab}
- (?s:
-
- )
- [ \t]*
- (?=\n{2,}|\Z) # followed by a blank line or end of document
- )
- }{
- my $key = md5_hex($1);
- $g_html_blocks{$key} = $1;
- "\n\n" . $key . "\n\n";
- }egx;
-
-
- return $text;
-}
-
-
-sub _RunBlockGamut {
-#
-# These are all the transformations that form block-level
-# tags like paragraphs, headers, and list items.
-#
- my $text = shift;
-
- $text = _DoHeaders($text);
-
- # Do Horizontal Rules:
- $text =~ s{^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$}{\n
tags around block-level tags.
- $text = _HashHTMLBlocks($text);
- $text = _FormParagraphs($text);
-
- return $text;
-}
-
-
-sub _RunSpanGamut {
-#
-# These are all the transformations that occur *within* block-level
-# tags like paragraphs, headers, and list items.
-#
- my $text = shift;
-
- $text = _EscapeSpecialCharsWithinTagAttributes($text);
- $text = _DoCodeSpans($text);
- $text = _EncodeBackslashEscapes($text);
-
- # Process anchor and image tags. Images must come first,
- # because ![foo][f] looks like an anchor.
- $text = _DoImages($text);
- $text = _DoAnchors($text);
-
- # Make links out of things like `
-- encode [\ ` * _] so they
-# don't conflict with their use in Markdown for code, italics and strong.
-# We're replacing each such character with its corresponding MD5 checksum
-# value; this is likely overkill, but it should prevent us from colliding
-# with the escape values by accident.
-#
- my $text = shift;
- my $tokens ||= _TokenizeHTML($text);
- $text = ''; # rebuild $text from the tokens
-
- foreach my $cur_token (@$tokens) {
- if ($cur_token->[0] eq "tag") {
- $cur_token->[1] =~ s! \\ !$g_escape_table{'\\'}!gx;
- $cur_token->[1] =~ s! ` !$g_escape_table{'`'}!gx;
- $cur_token->[1] =~ s! \* !$g_escape_table{'*'}!gx;
- $cur_token->[1] =~ s! _ !$g_escape_table{'_'}!gx;
- }
- $text .= $cur_token->[1];
- }
- return $text;
-}
-
-
-sub _DoAnchors {
-#
-# Turn Markdown link shortcuts into XHTML tags.
-#
- my $text = shift;
-
- #
- # First, handle reference-style links: [link text] [id]
- #
- $text =~ s{
- ( # wrap whole match in $1
- \[
- ($g_nested_brackets) # link text = $2
- \]
-
- [ ]? # one optional space
- (?:\n[ ]*)? # one optional newline followed by spaces
-
- \[
- (.*?) # id = $3
- \]
- )
- }{
- my $result;
- my $whole_match = $1;
- my $link_text = $2;
- my $link_id = lc $3;
-
- if ($link_id eq "") {
- $link_id = lc $link_text; # for shortcut links like [this][].
- }
-
- if (defined $g_urls{$link_id}) {
- my $url = $g_urls{$link_id};
- $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
- $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
- $result = "? # href = $3
- [ \t]*
- ( # $4
- (['"]) # quote char = $5
- (.*?) # Title = $6
- \5 # matching quote
- )? # title is optional
- \)
- )
- }{
- my $result;
- my $whole_match = $1;
- my $link_text = $2;
- my $url = $3;
- my $title = $6;
-
- $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
- $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
- $result = " tags.
-#
- my $text = shift;
-
- #
- # First, handle reference-style labeled images: ![alt text][id]
- #
- $text =~ s{
- ( # wrap whole match in $1
- !\[
- (.*?) # alt text = $2
- \]
-
- [ ]? # one optional space
- (?:\n[ ]*)? # one optional newline followed by spaces
-
- \[
- (.*?) # id = $3
- \]
-
- )
- }{
- my $result;
- my $whole_match = $1;
- my $alt_text = $2;
- my $link_id = lc $3;
-
- if ($link_id eq "") {
- $link_id = lc $alt_text; # for shortcut links like ![this][].
- }
-
- $alt_text =~ s/"/"/g;
- if (defined $g_urls{$link_id}) {
- my $url = $g_urls{$link_id};
- $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
- $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
- $result = "? # src url = $3
- [ \t]*
- ( # $4
- (['"]) # quote char = $5
- (.*?) # title = $6
- \5 # matching quote
- [ \t]*
- )? # title is optional
- \)
- )
- }{
- my $result;
- my $whole_match = $1;
- my $alt_text = $2;
- my $url = $3;
- my $title = '';
- if (defined($6)) {
- $title = $6;
- }
-
- $alt_text =~ s/"/"/g;
- $title =~ s/"/"/g;
- $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
- $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
- $result = "" . _RunSpanGamut($1) . "\n\n";
- }egmx;
-
- $text =~ s{ ^(.+)[ \t]*\n-+[ \t]*\n+ }{
- "" . _RunSpanGamut($1) . "
\n\n";
- }egmx;
-
-
- # atx-style headers:
- # # Header 1
- # ## Header 2
- # ## Header 2 with closing hashes ##
- # ...
- # ###### Header 6
- #
- $text =~ s{
- ^(\#{1,6}) # $1 = string of #'s
- [ \t]*
- (.+?) # $2 = Header text
- [ \t]*
- \#* # optional closing #'s (not counted)
- \n+
- }{
- my $h_level = length($1);
- "` blocks.
-#
-
- my $text = shift;
-
- $text =~ s{
- (?:\n\n|\A)
- ( # $1 = the code block -- one or more lines, starting with a space/tab
- (?:
- (?:[ ]{$g_tab_width} | \t) # Lines must start with a tab or a tab-width of spaces
- .*\n+
- )+
- )
- ((?=^[ ]{0,$g_tab_width}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
- }{
- my $codeblock = $1;
- my $result; # return value
-
- $codeblock = _EncodeCode(_Outdent($codeblock));
- $codeblock = _Detab($codeblock);
- $codeblock =~ s/\A\n+//; # trim leading newlines
- $codeblock =~ s/\s+\z//; # trim trailing whitespace
-
- $result = "\n\n
";
- @egsx;
-
- return $text;
-}
-
-
-sub _EncodeCode {
-#
-# Encode/escape certain characters inside Markdown code runs.
-# The point is that in code, these characters are literals,
-# and lose their special Markdown meanings.
-#
- local $_ = shift;
-
- # Encode all ampersands; HTML entities are not
- # entities within a Markdown code span.
- s/&/&/g;
-
- # Encode $'s, but only if we're running under Blosxom.
- # (Blosxom interpolates Perl variables in article bodies.)
- {
- no warnings 'once';
- if (defined($blosxom::version)) {
- s/\$/$/g;
- }
- }
-
-
- # Do the angle bracket song and dance:
- s! < !<!gx;
- s! > !>!gx;
-
- # Now, escape characters that are magic in Markdown:
- s! \* !$g_escape_table{'*'}!gx;
- s! _ !$g_escape_table{'_'}!gx;
- s! { !$g_escape_table{'{'}!gx;
- s! } !$g_escape_table{'}'}!gx;
- s! \[ !$g_escape_table{'['}!gx;
- s! \] !$g_escape_table{']'}!gx;
- s! \\ !$g_escape_table{'\\'}!gx;
-
- return $_;
-}
-
-
-sub _DoItalicsAndBold {
- my $text = shift;
-
- # must go first:
- $text =~ s{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 }
- {$2}gsx;
-
- $text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 }
- {$2}gsx;
-
- return $text;
-}
-
-
-sub _DoBlockQuotes {
- my $text = shift;
-
- $text =~ s{
- ( # Wrap whole match in $1
- (
- ^[ \t]*>[ \t]? # '>' at the start of a line
- .+\n # rest of the first line
- (.+\n)* # subsequent consecutive lines
- \n* # blanks
- )+
- )
- }{
- my $bq = $1;
- $bq =~ s/^[ \t]*>[ \t]?//gm; # trim one level of quoting
- $bq =~ s/^[ \t]+$//mg; # trim whitespace-only lines
- $bq = _RunBlockGamut($bq); # recurse
-
- $bq =~ s/^/ /g;
- # These leading spaces screw with
\n\n";
-
- $result;
- }egmx;
-
- return $text;
-}
-
-
-sub _DoCodeSpans {
-#
-# * Backtick quotes are used for " . $codeblock . "\n
spans.
-#
-# * You can use multiple backticks as the delimiters if you want to
-# include literal backticks in the code span. So, this input:
-#
-# Just type ``foo `bar` baz`` at the prompt.
-#
-# Will translate to:
-#
-#
foo `bar` baz
at the prompt.`bar`
...
-#
-
- my $text = shift;
-
- $text =~ s@
- (?$c content, so we need to fix that:
- $bq =~ s{
- (\s*
.+?
)
- }{
- my $pre = $1;
- $pre =~ s/^ //mg;
- $pre;
- }egsx;
-
- "\n$bq\n
\n\n";
- }egmx;
-
-
- return $text;
-}
-
-
-sub _FormParagraphs {
-#
-# Params:
-# $text - string to process with html