├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bin └── marked ├── index.js ├── lib └── marked.js ├── man └── marked.1 ├── package.json └── test ├── README ├── browser ├── index.html ├── index.js └── test.js ├── index.js ├── new ├── autolink_lines.html ├── autolink_lines.text ├── blockquote_list_item.html ├── blockquote_list_item.text ├── case_insensitive_refs.html ├── case_insensitive_refs.text ├── def_blocks.html ├── def_blocks.text ├── double_link.html ├── double_link.text ├── escaped_angles.html ├── escaped_angles.text ├── gfm_break.html ├── gfm_break.text ├── gfm_code.html ├── gfm_code.text ├── gfm_code_hr_list.html ├── gfm_code_hr_list.text ├── gfm_del.html ├── gfm_del.text ├── gfm_em.html ├── gfm_em.text ├── gfm_links.html ├── gfm_links.text ├── gfm_tables.html ├── gfm_tables.text ├── hr_list_break.html ├── hr_list_break.text ├── lazy_blockquotes.html ├── lazy_blockquotes.text ├── list_item_text.html ├── list_item_text.text ├── loose_lists.html ├── loose_lists.text ├── main.html ├── main.text ├── nested_code.html ├── nested_code.text ├── nested_em.html ├── nested_em.text ├── nested_square_link.html ├── nested_square_link.text ├── not_a_link.html ├── not_a_link.text ├── ref_paren.html ├── ref_paren.text ├── same_bullet.html ├── same_bullet.text ├── text.smartypants.html ├── text.smartypants.text ├── toplevel_paragraphs.html ├── toplevel_paragraphs.text ├── tricky_list.html └── tricky_list.text ├── original ├── amps_and_angles_encoding.html ├── amps_and_angles_encoding.text ├── auto_links.html ├── auto_links.text ├── backslash_escapes.html ├── backslash_escapes.text ├── blockquotes_with_code_blocks.html ├── blockquotes_with_code_blocks.text ├── code_blocks.html ├── code_blocks.text ├── code_spans.html ├── code_spans.text ├── hard_wrapped_paragraphs_with_list_like_lines.html ├── hard_wrapped_paragraphs_with_list_like_lines.text ├── horizontal_rules.html ├── horizontal_rules.text ├── inline_html_advanced.html ├── inline_html_advanced.text ├── inline_html_comments.html ├── inline_html_comments.text ├── inline_html_simple.html ├── inline_html_simple.text ├── links_inline_style.html ├── links_inline_style.text ├── links_reference_style.html ├── links_reference_style.text ├── links_shortcut_references.html ├── links_shortcut_references.text ├── literal_quotes_in_titles.html ├── literal_quotes_in_titles.text ├── markdown_documentation_basics.html ├── markdown_documentation_basics.text ├── markdown_documentation_syntax.html ├── markdown_documentation_syntax.text ├── nested_blockquotes.html ├── nested_blockquotes.text ├── ordered_and_unordered_lists.html ├── ordered_and_unordered_lists.text ├── strong_and_em_together.html ├── strong_and_em_together.text ├── tabs.html ├── tabs.text ├── tidyness.html └── tidyness.text └── tests ├── amps_and_angles_encoding.html ├── amps_and_angles_encoding.text ├── auto_links.html ├── auto_links.text ├── autolink_lines.html ├── autolink_lines.text ├── backslash_escapes.html ├── backslash_escapes.text ├── blockquote_list_item.html ├── blockquote_list_item.text ├── blockquotes_with_code_blocks.html ├── blockquotes_with_code_blocks.text ├── case_insensitive_refs.html ├── case_insensitive_refs.text ├── code_blocks.html ├── code_blocks.text ├── code_spans.html ├── code_spans.text ├── def_blocks.html ├── def_blocks.text ├── double_link.html ├── double_link.text ├── escaped_angles.html ├── escaped_angles.text ├── gfm_break.html ├── gfm_break.text ├── gfm_code.html ├── gfm_code.text ├── gfm_code_hr_list.html ├── gfm_code_hr_list.text ├── gfm_del.html ├── gfm_del.text ├── gfm_em.html ├── gfm_em.text ├── gfm_links.html ├── gfm_links.text ├── gfm_tables.html ├── gfm_tables.text ├── hard_wrapped_paragraphs_with_list_like_lines.html ├── hard_wrapped_paragraphs_with_list_like_lines.text ├── horizontal_rules.html ├── horizontal_rules.text ├── hr_list_break.html ├── hr_list_break.text ├── inline_html_advanced.html ├── inline_html_advanced.text ├── inline_html_comments.html ├── inline_html_comments.text ├── inline_html_simple.html ├── inline_html_simple.text ├── lazy_blockquotes.html ├── lazy_blockquotes.text ├── links_inline_style.html ├── links_inline_style.text ├── links_reference_style.html ├── links_reference_style.text ├── links_shortcut_references.html ├── links_shortcut_references.text ├── list_item_text.html ├── list_item_text.text ├── literal_quotes_in_titles.html ├── literal_quotes_in_titles.text ├── loose_lists.html ├── loose_lists.text ├── main.html ├── main.text ├── markdown_documentation_basics.html ├── markdown_documentation_basics.text ├── markdown_documentation_syntax.html ├── markdown_documentation_syntax.text ├── nested_blockquotes.html ├── nested_blockquotes.text ├── nested_code.html ├── nested_code.text ├── nested_em.html ├── nested_em.text ├── nested_square_link.html ├── nested_square_link.text ├── not_a_link.html ├── not_a_link.text ├── ordered_and_unordered_lists.html ├── ordered_and_unordered_lists.text ├── ref_paren.html ├── ref_paren.text ├── same_bullet.html ├── same_bullet.text ├── strong_and_em_together.html ├── strong_and_em_together.text ├── tabs.html ├── tabs.text ├── text.smartypants.html ├── text.smartypants.text ├── tidyness.html ├── tidyness.text ├── toplevel_paragraphs.html ├── toplevel_paragraphs.text ├── tricky_list.html └── tricky_list.text /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, Christopher Jeffrey (https://github.com/chjj/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @cp lib/marked.js marked.js 3 | @uglifyjs -o marked.min.js marked.js 4 | 5 | clean: 6 | @rm marked.js 7 | @rm marked.min.js 8 | 9 | bench: 10 | @node test --bench 11 | 12 | .PHONY: clean all 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # marked 2 | 3 | A full-featured markdown parser and compiler, written in javascript. 4 | Built for speed. 5 | 6 | ## Benchmarks 7 | 8 | node v0.4.x 9 | 10 | ``` bash 11 | $ node test --bench 12 | marked completed in 12071ms. 13 | showdown (reuse converter) completed in 27387ms. 14 | showdown (new converter) completed in 75617ms. 15 | markdown-js completed in 70069ms. 16 | ``` 17 | 18 | node v0.6.x 19 | 20 | ``` bash 21 | $ node test --bench 22 | marked completed in 6448ms. 23 | marked (gfm) completed in 7357ms. 24 | marked (pedantic) completed in 6092ms. 25 | discount completed in 7314ms. 26 | showdown (reuse converter) completed in 16018ms. 27 | showdown (new converter) completed in 18234ms. 28 | markdown-js completed in 24270ms. 29 | ``` 30 | 31 | __Marked is now faster than Discount, which is written in C.__ 32 | 33 | For those feeling skeptical: These benchmarks run the entire markdown test suite 34 | 1000 times. The test suite tests every feature. It doesn't cater to specific 35 | aspects. 36 | 37 | node v0.8.x 38 | 39 | ``` bash 40 | $ node test --bench 41 | marked completed in 3411ms. 42 | marked (gfm) completed in 3727ms. 43 | marked (pedantic) completed in 3201ms. 44 | robotskirt completed in 808ms. 45 | showdown (reuse converter) completed in 11954ms. 46 | showdown (new converter) completed in 17774ms. 47 | markdown-js completed in 17191ms. 48 | ``` 49 | 50 | ## Install 51 | 52 | ``` bash 53 | $ npm install marked 54 | ``` 55 | 56 | ## Another Javascript Markdown Parser 57 | 58 | The point of marked was to create a markdown compiler where it was possible to 59 | frequently parse huge chunks of markdown without having to worry about 60 | caching the compiled output somehow...or blocking for an unnecesarily long time. 61 | 62 | marked is very concise and still implements all markdown features. It is also 63 | now fully compatible with the client-side. 64 | 65 | marked more or less passes the official markdown test suite in its 66 | entirety. This is important because a surprising number of markdown compilers 67 | cannot pass more than a few tests. It was very difficult to get marked as 68 | compliant as it is. It could have cut corners in several areas for the sake 69 | of performance, but did not in order to be exactly what you expect in terms 70 | of a markdown rendering. In fact, this is why marked could be considered at a 71 | disadvantage in the benchmarks above. 72 | 73 | Along with implementing every markdown feature, marked also implements 74 | [GFM features](http://github.github.com/github-flavored-markdown/). 75 | 76 | ## Options 77 | 78 | marked has a few different switches which change behavior. 79 | 80 | - __pedantic__: Conform to obscure parts of `markdown.pl` as much as possible. 81 | Don't fix any of the original markdown bugs or poor behavior. 82 | - __gfm__: Enable github flavored markdown (enabled by default). 83 | - __sanitize__: Sanitize the output. Ignore any HTML that has been input. 84 | - __highlight__: A callback to highlight code blocks. 85 | - __tables__: Enable GFM tables. This is enabled by default. (Requires the 86 | `gfm` option in order to be enabled). 87 | - __breaks__: Enable GFM line breaks. Disabled by default. 88 | - __smartLists__: Use smarter list behavior than the original markdown. 89 | Disabled by default. May eventually be default with the old behavior 90 | moved into `pedantic`. 91 | - __langPrefix__: Set the prefix for code block classes. Defaults to `lang-`. 92 | 93 | ## Usage 94 | 95 | ``` js 96 | // Set default options 97 | marked.setOptions({ 98 | gfm: true, 99 | tables: true, 100 | breaks: false, 101 | pedantic: false, 102 | sanitize: true, 103 | smartLists: true, 104 | langPrefix: 'language-', 105 | highlight: function(code, lang) { 106 | if (lang === 'js') { 107 | return highlighter.javascript(code); 108 | } 109 | return code; 110 | } 111 | }); 112 | console.log(marked('i am using __markdown__.')); 113 | ``` 114 | 115 | You also have direct access to the lexer and parser if you so desire. 116 | 117 | ``` js 118 | var tokens = marked.lexer(text, options); 119 | console.log(marked.parser(tokens)); 120 | ``` 121 | 122 | ``` js 123 | var lexer = new marked.Lexer(options); 124 | var tokens = lexer.lex(text); 125 | console.log(tokens); 126 | console.log(lexer.rules); 127 | ``` 128 | 129 | ``` bash 130 | $ node 131 | > require('marked').lexer('> i am using marked.') 132 | [ { type: 'blockquote_start' }, 133 | { type: 'paragraph', 134 | text: 'i am using marked.' }, 135 | { type: 'blockquote_end' }, 136 | links: {} ] 137 | ``` 138 | 139 | ## CLI 140 | 141 | ``` bash 142 | $ marked -o hello.html 143 | hello world 144 | ^D 145 | $ cat hello.html 146 |

hello world

147 | ``` 148 | 149 | ## License 150 | 151 | Copyright (c) 2011-2013, Christopher Jeffrey. (MIT License) 152 | 153 | See LICENSE for more info. 154 | -------------------------------------------------------------------------------- /bin/marked: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Marked CLI 5 | * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License) 6 | */ 7 | 8 | var fs = require('fs') 9 | , util = require('util') 10 | , marked = require('../'); 11 | 12 | /** 13 | * Man Page 14 | */ 15 | 16 | function help() { 17 | var spawn = require('child_process').spawn; 18 | 19 | var options = { 20 | cwd: process.cwd(), 21 | env: process.env, 22 | setsid: false, 23 | customFds: [0, 1, 2] 24 | }; 25 | 26 | spawn('man', 27 | [__dirname + '/../man/marked.1'], 28 | options); 29 | } 30 | 31 | /** 32 | * Main 33 | */ 34 | 35 | function main(argv, callback) { 36 | var files = [] 37 | , options = {} 38 | , input 39 | , output 40 | , arg 41 | , tokens 42 | , opt; 43 | 44 | function getarg() { 45 | var arg = argv.shift(); 46 | 47 | if (arg.indexOf('--') === 0) { 48 | // e.g. --opt 49 | arg = arg.split('='); 50 | if (arg.length > 1) { 51 | // e.g. --opt=val 52 | argv.unshift(arg.slice(1).join('=')); 53 | } 54 | arg = arg[0]; 55 | } else if (arg[0] === '-') { 56 | if (arg.length > 2) { 57 | // e.g. -abc 58 | argv = arg.substring(1).split('').map(function(ch) { 59 | return '-' + ch; 60 | }).concat(argv); 61 | arg = argv.shift(); 62 | } else { 63 | // e.g. -a 64 | } 65 | } else { 66 | // e.g. foo 67 | } 68 | 69 | return arg; 70 | } 71 | 72 | while (argv.length) { 73 | arg = getarg(); 74 | switch (arg) { 75 | case '--test': 76 | return require('../test').main(process.argv.slice()); 77 | case '-o': 78 | case '--output': 79 | output = argv.shift(); 80 | break; 81 | case '-i': 82 | case '--input': 83 | input = argv.shift(); 84 | break; 85 | case '-t': 86 | case '--tokens': 87 | tokens = true; 88 | break; 89 | case '-h': 90 | case '--help': 91 | return help(); 92 | default: 93 | if (arg.indexOf('--') === 0) { 94 | opt = camelize(arg.replace(/^--(no-)?/, '')); 95 | if (!marked.defaults.hasOwnProperty(opt)) { 96 | continue; 97 | } 98 | if (arg.indexOf('--no-') === 0) { 99 | options[opt] = typeof marked.defaults[opt] !== 'boolean' 100 | ? null 101 | : false; 102 | } else { 103 | options[opt] = typeof marked.defaults[opt] !== 'boolean' 104 | ? argv.shift() 105 | : true; 106 | } 107 | } else { 108 | files.push(arg); 109 | } 110 | break; 111 | } 112 | } 113 | 114 | function getData(callback) { 115 | if (!input) { 116 | if (files.length <= 2) { 117 | return getStdin(callback); 118 | } 119 | input = files.pop(); 120 | } 121 | return fs.readFile(input, 'utf8', callback); 122 | } 123 | 124 | return getData(function(err, data) { 125 | if (err) return callback(err); 126 | 127 | data = tokens 128 | ? JSON.stringify(marked.lexer(data, options), null, 2) 129 | : marked(data, options); 130 | 131 | if (!output) { 132 | process.stdout.write(data + '\n'); 133 | return callback(); 134 | } 135 | 136 | return fs.writeFile(output, data, callback); 137 | }); 138 | } 139 | 140 | /** 141 | * Helpers 142 | */ 143 | 144 | function getStdin(callback) { 145 | var stdin = process.stdin 146 | , buff = ''; 147 | 148 | stdin.setEncoding('utf8'); 149 | 150 | stdin.on('data', function(data) { 151 | buff += data; 152 | }); 153 | 154 | stdin.on('error', function(err) { 155 | return callback(err); 156 | }); 157 | 158 | stdin.on('end', function() { 159 | return callback(null, buff); 160 | }); 161 | 162 | try { 163 | stdin.resume(); 164 | } catch (e) { 165 | callback(e); 166 | } 167 | } 168 | 169 | function camelize(text) { 170 | return text.replace(/(\w)-(\w)/g, function(_, a, b) { 171 | return a + b.toUpperCase(); 172 | }); 173 | } 174 | 175 | /** 176 | * Expose / Entry Point 177 | */ 178 | 179 | if (!module.parent) { 180 | process.title = 'marked'; 181 | main(process.argv.slice(), function(err, code) { 182 | if (err) throw err; 183 | return process.exit(code || 0); 184 | }); 185 | } else { 186 | module.exports = main; 187 | } 188 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/marked'); 2 | -------------------------------------------------------------------------------- /lib/marked.js: -------------------------------------------------------------------------------- 1 | /** 2 | * marked - a markdown parser 3 | * Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed) 4 | * https://github.com/chjj/marked 5 | */ 6 | 7 | ;(function() { 8 | 9 | /** 10 | * Block-Level Grammar 11 | */ 12 | 13 | var block = { 14 | newline: /^\n+/, 15 | code: /^( {4}[^\n]+\n*)+/, 16 | fences: noop, 17 | hr: /^( *[-*_]){3,} *(?:\n+|$)/, 18 | heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, 19 | nptable: noop, 20 | lheading: /^([^\n]+)\n *(=|-){3,} *\n*/, 21 | blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/, 22 | list: /^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, 23 | html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/, 24 | def: /^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, 25 | table: noop, 26 | paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, 27 | text: /^[^\n]+/ 28 | }; 29 | 30 | block.bullet = /(?:[*+-]|\d+\.)/; 31 | block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; 32 | block.item = replace(block.item, 'gm') 33 | (/bull/g, block.bullet) 34 | (); 35 | 36 | block.list = replace(block.list) 37 | (/bull/g, block.bullet) 38 | ('hr', /\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/) 39 | (); 40 | 41 | block._tag = '(?!(?:' 42 | + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' 43 | + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' 44 | + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|@)\\b'; 45 | 46 | block.html = replace(block.html) 47 | ('comment', //) 48 | ('closed', /<(tag)[\s\S]+?<\/\1>/) 49 | ('closing', /])*?>/) 50 | (/tag/g, block._tag) 51 | (); 52 | 53 | block.paragraph = replace(block.paragraph) 54 | ('hr', block.hr) 55 | ('heading', block.heading) 56 | ('lheading', block.lheading) 57 | ('blockquote', block.blockquote) 58 | ('tag', '<' + block._tag) 59 | ('def', block.def) 60 | (); 61 | 62 | /** 63 | * Normal Block Grammar 64 | */ 65 | 66 | block.normal = merge({}, block); 67 | 68 | /** 69 | * GFM Block Grammar 70 | */ 71 | 72 | block.gfm = merge({}, block.normal, { 73 | fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/, 74 | paragraph: /^/ 75 | }); 76 | 77 | block.gfm.paragraph = replace(block.paragraph) 78 | ('(?!', '(?!' + block.gfm.fences.source.replace('\\1', '\\2') + '|') 79 | (); 80 | 81 | /** 82 | * GFM + Tables Block Grammar 83 | */ 84 | 85 | block.tables = merge({}, block.gfm, { 86 | nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/, 87 | table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/ 88 | }); 89 | 90 | /** 91 | * Block Lexer 92 | */ 93 | 94 | function Lexer(options) { 95 | this.tokens = []; 96 | this.tokens.links = {}; 97 | this.options = options || marked.defaults; 98 | this.rules = block.normal; 99 | 100 | if (this.options.gfm) { 101 | if (this.options.tables) { 102 | this.rules = block.tables; 103 | } else { 104 | this.rules = block.gfm; 105 | } 106 | } 107 | } 108 | 109 | /** 110 | * Expose Block Rules 111 | */ 112 | 113 | Lexer.rules = block; 114 | 115 | /** 116 | * Static Lex Method 117 | */ 118 | 119 | Lexer.lex = function(src, options) { 120 | var lexer = new Lexer(options); 121 | return lexer.lex(src); 122 | }; 123 | 124 | /** 125 | * Preprocessing 126 | */ 127 | 128 | Lexer.prototype.lex = function(src) { 129 | src = src 130 | .replace(/\r\n|\r/g, '\n') 131 | .replace(/\t/g, ' ') 132 | .replace(/\u00a0/g, ' ') 133 | .replace(/\u2424/g, '\n'); 134 | 135 | return this.token(src, true); 136 | }; 137 | 138 | /** 139 | * Lexing 140 | */ 141 | 142 | Lexer.prototype.token = function(src, top) { 143 | var src = src.replace(/^ +$/gm, '') 144 | , next 145 | , loose 146 | , cap 147 | , bull 148 | , b 149 | , item 150 | , space 151 | , i 152 | , l; 153 | 154 | while (src) { 155 | // newline 156 | if (cap = this.rules.newline.exec(src)) { 157 | src = src.substring(cap[0].length); 158 | if (cap[0].length > 1) { 159 | this.tokens.push({ 160 | type: 'space' 161 | }); 162 | } 163 | } 164 | 165 | // code 166 | if (cap = this.rules.code.exec(src)) { 167 | src = src.substring(cap[0].length); 168 | cap = cap[0].replace(/^ {4}/gm, ''); 169 | this.tokens.push({ 170 | type: 'code', 171 | text: !this.options.pedantic 172 | ? cap.replace(/\n+$/, '') 173 | : cap 174 | }); 175 | continue; 176 | } 177 | 178 | // fences (gfm) 179 | if (cap = this.rules.fences.exec(src)) { 180 | src = src.substring(cap[0].length); 181 | this.tokens.push({ 182 | type: 'code', 183 | lang: cap[2], 184 | text: cap[3] 185 | }); 186 | continue; 187 | } 188 | 189 | // heading 190 | if (cap = this.rules.heading.exec(src)) { 191 | src = src.substring(cap[0].length); 192 | this.tokens.push({ 193 | type: 'heading', 194 | depth: cap[1].length, 195 | text: cap[2] 196 | }); 197 | continue; 198 | } 199 | 200 | // table no leading pipe (gfm) 201 | if (top && (cap = this.rules.nptable.exec(src))) { 202 | src = src.substring(cap[0].length); 203 | 204 | item = { 205 | type: 'table', 206 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), 207 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), 208 | cells: cap[3].replace(/\n$/, '').split('\n') 209 | }; 210 | 211 | for (i = 0; i < item.align.length; i++) { 212 | if (/^ *-+: *$/.test(item.align[i])) { 213 | item.align[i] = 'right'; 214 | } else if (/^ *:-+: *$/.test(item.align[i])) { 215 | item.align[i] = 'center'; 216 | } else if (/^ *:-+ *$/.test(item.align[i])) { 217 | item.align[i] = 'left'; 218 | } else { 219 | item.align[i] = null; 220 | } 221 | } 222 | 223 | for (i = 0; i < item.cells.length; i++) { 224 | item.cells[i] = item.cells[i].split(/ *\| */); 225 | } 226 | 227 | this.tokens.push(item); 228 | 229 | continue; 230 | } 231 | 232 | // lheading 233 | if (cap = this.rules.lheading.exec(src)) { 234 | src = src.substring(cap[0].length); 235 | this.tokens.push({ 236 | type: 'heading', 237 | depth: cap[2] === '=' ? 1 : 2, 238 | text: cap[1] 239 | }); 240 | continue; 241 | } 242 | 243 | // hr 244 | if (cap = this.rules.hr.exec(src)) { 245 | src = src.substring(cap[0].length); 246 | this.tokens.push({ 247 | type: 'hr' 248 | }); 249 | continue; 250 | } 251 | 252 | // blockquote 253 | if (cap = this.rules.blockquote.exec(src)) { 254 | src = src.substring(cap[0].length); 255 | 256 | this.tokens.push({ 257 | type: 'blockquote_start' 258 | }); 259 | 260 | cap = cap[0].replace(/^ *> ?/gm, ''); 261 | 262 | // Pass `top` to keep the current 263 | // "toplevel" state. This is exactly 264 | // how markdown.pl works. 265 | this.token(cap, top); 266 | 267 | this.tokens.push({ 268 | type: 'blockquote_end' 269 | }); 270 | 271 | continue; 272 | } 273 | 274 | // list 275 | if (cap = this.rules.list.exec(src)) { 276 | src = src.substring(cap[0].length); 277 | bull = cap[2]; 278 | 279 | this.tokens.push({ 280 | type: 'list_start', 281 | ordered: bull.length > 1 282 | }); 283 | 284 | // Get each top-level item. 285 | cap = cap[0].match(this.rules.item); 286 | 287 | next = false; 288 | l = cap.length; 289 | i = 0; 290 | 291 | for (; i < l; i++) { 292 | item = cap[i]; 293 | 294 | // Remove the list item's bullet 295 | // so it is seen as the next token. 296 | space = item.length; 297 | item = item.replace(/^ *([*+-]|\d+\.) +/, ''); 298 | 299 | // Outdent whatever the 300 | // list item contains. Hacky. 301 | if (~item.indexOf('\n ')) { 302 | space -= item.length; 303 | item = !this.options.pedantic 304 | ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') 305 | : item.replace(/^ {1,4}/gm, ''); 306 | } 307 | 308 | // Determine whether the next list item belongs here. 309 | // Backpedal if it does not belong in this list. 310 | if (this.options.smartLists && i !== l - 1) { 311 | b = block.bullet.exec(cap[i+1])[0]; 312 | if (bull !== b && !(bull.length > 1 && b.length > 1)) { 313 | src = cap.slice(i + 1).join('\n') + src; 314 | i = l - 1; 315 | } 316 | } 317 | 318 | // Determine whether item is loose or not. 319 | // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/ 320 | // for discount behavior. 321 | loose = next || /\n\n(?!\s*$)/.test(item); 322 | if (i !== l - 1) { 323 | next = item[item.length-1] === '\n'; 324 | if (!loose) loose = next; 325 | } 326 | 327 | this.tokens.push({ 328 | type: loose 329 | ? 'loose_item_start' 330 | : 'list_item_start' 331 | }); 332 | 333 | // Recurse. 334 | this.token(item, false); 335 | 336 | this.tokens.push({ 337 | type: 'list_item_end' 338 | }); 339 | } 340 | 341 | this.tokens.push({ 342 | type: 'list_end' 343 | }); 344 | 345 | continue; 346 | } 347 | 348 | // html 349 | if (cap = this.rules.html.exec(src)) { 350 | src = src.substring(cap[0].length); 351 | this.tokens.push({ 352 | type: this.options.sanitize 353 | ? 'paragraph' 354 | : 'html', 355 | pre: cap[1] === 'pre' || cap[1] === 'script', 356 | text: cap[0] 357 | }); 358 | continue; 359 | } 360 | 361 | // def 362 | if (top && (cap = this.rules.def.exec(src))) { 363 | src = src.substring(cap[0].length); 364 | this.tokens.links[cap[1].toLowerCase()] = { 365 | href: cap[2], 366 | title: cap[3] 367 | }; 368 | continue; 369 | } 370 | 371 | // table (gfm) 372 | if (top && (cap = this.rules.table.exec(src))) { 373 | src = src.substring(cap[0].length); 374 | 375 | item = { 376 | type: 'table', 377 | header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), 378 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), 379 | cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') 380 | }; 381 | 382 | for (i = 0; i < item.align.length; i++) { 383 | if (/^ *-+: *$/.test(item.align[i])) { 384 | item.align[i] = 'right'; 385 | } else if (/^ *:-+: *$/.test(item.align[i])) { 386 | item.align[i] = 'center'; 387 | } else if (/^ *:-+ *$/.test(item.align[i])) { 388 | item.align[i] = 'left'; 389 | } else { 390 | item.align[i] = null; 391 | } 392 | } 393 | 394 | for (i = 0; i < item.cells.length; i++) { 395 | item.cells[i] = item.cells[i] 396 | .replace(/^ *\| *| *\| *$/g, '') 397 | .split(/ *\| */); 398 | } 399 | 400 | this.tokens.push(item); 401 | 402 | continue; 403 | } 404 | 405 | // top-level paragraph 406 | if (top && (cap = this.rules.paragraph.exec(src))) { 407 | src = src.substring(cap[0].length); 408 | this.tokens.push({ 409 | type: 'paragraph', 410 | text: cap[1][cap[1].length-1] === '\n' 411 | ? cap[1].slice(0, -1) 412 | : cap[1] 413 | }); 414 | continue; 415 | } 416 | 417 | // text 418 | if (cap = this.rules.text.exec(src)) { 419 | // Top-level should never reach here. 420 | src = src.substring(cap[0].length); 421 | this.tokens.push({ 422 | type: 'text', 423 | text: cap[0] 424 | }); 425 | continue; 426 | } 427 | 428 | if (src) { 429 | throw new 430 | Error('Infinite loop on byte: ' + src.charCodeAt(0)); 431 | } 432 | } 433 | 434 | return this.tokens; 435 | }; 436 | 437 | /** 438 | * Inline-Level Grammar 439 | */ 440 | 441 | var inline = { 442 | escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, 443 | autolink: /^<([^ >]+(@|:\/)[^ >]+)>/, 444 | url: noop, 445 | tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/, 446 | link: /^!?\[(inside)\]\(href\)/, 447 | reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, 448 | nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/, 449 | strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, 450 | em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, 451 | code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/, 452 | br: /^ {2,}\n(?!\s*$)/, 453 | del: noop, 454 | text: /^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/; 459 | 460 | inline.link = replace(inline.link) 461 | ('inside', inline._inside) 462 | ('href', inline._href) 463 | (); 464 | 465 | inline.reflink = replace(inline.reflink) 466 | ('inside', inline._inside) 467 | (); 468 | 469 | /** 470 | * Normal Inline Grammar 471 | */ 472 | 473 | inline.normal = merge({}, inline); 474 | 475 | /** 476 | * Pedantic Inline Grammar 477 | */ 478 | 479 | inline.pedantic = merge({}, inline.normal, { 480 | strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, 481 | em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/ 482 | }); 483 | 484 | /** 485 | * GFM Inline Grammar 486 | */ 487 | 488 | inline.gfm = merge({}, inline.normal, { 489 | escape: replace(inline.escape)('])', '~|])')(), 490 | url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/, 491 | del: /^~~(?=\S)([\s\S]*?\S)~~/, 492 | text: replace(inline.text) 493 | (']|', '~]|') 494 | ('|', '|https?://|') 495 | () 496 | }); 497 | 498 | /** 499 | * GFM + Line Breaks Inline Grammar 500 | */ 501 | 502 | inline.breaks = merge({}, inline.gfm, { 503 | br: replace(inline.br)('{2,}', '*')(), 504 | text: replace(inline.gfm.text)('{2,}', '*')() 505 | }); 506 | 507 | /** 508 | * Inline Lexer & Compiler 509 | */ 510 | 511 | function InlineLexer(links, options) { 512 | this.options = options || marked.defaults; 513 | this.links = links; 514 | this.rules = inline.normal; 515 | 516 | if (!this.links) { 517 | throw new 518 | Error('Tokens array requires a `links` property.'); 519 | } 520 | 521 | if (this.options.gfm) { 522 | if (this.options.breaks) { 523 | this.rules = inline.breaks; 524 | } else { 525 | this.rules = inline.gfm; 526 | } 527 | } else if (this.options.pedantic) { 528 | this.rules = inline.pedantic; 529 | } 530 | } 531 | 532 | /** 533 | * Expose Inline Rules 534 | */ 535 | 536 | InlineLexer.rules = inline; 537 | 538 | /** 539 | * Static Lexing/Compiling Method 540 | */ 541 | 542 | InlineLexer.output = function(src, links, options) { 543 | var inline = new InlineLexer(links, options); 544 | return inline.output(src); 545 | }; 546 | 547 | /** 548 | * Lexing/Compiling 549 | */ 550 | 551 | InlineLexer.prototype.output = function(src) { 552 | var out = [] 553 | , link 554 | , text 555 | , href 556 | , cap; 557 | 558 | while (src) { 559 | // escape 560 | if (cap = this.rules.escape.exec(src)) { 561 | src = src.substring(cap[0].length); 562 | out.push(cap[1]); 563 | continue; 564 | } 565 | 566 | // autolink 567 | if (cap = this.rules.autolink.exec(src)) { 568 | src = src.substring(cap[0].length); 569 | if (cap[2] === '@') { 570 | text = cap[1][6] === ':' 571 | ? cap[1].substring(7) 572 | : cap[1]; 573 | href = 'mailto:' + text; 574 | } else { 575 | text = cap[1]; 576 | href = text; 577 | } 578 | out.push(React.DOM.a({href: this.sanitizeUrl(href)}, text)); 579 | continue; 580 | } 581 | 582 | // url (gfm) 583 | if (cap = this.rules.url.exec(src)) { 584 | src = src.substring(cap[0].length); 585 | text = cap[1]; 586 | href = text; 587 | out.push(React.DOM.a({href: this.sanitizeUrl(href)}, text)); 588 | continue; 589 | } 590 | 591 | // tag 592 | if (cap = this.rules.tag.exec(src)) { 593 | src = src.substring(cap[0].length); 594 | // TODO(alpert): Don't escape if sanitize is false 595 | out.push(cap[0]); 596 | continue; 597 | } 598 | 599 | // link 600 | if (cap = this.rules.link.exec(src)) { 601 | src = src.substring(cap[0].length); 602 | out.push(this.outputLink(cap, { 603 | href: cap[2], 604 | title: cap[3] 605 | })); 606 | continue; 607 | } 608 | 609 | // reflink, nolink 610 | if ((cap = this.rules.reflink.exec(src)) 611 | || (cap = this.rules.nolink.exec(src))) { 612 | src = src.substring(cap[0].length); 613 | link = (cap[2] || cap[1]).replace(/\s+/g, ' '); 614 | link = this.links[link.toLowerCase()]; 615 | if (!link || !link.href) { 616 | out.push.apply(out, this.output(cap[0][0])); 617 | src = cap[0].substring(1) + src; 618 | continue; 619 | } 620 | out.push(this.outputLink(cap, link)); 621 | continue; 622 | } 623 | 624 | // strong 625 | if (cap = this.rules.strong.exec(src)) { 626 | src = src.substring(cap[0].length); 627 | out.push(React.DOM.strong(null, this.output(cap[2] || cap[1]))); 628 | continue; 629 | } 630 | 631 | // em 632 | if (cap = this.rules.em.exec(src)) { 633 | src = src.substring(cap[0].length); 634 | out.push(React.DOM.em(null, this.output(cap[2] || cap[1]))); 635 | continue; 636 | } 637 | 638 | // code 639 | if (cap = this.rules.code.exec(src)) { 640 | src = src.substring(cap[0].length); 641 | out.push(React.DOM.code(null, cap[2])); 642 | continue; 643 | } 644 | 645 | // br 646 | if (cap = this.rules.br.exec(src)) { 647 | src = src.substring(cap[0].length); 648 | out.push(React.DOM.br(null, null)); 649 | continue; 650 | } 651 | 652 | // del (gfm) 653 | if (cap = this.rules.del.exec(src)) { 654 | src = src.substring(cap[0].length); 655 | out.push(React.DOM.del(null, this.output(cap[1]))); 656 | continue; 657 | } 658 | 659 | // text 660 | if (cap = this.rules.text.exec(src)) { 661 | src = src.substring(cap[0].length); 662 | out.push(this.smartypants(cap[0])); 663 | continue; 664 | } 665 | 666 | if (src) { 667 | throw new 668 | Error('Infinite loop on byte: ' + src.charCodeAt(0)); 669 | } 670 | } 671 | 672 | return out; 673 | }; 674 | 675 | /** 676 | * Sanitize a URL for a link or image 677 | */ 678 | 679 | InlineLexer.prototype.sanitizeUrl = function(url) { 680 | if (this.options.sanitize) { 681 | try { 682 | var prot = decodeURIComponent(url) 683 | .replace(/[^A-Za-z0-9:]/g, '') 684 | .toLowerCase(); 685 | if (prot.indexOf('javascript:') === 0) { 686 | return '#'; 687 | } 688 | } catch (e) { 689 | return '#'; 690 | } 691 | } 692 | return url; 693 | }; 694 | 695 | /** 696 | * Compile Link 697 | */ 698 | 699 | InlineLexer.prototype.outputLink = function(cap, link) { 700 | if (cap[0][0] !== '!') { 701 | return React.DOM.a({ 702 | href: this.sanitizeUrl(link.href), 703 | title: link.title 704 | }, this.output(cap[1])); 705 | } else { 706 | return React.DOM.img({ 707 | src: this.sanitizeUrl(link.href), 708 | alt: cap[1], 709 | title: link.title 710 | }, null); 711 | } 712 | }; 713 | 714 | /** 715 | * Smartypants Transformations 716 | */ 717 | 718 | InlineLexer.prototype.smartypants = function(text) { 719 | if (!this.options.smartypants) return text; 720 | return text 721 | .replace(/--/g, '\u2014') 722 | .replace(/'([^']*)'/g, '\u2018$1\u2019') 723 | .replace(/"([^"]*)"/g, '\u201C$1\u201D') 724 | .replace(/\.{3}/g, '\u2026'); 725 | }; 726 | 727 | /** 728 | * Parsing & Compiling 729 | */ 730 | 731 | function Parser(options) { 732 | this.tokens = []; 733 | this.token = null; 734 | this.options = options || marked.defaults; 735 | } 736 | 737 | /** 738 | * Static Parse Method 739 | */ 740 | 741 | Parser.parse = function(src, options) { 742 | var parser = new Parser(options); 743 | return parser.parse(src); 744 | }; 745 | 746 | /** 747 | * Parse Loop 748 | */ 749 | 750 | Parser.prototype.parse = function(src) { 751 | this.inline = new InlineLexer(src.links, this.options); 752 | this.tokens = src.reverse(); 753 | 754 | var out = []; 755 | while (this.next()) { 756 | out.push(this.tok()); 757 | } 758 | 759 | return out; 760 | }; 761 | 762 | /** 763 | * Next Token 764 | */ 765 | 766 | Parser.prototype.next = function() { 767 | return this.token = this.tokens.pop(); 768 | }; 769 | 770 | /** 771 | * Preview Next Token 772 | */ 773 | 774 | Parser.prototype.peek = function() { 775 | return this.tokens[this.tokens.length-1] || 0; 776 | }; 777 | 778 | /** 779 | * Parse Text Tokens 780 | */ 781 | 782 | Parser.prototype.parseText = function() { 783 | var body = this.token.text; 784 | 785 | while (this.peek().type === 'text') { 786 | body += '\n' + this.next().text; 787 | } 788 | 789 | return this.inline.output(body); 790 | }; 791 | 792 | /** 793 | * Parse Current Token 794 | */ 795 | 796 | Parser.prototype.tok = function() { 797 | switch (this.token.type) { 798 | case 'space': { 799 | return []; 800 | } 801 | case 'hr': { 802 | return React.DOM.hr(null, null); 803 | } 804 | case 'heading': { 805 | return React.DOM['h' + this.token.depth](null, 806 | this.inline.output(this.token.text) 807 | ); 808 | } 809 | case 'code': { 810 | if (this.options.highlight) { 811 | var code = this.options.highlight(this.token.text, this.token.lang); 812 | if (code != null && code !== this.token.text) { 813 | this.token.escaped = true; 814 | this.token.text = code; 815 | } 816 | } 817 | 818 | if (!this.token.escaped) { 819 | this.token.text = escape(this.token.text, true); 820 | } 821 | 822 | return React.DOM.pre(null, React.DOM.code({ 823 | className: this.token.lang 824 | ? this.options.langPrefix + this.token.lang 825 | : '', 826 | dangerouslySetInnerHTML: {__html: this.token.text} 827 | })); 828 | } 829 | case 'table': { 830 | var table = [] 831 | , body = [] 832 | , row = [] 833 | , heading 834 | , i 835 | , cells 836 | , j; 837 | 838 | // header 839 | for (i = 0; i < this.token.header.length; i++) { 840 | heading = this.inline.output(this.token.header[i]); 841 | row.push(React.DOM.th( 842 | this.token.align[i] 843 | ? {style: {textAlign: this.token.align[i]}} 844 | : null, 845 | heading 846 | )); 847 | } 848 | table.push(React.DOM.thead(null, React.DOM.tr(null, row))); 849 | 850 | // body 851 | for (i = 0; i < this.token.cells.length; i++) { 852 | row = []; 853 | cells = this.token.cells[i]; 854 | for (j = 0; j < cells.length; j++) { 855 | row.push(React.DOM.td( 856 | this.token.align[j] 857 | ? {style: {textAlign: this.token.align[j]}} 858 | : null, 859 | this.inline.output(cells[j]) 860 | )); 861 | } 862 | body.push(React.DOM.tr(null, row)); 863 | } 864 | table.push(React.DOM.tbody(null, body)); 865 | 866 | return React.DOM.table(null, table); 867 | } 868 | case 'blockquote_start': { 869 | var body = []; 870 | 871 | while (this.next().type !== 'blockquote_end') { 872 | body.push(this.tok()); 873 | } 874 | 875 | return React.DOM.blockquote(null, body); 876 | } 877 | case 'list_start': { 878 | var type = this.token.ordered ? 'ol' : 'ul' 879 | , body = []; 880 | 881 | while (this.next().type !== 'list_end') { 882 | body.push(this.tok()); 883 | } 884 | 885 | return React.DOM[type](null, body); 886 | } 887 | case 'list_item_start': { 888 | var body = []; 889 | 890 | while (this.next().type !== 'list_item_end') { 891 | body.push(this.token.type === 'text' 892 | ? this.parseText() 893 | : this.tok()); 894 | } 895 | 896 | return React.DOM.li(null, body); 897 | } 898 | case 'loose_item_start': { 899 | var body = []; 900 | 901 | while (this.next().type !== 'list_item_end') { 902 | body.push(this.tok()); 903 | } 904 | 905 | return React.DOM.li(null, body); 906 | } 907 | case 'html': { 908 | return !this.token.pre && !this.options.pedantic 909 | ? this.inline.output(this.token.text) 910 | : this.token.text; 911 | } 912 | case 'paragraph': { 913 | return this.options.paragraphFn 914 | ? this.options.paragraphFn.call(null, this.inline.output(this.token.text)) 915 | : React.DOM.p(null, this.inline.output(this.token.text)); 916 | } 917 | case 'text': { 918 | return this.options.paragraphFn 919 | ? this.options.paragraphFn.call(null, this.parseText()) 920 | : React.DOM.p(null, this.parseText()); 921 | } 922 | } 923 | }; 924 | 925 | /** 926 | * Helpers 927 | */ 928 | 929 | function escape(html, encode) { 930 | return html 931 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') 932 | .replace(//g, '>') 934 | .replace(/"/g, '"') 935 | .replace(/'/g, '''); 936 | } 937 | 938 | function replace(regex, opt) { 939 | regex = regex.source; 940 | opt = opt || ''; 941 | return function self(name, val) { 942 | if (!name) return new RegExp(regex, opt); 943 | val = val.source || val; 944 | val = val.replace(/(^|[^\[])\^/g, '$1'); 945 | regex = regex.replace(name, val); 946 | return self; 947 | }; 948 | } 949 | 950 | function noop() {} 951 | noop.exec = noop; 952 | 953 | function merge(obj) { 954 | var i = 1 955 | , target 956 | , key; 957 | 958 | for (; i < arguments.length; i++) { 959 | target = arguments[i]; 960 | for (key in target) { 961 | if (Object.prototype.hasOwnProperty.call(target, key)) { 962 | obj[key] = target[key]; 963 | } 964 | } 965 | } 966 | 967 | return obj; 968 | } 969 | 970 | /** 971 | * Marked 972 | */ 973 | 974 | function marked(src, opt, callback) { 975 | if (callback || typeof opt === 'function') { 976 | if (!callback) { 977 | callback = opt; 978 | opt = null; 979 | } 980 | 981 | if (opt) opt = merge({}, marked.defaults, opt); 982 | 983 | var highlight = opt.highlight 984 | , tokens 985 | , pending 986 | , i = 0; 987 | 988 | try { 989 | tokens = Lexer.lex(src, opt) 990 | } catch (e) { 991 | return callback(e); 992 | } 993 | 994 | pending = tokens.length; 995 | 996 | var done = function(hi) { 997 | var out, err; 998 | 999 | if (hi !== true) { 1000 | delete opt.highlight; 1001 | } 1002 | 1003 | try { 1004 | out = Parser.parse(tokens, opt); 1005 | } catch (e) { 1006 | err = e; 1007 | } 1008 | 1009 | opt.highlight = highlight; 1010 | 1011 | return err 1012 | ? callback(err) 1013 | : callback(null, out); 1014 | }; 1015 | 1016 | if (!highlight || highlight.length < 3) { 1017 | return done(true); 1018 | } 1019 | 1020 | if (!pending) return done(); 1021 | 1022 | for (; i < tokens.length; i++) { 1023 | (function(token) { 1024 | if (token.type !== 'code') { 1025 | return --pending || done(); 1026 | } 1027 | return highlight(token.text, token.lang, function(err, code) { 1028 | if (code == null || code === token.text) { 1029 | return --pending || done(); 1030 | } 1031 | token.text = code; 1032 | token.escaped = true; 1033 | --pending || done(); 1034 | }); 1035 | })(tokens[i]); 1036 | } 1037 | 1038 | return; 1039 | } 1040 | try { 1041 | if (opt) opt = merge({}, marked.defaults, opt); 1042 | return Parser.parse(Lexer.lex(src, opt), opt); 1043 | } catch (e) { 1044 | e.message += '\nPlease report this to https://github.com/chjj/marked.'; 1045 | if ((opt || marked.defaults).silent) { 1046 | return [React.DOM.p(null, "An error occurred:"), 1047 | React.DOM.pre(null, e.message)]; 1048 | } 1049 | throw e; 1050 | } 1051 | } 1052 | 1053 | /** 1054 | * Options 1055 | */ 1056 | 1057 | marked.options = 1058 | marked.setOptions = function(opt) { 1059 | merge(marked.defaults, opt); 1060 | return marked; 1061 | }; 1062 | 1063 | marked.defaults = { 1064 | gfm: true, 1065 | tables: true, 1066 | breaks: false, 1067 | pedantic: false, 1068 | sanitize: false, 1069 | smartLists: false, 1070 | silent: false, 1071 | highlight: null, 1072 | langPrefix: 'lang-', 1073 | smartypants: false, 1074 | paragraphFn: null 1075 | }; 1076 | 1077 | /** 1078 | * Expose 1079 | */ 1080 | 1081 | marked.Parser = Parser; 1082 | marked.parser = Parser.parse; 1083 | 1084 | marked.Lexer = Lexer; 1085 | marked.lexer = Lexer.lex; 1086 | 1087 | marked.InlineLexer = InlineLexer; 1088 | marked.inlineLexer = InlineLexer.output; 1089 | 1090 | marked.parse = marked; 1091 | 1092 | if (typeof exports === 'object') { 1093 | module.exports = marked; 1094 | } else if (typeof define === 'function' && define.amd) { 1095 | define(function() { return marked; }); 1096 | } else { 1097 | this.markedReact = marked; 1098 | } 1099 | 1100 | }).call(function() { 1101 | return this || (typeof window !== 'undefined' ? window : global); 1102 | }()); 1103 | -------------------------------------------------------------------------------- /man/marked.1: -------------------------------------------------------------------------------- 1 | .ds q \N'34' 2 | .TH marked 1 "2013-01-05" "v0.2.7" "marked.js" 3 | 4 | .SH NAME 5 | marked \- a javascript markdown parser 6 | 7 | .SH SYNOPSIS 8 | .B marked 9 | [\-o \fI\fP] [\-i \fI\fP] [\-\-help] 10 | [\-\-tokens] [\-\-pedantic] [\-\-gfm] 11 | [\-\-breaks] [\-\-tables] [\-\-sanitize] 12 | [\-\-smart\-lists] [\-\-lang\-prefix \fI\fP] 13 | [\-\-no\-etc...] [\-\-silent] [\fIfilename\fP] 14 | 15 | .SH DESCRIPTION 16 | .B marked 17 | is a full-featured javascript markdown parser, built for speed. It also includes 18 | multiple GFM features. 19 | 20 | .SH EXAMPLES 21 | .TP 22 | cat in.md | marked > out.html 23 | .TP 24 | echo "hello *world*" | marked 25 | .TP 26 | marked -o out.html in.md --gfm 27 | .TP 28 | marked --output="hello world.html" -i in.md --no-breaks 29 | 30 | .SH OPTIONS 31 | .TP 32 | .BI \-o,\ \-\-output\ [\fIoutput\fP] 33 | Specify file output. If none is specified, write to stdout. 34 | .TP 35 | .BI \-i,\ \-\-input\ [\fIinput\fP] 36 | Specify file input, otherwise use last argument as input file. If no input file 37 | is specified, read from stdin. 38 | .TP 39 | .BI \-t,\ \-\-tokens 40 | Output a token stream instead of html. 41 | .TP 42 | .BI \-\-pedantic 43 | Conform to obscure parts of markdown.pl as much as possible. Don't fix original 44 | markdown bugs. 45 | .TP 46 | .BI \-\-gfm 47 | Enable github flavored markdown. 48 | .TP 49 | .BI \-\-breaks 50 | Enable GFM line breaks. Only works with the gfm option. 51 | .TP 52 | .BI \-\-tables 53 | Enable GFM tables. Only works with the gfm option. 54 | .TP 55 | .BI \-\-sanitize 56 | Sanitize output. Ignore any HTML input. 57 | .TP 58 | .BI \-\-smart\-lists 59 | Use smarter list behavior than the original markdown. 60 | .TP 61 | .BI \-\-lang\-prefix\ [\fIprefix\fP] 62 | Set the prefix for code block classes. 63 | .TP 64 | .BI \-\-no\-sanitize,\ \-no-etc... 65 | The inverse of any of the marked options above. 66 | .TP 67 | .BI \-\-silent 68 | Silence error output. 69 | .TP 70 | .BI \-h,\ \-\-help 71 | Display help information. 72 | 73 | .SH CONFIGURATION 74 | For configuring and running programmatically. 75 | 76 | .B Example 77 | 78 | require('marked')('*foo*', { gfm: true }); 79 | 80 | .SH BUGS 81 | Please report any bugs to https://github.com/chjj/marked. 82 | 83 | .SH LICENSE 84 | Copyright (c) 2011-2013, Christopher Jeffrey (MIT License). 85 | 86 | .SH "SEE ALSO" 87 | .BR markdown(1), 88 | .BR node.js(1) 89 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "marked", 3 | "description": "A markdown parser built for speed", 4 | "author": "Christopher Jeffrey", 5 | "version": "0.2.9", 6 | "main": "./lib/marked.js", 7 | "bin": "./bin/marked", 8 | "man": "./man/marked.1", 9 | "preferGlobal": true, 10 | "repository": "git://github.com/chjj/marked.git", 11 | "homepage": "https://github.com/chjj/marked", 12 | "bugs": { "url": "http://github.com/chjj/marked/issues" }, 13 | "keywords": ["markdown", "markup", "html"], 14 | "tags": ["markdown", "markup", "html"], 15 | "devDependencies": { 16 | "markdown": "*", 17 | "showdown": "*", 18 | "robotskirt": "*" 19 | }, 20 | "scripts": { "test": "node test", "bench": "node test --bench" } 21 | } 22 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | In this directory: 2 | 3 | # 4 | # MarkdownTester -- Run tests for Markdown implementations 5 | # 6 | # Copyright (c) 2004-2005 John Gruber 7 | # 8 | # 9 | 10 | Partially modified for testing purposes. 11 | -------------------------------------------------------------------------------- /test/browser/index.html: -------------------------------------------------------------------------------- 1 | 2 | marked tests 3 |

testing...

4 | 5 | 6 | -------------------------------------------------------------------------------- /test/browser/index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | var test = require('../') 4 | , runTests = test.runTests 5 | , load = test.load; 6 | 7 | var express = require('express') 8 | , app = express(); 9 | 10 | app.use(function(req, res, next) { 11 | var setHeader = res.setHeader; 12 | res.setHeader = function(name) { 13 | switch (name) { 14 | case 'Cache-Control': 15 | case 'Last-Modified': 16 | case 'ETag': 17 | return; 18 | } 19 | return setHeader.apply(res, arguments); 20 | }; 21 | next(); 22 | }); 23 | 24 | var dir = __dirname + '/../tests' 25 | , files = {}; 26 | 27 | app.get('/test.js', function(req, res, next) { 28 | var test = fs.readFileSync(__dirname + '/test.js', 'utf8') 29 | , files = load(); 30 | 31 | test = test.replace('__TESTS__', JSON.stringify(files)); 32 | test = test.replace('__MAIN__', runTests + ''); 33 | 34 | res.contentType('.js'); 35 | res.send(test); 36 | }); 37 | 38 | app.use(express.static(__dirname + '/../../lib')); 39 | app.use(express.static(__dirname)); 40 | 41 | app.listen(8080); 42 | -------------------------------------------------------------------------------- /test/browser/test.js: -------------------------------------------------------------------------------- 1 | ;(function() { 2 | 3 | var console = {} 4 | , files = __TESTS__; 5 | 6 | console.log = function(text) { 7 | var args = Array.prototype.slice.call(arguments, 1) 8 | , i = 0; 9 | 10 | text = text.replace(/%\w/g, function() { 11 | return args[i++] || ''; 12 | }); 13 | 14 | if (window.console) window.console.log(text); 15 | document.body.innerHTML += '
' + escape(text) + '
'; 16 | }; 17 | 18 | Object.keys = Object.keys || function(obj) { 19 | var out = [] 20 | , key; 21 | 22 | for (key in obj) { 23 | if (Object.prototype.hasOwnProperty.call(obj, key)) { 24 | out.push(key); 25 | } 26 | } 27 | 28 | return out; 29 | }; 30 | 31 | String.prototype.trim = String.prototype.trim || function() { 32 | return this.replace(/^\s+|\s+$/g, ''); 33 | }; 34 | 35 | function load() { 36 | return files; 37 | } 38 | 39 | function escape(html, encode) { 40 | return html 41 | .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') 42 | .replace(//g, '>') 44 | .replace(/"/g, '"') 45 | .replace(/'/g, '''); 46 | } 47 | 48 | (__MAIN__)(); 49 | 50 | }).call(this); 51 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * marked tests 5 | * Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed) 6 | * https://github.com/chjj/marked 7 | */ 8 | 9 | /** 10 | * Modules 11 | */ 12 | 13 | var fs = require('fs') 14 | , path = require('path') 15 | , marked = require('../'); 16 | 17 | /** 18 | * Load Tests 19 | */ 20 | 21 | function load() { 22 | var dir = __dirname + '/tests' 23 | , files = {} 24 | , list 25 | , file 26 | , i 27 | , l; 28 | 29 | list = fs 30 | .readdirSync(dir) 31 | .filter(function(file) { 32 | return path.extname(file) !== '.html'; 33 | }) 34 | .sort(function(a, b) { 35 | a = path.basename(a).toLowerCase().charCodeAt(0); 36 | b = path.basename(b).toLowerCase().charCodeAt(0); 37 | return a > b ? 1 : (a < b ? -1 : 0); 38 | }); 39 | 40 | i = 0; 41 | l = list.length; 42 | 43 | for (; i < l; i++) { 44 | file = path.join(dir, list[i]); 45 | files[path.basename(file)] = { 46 | text: fs.readFileSync(file, 'utf8'), 47 | html: fs.readFileSync(file.replace(/[^.]+$/, 'html'), 'utf8') 48 | }; 49 | } 50 | 51 | return files; 52 | } 53 | 54 | /** 55 | * Test Runner 56 | */ 57 | 58 | function runTests(engine, options) { 59 | if (typeof engine !== 'function') { 60 | options = engine; 61 | engine = null; 62 | } 63 | 64 | var engine = engine || marked 65 | , options = options || {} 66 | , files = options.files || load() 67 | , complete = 0 68 | , failed = 0 69 | , skipped = 0 70 | , keys = Object.keys(files) 71 | , i = 0 72 | , len = keys.length 73 | , filename 74 | , file 75 | , text 76 | , html 77 | , j 78 | , l; 79 | 80 | if (options.marked) { 81 | marked.setOptions(options.marked); 82 | } 83 | 84 | main: 85 | for (; i < len; i++) { 86 | filename = keys[i]; 87 | file = files[filename]; 88 | 89 | if ((~filename.indexOf('.gfm.') && !marked.defaults.gfm) 90 | || (~filename.indexOf('.tables.') && !marked.defaults.tables) 91 | || (~filename.indexOf('.breaks.') && !marked.defaults.breaks) 92 | || (~filename.indexOf('.pedantic.') && !marked.defaults.pedantic) 93 | || (~filename.indexOf('.sanitize.') && !marked.defaults.sanitize) 94 | || (~filename.indexOf('.smartlists.') && !marked.defaults.smartLists) 95 | || (~filename.indexOf('.smartypants.') && !marked.defaults.smartypants)) { 96 | skipped++; 97 | console.log('#%d. %s skipped.', i + 1, filename); 98 | continue main; 99 | } 100 | 101 | try { 102 | text = engine(file.text).replace(/\s/g, ''); 103 | html = file.html.replace(/\s/g, ''); 104 | } catch(e) { 105 | console.log('%s failed.', filename); 106 | throw e; 107 | } 108 | 109 | j = 0; 110 | l = html.length; 111 | 112 | for (; j < l; j++) { 113 | if (text[j] !== html[j]) { 114 | failed++; 115 | 116 | text = text.substring( 117 | Math.max(j - 30, 0), 118 | Math.min(j + 30, text.length)); 119 | 120 | html = html.substring( 121 | Math.max(j - 30, 0), 122 | Math.min(j + 30, html.length)); 123 | 124 | console.log( 125 | '\n#%d. %s failed at offset %d. Near: "%s".\n', 126 | i + 1, filename, j, text); 127 | 128 | console.log('\nGot:\n%s\n', text.trim() || text); 129 | console.log('\nExpected:\n%s\n', html.trim() || html); 130 | 131 | if (options.stop) { 132 | break main; 133 | } 134 | 135 | continue main; 136 | } 137 | } 138 | 139 | complete++; 140 | console.log('#%d. %s completed.', i + 1, filename); 141 | } 142 | 143 | console.log('%d/%d tests completed successfully.', complete, len); 144 | if (failed) console.log('%d/%d tests failed.', failed, len); 145 | if (skipped) console.log('%d/%d tests skipped.', skipped, len); 146 | } 147 | 148 | /** 149 | * Benchmark a function 150 | */ 151 | 152 | function bench(name, func) { 153 | var files = bench.files || load(); 154 | 155 | if (!bench.files) { 156 | bench.files = files; 157 | 158 | // Change certain tests to allow 159 | // comparison to older benchmark times. 160 | fs.readdirSync(__dirname + '/new').forEach(function(name) { 161 | if (path.extname(name) === '.html') return; 162 | if (name === 'main.text') return; 163 | delete files[name]; 164 | }); 165 | 166 | files['backslash_escapes.text'] = { 167 | text: 'hello world \\[how](are you) today' 168 | }; 169 | 170 | files['main.text'].text = files['main.text'].text.replace('* * *\n\n', ''); 171 | } 172 | 173 | var start = Date.now() 174 | , times = 1000 175 | , keys = Object.keys(files) 176 | , i 177 | , l = keys.length 178 | , filename 179 | , file; 180 | 181 | while (times--) { 182 | for (i = 0; i < l; i++) { 183 | filename = keys[i]; 184 | file = files[filename]; 185 | func(file.text); 186 | } 187 | } 188 | 189 | console.log('%s completed in %dms.', name, Date.now() - start); 190 | } 191 | 192 | /** 193 | * Benchmark all engines 194 | */ 195 | 196 | function runBench(options) { 197 | var options = options || {}; 198 | 199 | // Non-GFM, Non-pedantic 200 | marked.setOptions({ 201 | gfm: false, 202 | tables: false, 203 | breaks: false, 204 | pedantic: false, 205 | sanitize: false, 206 | smartLists: false 207 | }); 208 | if (options.marked) { 209 | marked.setOptions(options.marked); 210 | } 211 | bench('marked', marked); 212 | 213 | // GFM 214 | marked.setOptions({ 215 | gfm: true, 216 | tables: false, 217 | breaks: false, 218 | pedantic: false, 219 | sanitize: false, 220 | smartLists: false 221 | }); 222 | if (options.marked) { 223 | marked.setOptions(options.marked); 224 | } 225 | bench('marked (gfm)', marked); 226 | 227 | // Pedantic 228 | marked.setOptions({ 229 | gfm: false, 230 | tables: false, 231 | breaks: false, 232 | pedantic: true, 233 | sanitize: false, 234 | smartLists: false 235 | }); 236 | if (options.marked) { 237 | marked.setOptions(options.marked); 238 | } 239 | bench('marked (pedantic)', marked); 240 | 241 | // robotskirt 242 | try { 243 | bench('robotskirt', (function() { 244 | var rs = require('robotskirt'); 245 | return function(text) { 246 | var parser = rs.Markdown.std(); 247 | return parser.render(text); 248 | }; 249 | })()); 250 | } catch (e) { 251 | console.log('Could not bench robotskirt.'); 252 | } 253 | 254 | // showdown 255 | try { 256 | bench('showdown (reuse converter)', (function() { 257 | var Showdown = require('showdown'); 258 | var convert = new Showdown.converter(); 259 | return function(text) { 260 | return convert.makeHtml(text); 261 | }; 262 | })()); 263 | bench('showdown (new converter)', (function() { 264 | var Showdown = require('showdown'); 265 | return function(text) { 266 | var convert = new Showdown.converter(); 267 | return convert.makeHtml(text); 268 | }; 269 | })()); 270 | } catch (e) { 271 | console.log('Could not bench showdown.'); 272 | } 273 | 274 | // markdown.js 275 | try { 276 | bench('markdown.js', require('markdown').parse); 277 | } catch (e) { 278 | console.log('Could not bench markdown.js.'); 279 | } 280 | } 281 | 282 | /** 283 | * A simple one-time benchmark 284 | */ 285 | 286 | function time(options) { 287 | var options = options || {}; 288 | if (options.marked) { 289 | marked.setOptions(options.marked); 290 | } 291 | bench('marked', marked); 292 | } 293 | 294 | /** 295 | * Markdown Test Suite Fixer 296 | * This function is responsible for "fixing" 297 | * the markdown test suite. There are 298 | * certain aspects of the suite that 299 | * are strange or might make tests 300 | * fail for reasons unrelated to 301 | * conformance. 302 | */ 303 | 304 | function fix(options) { 305 | ['tests', 'original', 'new'].forEach(function(dir) { 306 | try { 307 | fs.mkdirSync(path.resolve(__dirname, dir), 0755); 308 | } catch (e) { 309 | ; 310 | } 311 | }); 312 | 313 | // rm -rf tests 314 | fs.readdirSync(path.resolve(__dirname, 'tests')).forEach(function(file) { 315 | fs.unlinkSync(path.resolve(__dirname, 'tests', file)); 316 | }); 317 | 318 | // cp -r original tests 319 | fs.readdirSync(path.resolve(__dirname, 'original')).forEach(function(file) { 320 | fs.writeFileSync(path.resolve(__dirname, 'tests', file), 321 | fs.readFileSync(path.resolve(__dirname, 'original', file))); 322 | }); 323 | 324 | // node fix.js 325 | var dir = __dirname + '/tests'; 326 | 327 | // fix unencoded quotes 328 | fs.readdirSync(dir).filter(function(file) { 329 | return path.extname(file) === '.html'; 330 | }).forEach(function(file) { 331 | var file = path.join(dir, file) 332 | , html = fs.readFileSync(file, 'utf8'); 333 | 334 | html = html 335 | .replace(/='([^\n']*)'(?=[^<>\n]*>)/g, '=&__APOS__;$1&__APOS__;') 336 | .replace(/="([^\n"]*)"(?=[^<>\n]*>)/g, '=&__QUOT__;$1&__QUOT__;') 337 | .replace(/"/g, '"') 338 | .replace(/'/g, ''') 339 | .replace(/&__QUOT__;/g, '"') 340 | .replace(/&__APOS__;/g, '\''); 341 | 342 | fs.writeFileSync(file, html); 343 | }); 344 | 345 | // turn
into
346 | fs.readdirSync(dir).forEach(function(file) { 347 | var file = path.join(dir, file) 348 | , text = fs.readFileSync(file, 'utf8'); 349 | 350 | text = text.replace(/(<|<)hr\s*\/(>|>)/g, '$1hr$2'); 351 | 352 | fs.writeFileSync(file, text); 353 | }); 354 | 355 | // markdown does some strange things. 356 | // it does not encode naked `>`, marked does. 357 | (function() { 358 | var file = dir + '/amps_and_angles_encoding.html'; 359 | var html = fs.readFileSync(file, 'utf8') 360 | .replace('6 > 5.', '6 > 5.'); 361 | 362 | fs.writeFileSync(file, html); 363 | })(); 364 | 365 | // cp new/* tests/ 366 | fs.readdirSync(path.resolve(__dirname, 'new')).forEach(function(file) { 367 | fs.writeFileSync(path.resolve(__dirname, 'tests', file), 368 | fs.readFileSync(path.resolve(__dirname, 'new', file))); 369 | }); 370 | } 371 | 372 | /** 373 | * Argument Parsing 374 | */ 375 | 376 | function parseArg(argv) { 377 | var argv = process.argv.slice(2) 378 | , options = {} 379 | , orphans = [] 380 | , arg; 381 | 382 | function getarg() { 383 | var arg = argv.shift(); 384 | 385 | if (arg.indexOf('--') === 0) { 386 | // e.g. --opt 387 | arg = arg.split('='); 388 | if (arg.length > 1) { 389 | // e.g. --opt=val 390 | argv.unshift(arg.slice(1).join('=')); 391 | } 392 | arg = arg[0]; 393 | } else if (arg[0] === '-') { 394 | if (arg.length > 2) { 395 | // e.g. -abc 396 | argv = arg.substring(1).split('').map(function(ch) { 397 | return '-' + ch; 398 | }).concat(argv); 399 | arg = argv.shift(); 400 | } else { 401 | // e.g. -a 402 | } 403 | } else { 404 | // e.g. foo 405 | } 406 | 407 | return arg; 408 | } 409 | 410 | while (argv.length) { 411 | arg = getarg(); 412 | switch (arg) { 413 | case '-f': 414 | case '--fix': 415 | case 'fix': 416 | options.fix = true; 417 | break; 418 | case '-b': 419 | case '--bench': 420 | options.bench = true; 421 | break; 422 | case '-s': 423 | case '--stop': 424 | options.stop = true; 425 | break; 426 | case '-t': 427 | case '--time': 428 | options.time = true; 429 | break; 430 | default: 431 | if (arg.indexOf('--') === 0) { 432 | opt = camelize(arg.replace(/^--(no-)?/, '')); 433 | if (!marked.defaults.hasOwnProperty(opt)) { 434 | continue; 435 | } 436 | options.marked = options.marked || {}; 437 | if (arg.indexOf('--no-') === 0) { 438 | options.marked[opt] = typeof marked.defaults[opt] !== 'boolean' 439 | ? null 440 | : false; 441 | } else { 442 | options.marked[opt] = typeof marked.defaults[opt] !== 'boolean' 443 | ? argv.shift() 444 | : true; 445 | } 446 | } else { 447 | orphans.push(arg); 448 | } 449 | break; 450 | } 451 | } 452 | 453 | return options; 454 | } 455 | 456 | /** 457 | * Helpers 458 | */ 459 | 460 | function camelize(text) { 461 | return text.replace(/(\w)-(\w)/g, function(_, a, b) { 462 | return a + b.toUpperCase(); 463 | }); 464 | } 465 | 466 | /** 467 | * Main 468 | */ 469 | 470 | function main(argv) { 471 | var opt = parseArg(); 472 | 473 | if (opt.fix) { 474 | return fix(opt); 475 | } 476 | 477 | if (opt.bench) { 478 | return runBench(opt); 479 | } 480 | 481 | if (opt.time) { 482 | return time(opt); 483 | } 484 | 485 | return runTests(opt); 486 | } 487 | 488 | /** 489 | * Execute 490 | */ 491 | 492 | if (!module.parent) { 493 | process.title = 'marked'; 494 | main(process.argv.slice()); 495 | } else { 496 | exports = main; 497 | exports.main = main; 498 | exports.runTests = runTests; 499 | exports.runBench = runBench; 500 | exports.load = load; 501 | exports.bench = bench; 502 | module.exports = exports; 503 | } 504 | -------------------------------------------------------------------------------- /test/new/autolink_lines.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | http://example.com 3 |

4 | -------------------------------------------------------------------------------- /test/new/autolink_lines.text: -------------------------------------------------------------------------------- 1 | hello world 2 | 3 | -------------------------------------------------------------------------------- /test/new/blockquote_list_item.html: -------------------------------------------------------------------------------- 1 |

This fails in markdown.pl and upskirt:

2 | 3 |
  • hello

    world

4 | -------------------------------------------------------------------------------- /test/new/blockquote_list_item.text: -------------------------------------------------------------------------------- 1 | This fails in markdown.pl and upskirt: 2 | 3 | * hello 4 | > world 5 | -------------------------------------------------------------------------------- /test/new/case_insensitive_refs.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/new/case_insensitive_refs.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [HI]: /url 4 | -------------------------------------------------------------------------------- /test/new/def_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

hello 3 | [1]: hello

4 |
5 | 6 |
7 | 8 |
9 |

hello

10 |
11 | 12 | 13 |
    14 |
  • hello
  • 15 |
  • [3]: hello
  • 16 |
17 | 18 | 19 |
    20 |
  • hello
  • 21 |
22 | 23 | 24 |
25 |

foo 26 | bar 27 | bar

28 |
29 | -------------------------------------------------------------------------------- /test/new/def_blocks.text: -------------------------------------------------------------------------------- 1 | > hello 2 | > [1]: hello 3 | 4 | * * * 5 | 6 | > hello 7 | [2]: hello 8 | 9 | 10 | * hello 11 | * [3]: hello 12 | 13 | 14 | * hello 15 | [4]: hello 16 | 17 | 18 | > foo 19 | > bar 20 | [1]: foo 21 | > bar 22 | -------------------------------------------------------------------------------- /test/new/double_link.html: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 |

Already linked: http://example.com/.

4 | 5 |

Already linked: http://example.com/.

6 | -------------------------------------------------------------------------------- /test/new/double_link.text: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 | Already linked: [http://example.com/](http://example.com/). 4 | 5 | Already linked: **http://example.com/**. 6 | -------------------------------------------------------------------------------- /test/new/escaped_angles.html: -------------------------------------------------------------------------------- 1 |

>

2 | -------------------------------------------------------------------------------- /test/new/escaped_angles.text: -------------------------------------------------------------------------------- 1 | \> 2 | -------------------------------------------------------------------------------- /test/new/gfm_break.html: -------------------------------------------------------------------------------- 1 |

Look at the
pretty line
breaks.

2 | -------------------------------------------------------------------------------- /test/new/gfm_break.text: -------------------------------------------------------------------------------- 1 | Look at the 2 | pretty line 3 | breaks. 4 | -------------------------------------------------------------------------------- /test/new/gfm_code.html: -------------------------------------------------------------------------------- 1 |
var a = 'hello';
2 | console.log(a + ' world');
3 |
echo "hello, ${WORLD}"
4 |
Q: What do you call a tall person who sells stolen goods?
5 |
A longfence!
6 | -------------------------------------------------------------------------------- /test/new/gfm_code.text: -------------------------------------------------------------------------------- 1 | ``` js 2 | var a = 'hello'; 3 | console.log(a + ' world'); 4 | ``` 5 | 6 | ~~~bash 7 | echo "hello, ${WORLD}" 8 | ~~~ 9 | 10 | ```````longfence 11 | Q: What do you call a tall person who sells stolen goods? 12 | ``````` 13 | 14 | ~~~~~~~~~~ ManyTildes 15 | A longfence! 16 | ~~~~~~~~~~ 17 | -------------------------------------------------------------------------------- /test/new/gfm_code_hr_list.html: -------------------------------------------------------------------------------- 1 |

foo

2 |
    3 |
  1. bar:

    4 |
    5 |
      6 |
    • one
        7 |
      • two
          8 |
        • three
        • 9 |
        • four
        • 10 |
        • five
        • 11 |
        12 |
      • 13 |
      14 |
    • 15 |
    16 |
    17 |
  2. 18 |
  3. foo:

    19 |
     line 1
    20 |  line 2
    21 |
  4. 22 |
  5. foo:

    23 |
      24 |
    1. foo bar bar:

      25 |
       some code here
      26 | 
      27 |
    2. 28 |
    3. foo bar bar:

      29 |
       foo
      30 |  ---
      31 |  bar
      32 |  ---
      33 |  foo
      34 |  bar
      35 |
    4. 36 |
    5. foo bar bar:

      37 |
       ---
      38 |  foo
      39 |  foo
      40 |  ---
      41 |  bar
      42 |
    6. 43 |
    7. foo bar bar:

      44 |
       foo
      45 |  ---
      46 |  bar
      47 |
    8. 48 |
    9. foo

      49 |
    10. 50 |
    51 |
  6. 52 |
53 | -------------------------------------------------------------------------------- /test/new/gfm_code_hr_list.text: -------------------------------------------------------------------------------- 1 | ## foo 2 | 3 | 1. bar: 4 | 5 | > - one 6 | - two 7 | - three 8 | - four 9 | - five 10 | 11 | 1. foo: 12 | 13 | ``` 14 | line 1 15 | line 2 16 | ``` 17 | 18 | 1. foo: 19 | 20 | 1. foo `bar` bar: 21 | 22 | ``` erb 23 | some code here 24 | ``` 25 | 26 | 2. foo `bar` bar: 27 | 28 | ``` erb 29 | foo 30 | --- 31 | bar 32 | --- 33 | foo 34 | bar 35 | ``` 36 | 37 | 3. foo `bar` bar: 38 | 39 | ``` html 40 | --- 41 | foo 42 | foo 43 | --- 44 | bar 45 | ``` 46 | 47 | 4. foo `bar` bar: 48 | 49 | foo 50 | --- 51 | bar 52 | 53 | 5. foo 54 | -------------------------------------------------------------------------------- /test/new/gfm_del.html: -------------------------------------------------------------------------------- 1 |

hello hi world

2 | -------------------------------------------------------------------------------- /test/new/gfm_del.text: -------------------------------------------------------------------------------- 1 | hello ~~hi~~ world 2 | -------------------------------------------------------------------------------- /test/new/gfm_em.html: -------------------------------------------------------------------------------- 1 |

These words should_not_be_emphasized.

2 | -------------------------------------------------------------------------------- /test/new/gfm_em.text: -------------------------------------------------------------------------------- 1 | These words should_not_be_emphasized. 2 | -------------------------------------------------------------------------------- /test/new/gfm_links.html: -------------------------------------------------------------------------------- 1 |

This should be a link: 2 | http://example.com/hello-world.

3 | -------------------------------------------------------------------------------- /test/new/gfm_links.text: -------------------------------------------------------------------------------- 1 | This should be a link: http://example.com/hello-world. 2 | -------------------------------------------------------------------------------- /test/new/gfm_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Heading 1Heading 2
Cell 1Cell 2
Cell 3Cell 4
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
19 |
Test code
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Header 1Header 2
Cell 1Cell 2
Cell 3Cell 4
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
38 | 39 | -------------------------------------------------------------------------------- /test/new/gfm_tables.text: -------------------------------------------------------------------------------- 1 | | Heading 1 | Heading 2 2 | | --------- | --------- 3 | | Cell 1 | Cell 2 4 | | Cell 3 | Cell 4 5 | 6 | | Header 1 | Header 2 | Header 3 | Header 4 | 7 | | :------: | -------: | :------- | -------- | 8 | | Cell 1 | Cell 2 | Cell 3 | Cell 4 | 9 | | Cell 5 | Cell 6 | Cell 7 | Cell 8 | 10 | 11 | Test code 12 | 13 | Header 1 | Header 2 14 | -------- | -------- 15 | Cell 1 | Cell 2 16 | Cell 3 | Cell 4 17 | 18 | Header 1|Header 2|Header 3|Header 4 19 | :-------|:------:|-------:|-------- 20 | Cell 1 |Cell 2 |Cell 3 |Cell 4 21 | *Cell 5*|Cell 6 |Cell 7 |Cell 8 22 | -------------------------------------------------------------------------------- /test/new/hr_list_break.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • hello 3 | world
  • 4 |
  • how 5 | are
  • 6 |
7 | 8 |
9 | 10 |

you today?

11 | -------------------------------------------------------------------------------- /test/new/hr_list_break.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | * how 4 | are 5 | * * * 6 | you today? 7 | -------------------------------------------------------------------------------- /test/new/lazy_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

hi there 3 | bud

4 |
5 | -------------------------------------------------------------------------------- /test/new/lazy_blockquotes.text: -------------------------------------------------------------------------------- 1 | > hi there 2 | bud 3 | -------------------------------------------------------------------------------- /test/new/list_item_text.html: -------------------------------------------------------------------------------- 1 |
  • item1

    • item2

    text

2 | -------------------------------------------------------------------------------- /test/new/list_item_text.text: -------------------------------------------------------------------------------- 1 | * item1 2 | 3 | * item2 4 | 5 | text 6 | -------------------------------------------------------------------------------- /test/new/loose_lists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • hello 3 | world

    4 | 5 |

    how 6 | are

  • 7 |
  • you
  • 8 |
9 | 10 | 11 | 12 |

better behavior:

13 | 14 |
  • hello

    • world 15 | how

      are 16 | you

    • today

  • hi
17 | 18 | 19 | 20 |
    21 |
  • hello

  • 22 |
  • world

  • 23 |
  • hi
  • 24 |
25 | 26 | 27 | 28 |
    29 |
  • hello
  • 30 |
  • world

  • 31 |
  • hi

  • 32 |
33 | 34 | 35 | 36 |
    37 |
  • hello
  • 38 |
  • world

    39 | 40 |

    how

  • 41 |
  • hi
  • 42 |
43 | 44 | 45 | 46 |
    47 |
  • hello
  • 48 |
  • world
  • 49 |
  • how

    50 | 51 |

    are

  • 52 |
53 | 54 | 55 | 56 |
    57 |
  • hello
  • 58 |
  • world

  • 59 |
  • how

    60 | 61 |

    are

  • 62 |
63 | -------------------------------------------------------------------------------- /test/new/loose_lists.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | 4 | how 5 | are 6 | * you 7 | 8 | 9 | 10 | better behavior: 11 | 12 | * hello 13 | * world 14 | how 15 | 16 | are 17 | you 18 | 19 | * today 20 | * hi 21 | 22 | 23 | 24 | * hello 25 | 26 | * world 27 | * hi 28 | 29 | 30 | 31 | * hello 32 | * world 33 | 34 | * hi 35 | 36 | 37 | 38 | * hello 39 | * world 40 | 41 | how 42 | * hi 43 | 44 | 45 | 46 | * hello 47 | * world 48 | * how 49 | 50 | are 51 | 52 | 53 | 54 | * hello 55 | * world 56 | 57 | * how 58 | 59 | are 60 | -------------------------------------------------------------------------------- /test/new/main.html: -------------------------------------------------------------------------------- 1 |

A heading

Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.

A link. Not anymore.

  • List Item 1

  • List Item 2

    • New List Item 1 Hi, this is a list item.
    • New List Item 2 Another item
      Code goes here.
      3 | Lots of it...
    • New List Item 3 The last item
  • List Item 3 The final item.

  • List Item 4 The real final item.

Paragraph.

  • bq Item 1
  • bq Item 2
    • New bq Item 1
    • New bq Item 2 Text here

Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again

Another Heading

Hello world. Here is a link. And an image alt.

Code goes here.
4 | Lots of it...
5 | -------------------------------------------------------------------------------- /test/new/main.text: -------------------------------------------------------------------------------- 1 | [test]: http://google.com/ "Google" 2 | 3 | # A heading 4 | 5 | Just a note, I've found that I can't test my markdown parser vs others. 6 | For example, both markdown.js and showdown code blocks in lists wrong. They're 7 | also completely [inconsistent][test] with regards to paragraphs in list items. 8 | 9 | A link. Not anymore. 10 | 11 | 13 | 14 | * List Item 1 15 | 16 | * List Item 2 17 | * New List Item 1 18 | Hi, this is a list item. 19 | * New List Item 2 20 | Another item 21 | Code goes here. 22 | Lots of it... 23 | * New List Item 3 24 | The last item 25 | 26 | * List Item 3 27 | The final item. 28 | 29 | * List Item 4 30 | The real final item. 31 | 32 | Paragraph. 33 | 34 | > * bq Item 1 35 | > * bq Item 2 36 | > * New bq Item 1 37 | > * New bq Item 2 38 | > Text here 39 | 40 | * * * 41 | 42 | > Another blockquote! 43 | > I really need to get 44 | > more creative with 45 | > mockup text.. 46 | > markdown.js breaks here again 47 | 48 | Another Heading 49 | ------------- 50 | 51 | Hello *world*. Here is a [link](//hello). 52 | And an image ![alt](src). 53 | 54 | Code goes here. 55 | Lots of it... 56 | -------------------------------------------------------------------------------- /test/new/nested_code.html: -------------------------------------------------------------------------------- 1 |

hi ther `` ok ```

2 | -------------------------------------------------------------------------------- /test/new/nested_code.text: -------------------------------------------------------------------------------- 1 | ````` hi ther `` ok ``` ````` 2 | -------------------------------------------------------------------------------- /test/new/nested_em.html: -------------------------------------------------------------------------------- 1 |

test test test

2 | 3 |

test test test

4 | -------------------------------------------------------------------------------- /test/new/nested_em.text: -------------------------------------------------------------------------------- 1 | *test **test** test* 2 | 3 | _test __test__ test_ 4 | -------------------------------------------------------------------------------- /test/new/nested_square_link.html: -------------------------------------------------------------------------------- 1 |

the ] character

2 | -------------------------------------------------------------------------------- /test/new/nested_square_link.text: -------------------------------------------------------------------------------- 1 | [the `]` character](/url) 2 | -------------------------------------------------------------------------------- /test/new/not_a_link.html: -------------------------------------------------------------------------------- 1 |

\[test](not a link)

2 | -------------------------------------------------------------------------------- /test/new/not_a_link.text: -------------------------------------------------------------------------------- 1 | \\[test](not a link) 2 | -------------------------------------------------------------------------------- /test/new/ref_paren.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/new/ref_paren.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [hi]: /url (there) 4 | -------------------------------------------------------------------------------- /test/new/same_bullet.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • test
  • 3 |
  • test
  • 4 |
  • test
  • 5 |
6 | -------------------------------------------------------------------------------- /test/new/same_bullet.text: -------------------------------------------------------------------------------- 1 | * test 2 | + test 3 | - test 4 | -------------------------------------------------------------------------------- /test/new/text.smartypants.html: -------------------------------------------------------------------------------- 1 |

Hello world ‘how’ “are” you — today…

2 | -------------------------------------------------------------------------------- /test/new/text.smartypants.text: -------------------------------------------------------------------------------- 1 | Hello world 'how' "are" you -- today... 2 | -------------------------------------------------------------------------------- /test/new/toplevel_paragraphs.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | how are you 3 | how are you

4 | 5 |

hello world

6 |
how are you
7 | 8 |

hello world

9 |
10 | 11 |

hello world

12 |

how are you

13 | 14 |

hello world

15 |

how are you

16 | 17 |

hello world

18 |

how are you

19 | 20 |

hello world 21 | * how are you

22 | 23 |

hello world

24 |
how are you
25 | 26 |

hello world 27 | how are you

28 | 29 |

hello world 30 |

31 | 32 |
hello
33 | 34 |

hello

35 | -------------------------------------------------------------------------------- /test/new/toplevel_paragraphs.text: -------------------------------------------------------------------------------- 1 | hello world 2 | how are you 3 | how are you 4 | 5 | hello world 6 | ``` 7 | how are you 8 | ``` 9 | 10 | hello world 11 | * * * 12 | 13 | hello world 14 | # how are you 15 | 16 | hello world 17 | how are you 18 | =========== 19 | 20 | hello world 21 | > how are you 22 | 23 | hello world 24 | * how are you 25 | 26 | hello world 27 |
how are you
28 | 29 | hello world 30 | how are you 31 | 32 | hello [world][how] 33 | [how]: /are/you 34 | 35 |
hello
36 | 37 | hello 38 | -------------------------------------------------------------------------------- /test/new/tricky_list.html: -------------------------------------------------------------------------------- 1 |

hello world

2 | 3 |
    4 |
  • hello world
  • 5 |
6 | 7 |

hello world

8 | 9 |
    10 |
  • hello world
  • 11 |
12 | 13 |

hello world

14 | 15 |
    16 |
  • Hello world
  • 17 |
18 | 19 |

hello world

20 | 21 |
    22 |
  • hello world
  • 23 |
24 | -------------------------------------------------------------------------------- /test/new/tricky_list.text: -------------------------------------------------------------------------------- 1 | **hello** _world_ 2 | 3 | * hello world 4 | 5 | **hello** _world_ 6 | 7 | * hello world 8 | 9 | **hello** _world_ 10 | 11 | * Hello world 12 | 13 | **hello** _world_ 14 | 15 | * hello world 16 | -------------------------------------------------------------------------------- /test/original/amps_and_angles_encoding.html: -------------------------------------------------------------------------------- 1 |

AT&T has an ampersand in their name.

2 | 3 |

AT&T is another way to write it.

4 | 5 |

This & that.

6 | 7 |

4 < 5.

8 | 9 |

6 > 5.

10 | 11 |

Here's a link with an ampersand in the URL.

12 | 13 |

Here's a link with an amersand in the link text: AT&T.

14 | 15 |

Here's an inline link.

16 | 17 |

Here's an inline link.

18 | -------------------------------------------------------------------------------- /test/original/amps_and_angles_encoding.text: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" 22 | -------------------------------------------------------------------------------- /test/original/auto_links.html: -------------------------------------------------------------------------------- 1 |

Link: http://example.com/.

2 | 3 |

With an ampersand: http://example.com/?foo=1&bar=2

4 | 5 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

Auto-links should not occur here: <http://example.com/>

16 | 17 |
or here: <http://example.com/>
18 | 
19 | -------------------------------------------------------------------------------- /test/original/auto_links.text: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: 14 | -------------------------------------------------------------------------------- /test/original/backslash_escapes.html: -------------------------------------------------------------------------------- 1 |

These should all get escaped:

2 | 3 |

Backslash: \

4 | 5 |

Backtick: `

6 | 7 |

Asterisk: *

8 | 9 |

Underscore: _

10 | 11 |

Left brace: {

12 | 13 |

Right brace: }

14 | 15 |

Left bracket: [

16 | 17 |

Right bracket: ]

18 | 19 |

Left paren: (

20 | 21 |

Right paren: )

22 | 23 |

Greater-than: >

24 | 25 |

Hash: #

26 | 27 |

Period: .

28 | 29 |

Bang: !

30 | 31 |

Plus: +

32 | 33 |

Minus: -

34 | 35 |

These should not, because they occur within a code block:

36 | 37 |
Backslash: \\
 38 | 
 39 | Backtick: \`
 40 | 
 41 | Asterisk: \*
 42 | 
 43 | Underscore: \_
 44 | 
 45 | Left brace: \{
 46 | 
 47 | Right brace: \}
 48 | 
 49 | Left bracket: \[
 50 | 
 51 | Right bracket: \]
 52 | 
 53 | Left paren: \(
 54 | 
 55 | Right paren: \)
 56 | 
 57 | Greater-than: \>
 58 | 
 59 | Hash: \#
 60 | 
 61 | Period: \.
 62 | 
 63 | Bang: \!
 64 | 
 65 | Plus: \+
 66 | 
 67 | Minus: \-
 68 | 
69 | 70 |

Nor should these, which occur in code spans:

71 | 72 |

Backslash: \\

73 | 74 |

Backtick: \`

75 | 76 |

Asterisk: \*

77 | 78 |

Underscore: \_

79 | 80 |

Left brace: \{

81 | 82 |

Right brace: \}

83 | 84 |

Left bracket: \[

85 | 86 |

Right bracket: \]

87 | 88 |

Left paren: \(

89 | 90 |

Right paren: \)

91 | 92 |

Greater-than: \>

93 | 94 |

Hash: \#

95 | 96 |

Period: \.

97 | 98 |

Bang: \!

99 | 100 |

Plus: \+

101 | 102 |

Minus: \-

103 | 104 | 105 |

These should get escaped, even though they're matching pairs for 106 | other Markdown constructs:

107 | 108 |

*asterisks*

109 | 110 |

_underscores_

111 | 112 |

`backticks`

113 | 114 |

This is a code span with a literal backslash-backtick sequence: \`

115 | 116 |

This is a tag with unescaped backticks bar.

117 | 118 |

This is a tag with backslashes bar.

119 | -------------------------------------------------------------------------------- /test/original/backslash_escapes.text: -------------------------------------------------------------------------------- 1 | These should all get escaped: 2 | 3 | Backslash: \\ 4 | 5 | Backtick: \` 6 | 7 | Asterisk: \* 8 | 9 | Underscore: \_ 10 | 11 | Left brace: \{ 12 | 13 | Right brace: \} 14 | 15 | Left bracket: \[ 16 | 17 | Right bracket: \] 18 | 19 | Left paren: \( 20 | 21 | Right paren: \) 22 | 23 | Greater-than: \> 24 | 25 | Hash: \# 26 | 27 | Period: \. 28 | 29 | Bang: \! 30 | 31 | Plus: \+ 32 | 33 | Minus: \- 34 | 35 | 36 | 37 | These should not, because they occur within a code block: 38 | 39 | Backslash: \\ 40 | 41 | Backtick: \` 42 | 43 | Asterisk: \* 44 | 45 | Underscore: \_ 46 | 47 | Left brace: \{ 48 | 49 | Right brace: \} 50 | 51 | Left bracket: \[ 52 | 53 | Right bracket: \] 54 | 55 | Left paren: \( 56 | 57 | Right paren: \) 58 | 59 | Greater-than: \> 60 | 61 | Hash: \# 62 | 63 | Period: \. 64 | 65 | Bang: \! 66 | 67 | Plus: \+ 68 | 69 | Minus: \- 70 | 71 | 72 | Nor should these, which occur in code spans: 73 | 74 | Backslash: `\\` 75 | 76 | Backtick: `` \` `` 77 | 78 | Asterisk: `\*` 79 | 80 | Underscore: `\_` 81 | 82 | Left brace: `\{` 83 | 84 | Right brace: `\}` 85 | 86 | Left bracket: `\[` 87 | 88 | Right bracket: `\]` 89 | 90 | Left paren: `\(` 91 | 92 | Right paren: `\)` 93 | 94 | Greater-than: `\>` 95 | 96 | Hash: `\#` 97 | 98 | Period: `\.` 99 | 100 | Bang: `\!` 101 | 102 | Plus: `\+` 103 | 104 | Minus: `\-` 105 | 106 | 107 | These should get escaped, even though they're matching pairs for 108 | other Markdown constructs: 109 | 110 | \*asterisks\* 111 | 112 | \_underscores\_ 113 | 114 | \`backticks\` 115 | 116 | This is a code span with a literal backslash-backtick sequence: `` \` `` 117 | 118 | This is a tag with unescaped backticks bar. 119 | 120 | This is a tag with backslashes bar. 121 | -------------------------------------------------------------------------------- /test/original/blockquotes_with_code_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

3 | 4 |
sub status {
 5 |     print "working";
 6 | }
 7 | 
8 | 9 |

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /test/original/blockquotes_with_code_blocks.text: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /test/original/code_blocks.html: -------------------------------------------------------------------------------- 1 |
code block on the first line
 2 | 
3 | 4 |

Regular text.

5 | 6 |
code block indented by spaces
 7 | 
8 | 9 |

Regular text.

10 | 11 |
the lines in this block  
12 | all contain trailing spaces  
13 | 
14 | 15 |

Regular Text.

16 | 17 |
code block on the last line
18 | 
19 | -------------------------------------------------------------------------------- /test/original/code_blocks.text: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line 15 | -------------------------------------------------------------------------------- /test/original/code_spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 | 3 |

Fix for backticks within HTML tag: like this

4 | 5 |

Here's how you put `backticks` in a code span.

6 | 7 | -------------------------------------------------------------------------------- /test/original/code_spans.text: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. 6 | 7 | -------------------------------------------------------------------------------- /test/original/hard_wrapped_paragraphs_with_list_like_lines.html: -------------------------------------------------------------------------------- 1 |

In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.

6 | 7 |

Here's one with a bullet. 8 | * criminey.

9 | -------------------------------------------------------------------------------- /test/original/hard_wrapped_paragraphs_with_list_like_lines.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /test/original/horizontal_rules.html: -------------------------------------------------------------------------------- 1 |

Dashes:

2 | 3 |
4 | 5 |
6 | 7 |
8 | 9 |
10 | 11 |
---
12 | 
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
- - -
23 | 
24 | 25 |

Asterisks:

26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
***
36 | 
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
* * *
47 | 
48 | 49 |

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | -------------------------------------------------------------------------------- /test/original/horizontal_rules.text: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /test/original/inline_html_advanced.html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/original/inline_html_advanced.text: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/original/inline_html_comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 | 8 | 9 |

Paragraph two.

10 | 11 | 12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /test/original/inline_html_comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /test/original/inline_html_simple.html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 | 3 |
4 | foo 5 |
6 | 7 |

This should be a code block, though:

8 | 9 |
<div>
10 |     foo
11 | </div>
12 | 
13 | 14 |

As should this:

15 | 16 |
<div>foo</div>
17 | 
18 | 19 |

Now, nested:

20 | 21 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

This should just be an HTML comment:

30 | 31 | 32 | 33 |

Multiline:

34 | 35 | 39 | 40 |

Code block:

41 | 42 |
<!-- Comment -->
43 | 
44 | 45 |

Just plain comment, with trailing spaces on the line:

46 | 47 | 48 | 49 |

Code:

50 | 51 |
<hr />
52 | 
53 | 54 |

Hr's:

55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /test/original/inline_html_simple.text: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /test/original/links_inline_style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 | 3 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

URL and title.

10 | 11 |

Empty.

12 | -------------------------------------------------------------------------------- /test/original/links_inline_style.text: -------------------------------------------------------------------------------- 1 | Just a [URL](/url/). 2 | 3 | [URL and title](/url/ "title"). 4 | 5 | [URL and title](/url/ "title preceded by two spaces"). 6 | 7 | [URL and title](/url/ "title preceded by a tab"). 8 | 9 | [URL and title](/url/ "title has spaces afterward" ). 10 | 11 | 12 | [Empty](). 13 | -------------------------------------------------------------------------------- /test/original/links_reference_style.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | 5 |

Foo bar.

6 | 7 |

With embedded [brackets].

8 | 9 |

Indented once.

10 | 11 |

Indented twice.

12 | 13 |

Indented thrice.

14 | 15 |

Indented [four][] times.

16 | 17 |
[four]: /url
18 | 
19 | 20 |
21 | 22 |

this should work

23 | 24 |

So should this.

25 | 26 |

And this.

27 | 28 |

And this.

29 | 30 |

And this.

31 | 32 |

But not [that] [].

33 | 34 |

Nor [that][].

35 | 36 |

Nor [that].

37 | 38 |

[Something in brackets like this should work]

39 | 40 |

[Same with this.]

41 | 42 |

In this case, this points to something else.

43 | 44 |

Backslashing should suppress [this] and [this].

45 | 46 |
47 | 48 |

Here's one where the link 49 | breaks across lines.

50 | 51 |

Here's another where the link 52 | breaks across lines, but with a line-ending space.

53 | -------------------------------------------------------------------------------- /test/original/links_reference_style.text: -------------------------------------------------------------------------------- 1 | Foo [bar] [1]. 2 | 3 | Foo [bar][1]. 4 | 5 | Foo [bar] 6 | [1]. 7 | 8 | [1]: /url/ "Title" 9 | 10 | 11 | With [embedded [brackets]] [b]. 12 | 13 | 14 | Indented [once][]. 15 | 16 | Indented [twice][]. 17 | 18 | Indented [thrice][]. 19 | 20 | Indented [four][] times. 21 | 22 | [once]: /url 23 | 24 | [twice]: /url 25 | 26 | [thrice]: /url 27 | 28 | [four]: /url 29 | 30 | 31 | [b]: /url/ 32 | 33 | * * * 34 | 35 | [this] [this] should work 36 | 37 | So should [this][this]. 38 | 39 | And [this] []. 40 | 41 | And [this][]. 42 | 43 | And [this]. 44 | 45 | But not [that] []. 46 | 47 | Nor [that][]. 48 | 49 | Nor [that]. 50 | 51 | [Something in brackets like [this][] should work] 52 | 53 | [Same with [this].] 54 | 55 | In this case, [this](/somethingelse/) points to something else. 56 | 57 | Backslashing should suppress \[this] and [this\]. 58 | 59 | [this]: foo 60 | 61 | 62 | * * * 63 | 64 | Here's one where the [link 65 | breaks] across lines. 66 | 67 | Here's another where the [link 68 | breaks] across lines, but with a line-ending space. 69 | 70 | 71 | [link breaks]: /url/ 72 | -------------------------------------------------------------------------------- /test/original/links_shortcut_references.html: -------------------------------------------------------------------------------- 1 |

This is the simple case.

2 | 3 |

This one has a line 4 | break.

5 | 6 |

This one has a line 7 | break with a line-ending space.

8 | 9 |

this and the other

10 | -------------------------------------------------------------------------------- /test/original/links_shortcut_references.text: -------------------------------------------------------------------------------- 1 | This is the [simple case]. 2 | 3 | [simple case]: /simple 4 | 5 | 6 | 7 | This one has a [line 8 | break]. 9 | 10 | This one has a [line 11 | break] with a line-ending space. 12 | 13 | [line break]: /foo 14 | 15 | 16 | [this] [that] and the [other] 17 | 18 | [this]: /this 19 | [that]: /that 20 | [other]: /other 21 | -------------------------------------------------------------------------------- /test/original/literal_quotes_in_titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /test/original/literal_quotes_in_titles.text: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /test/original/markdown_documentation_basics.html: -------------------------------------------------------------------------------- 1 |

Markdown: Basics

2 | 3 | 10 | 11 |

Getting the Gist of Markdown's Formatting Syntax

12 | 13 |

This page offers a brief overview of what it's like to use Markdown. 14 | The syntax page provides complete, detailed documentation for 15 | every feature, but Markdown should be very easy to pick up simply by 16 | looking at a few examples of it in action. The examples on this page 17 | are written in a before/after style, showing example syntax and the 18 | HTML output produced by Markdown.

19 | 20 |

It's also helpful to simply try Markdown out; the Dingus is a 21 | web application that allows you type your own Markdown-formatted text 22 | and translate it to XHTML.

23 | 24 |

Note: This document is itself written using Markdown; you 25 | can see the source for it by adding '.text' to the URL.

26 | 27 |

Paragraphs, Headers, Blockquotes

28 | 29 |

A paragraph is simply one or more consecutive lines of text, separated 30 | by one or more blank lines. (A blank line is any line that looks like a 31 | blank line -- a line containing nothing spaces or tabs is considered 32 | blank.) Normal paragraphs should not be intended with spaces or tabs.

33 | 34 |

Markdown offers two styles of headers: Setext and atx. 35 | Setext-style headers for <h1> and <h2> are created by 36 | "underlining" with equal signs (=) and hyphens (-), respectively. 37 | To create an atx-style header, you put 1-6 hash marks (#) at the 38 | beginning of the line -- the number of hashes equals the resulting 39 | HTML header level.

40 | 41 |

Blockquotes are indicated using email-style '>' angle brackets.

42 | 43 |

Markdown:

44 | 45 |
A First Level Header
 46 | ====================
 47 | 
 48 | A Second Level Header
 49 | ---------------------
 50 | 
 51 | Now is the time for all good men to come to
 52 | the aid of their country. This is just a
 53 | regular paragraph.
 54 | 
 55 | The quick brown fox jumped over the lazy
 56 | dog's back.
 57 | 
 58 | ### Header 3
 59 | 
 60 | > This is a blockquote.
 61 | > 
 62 | > This is the second paragraph in the blockquote.
 63 | >
 64 | > ## This is an H2 in a blockquote
 65 | 
66 | 67 |

Output:

68 | 69 |
<h1>A First Level Header</h1>
 70 | 
 71 | <h2>A Second Level Header</h2>
 72 | 
 73 | <p>Now is the time for all good men to come to
 74 | the aid of their country. This is just a
 75 | regular paragraph.</p>
 76 | 
 77 | <p>The quick brown fox jumped over the lazy
 78 | dog's back.</p>
 79 | 
 80 | <h3>Header 3</h3>
 81 | 
 82 | <blockquote>
 83 |     <p>This is a blockquote.</p>
 84 | 
 85 |     <p>This is the second paragraph in the blockquote.</p>
 86 | 
 87 |     <h2>This is an H2 in a blockquote</h2>
 88 | </blockquote>
 89 | 
90 | 91 |

Phrase Emphasis

92 | 93 |

Markdown uses asterisks and underscores to indicate spans of emphasis.

94 | 95 |

Markdown:

96 | 97 |
Some of these words *are emphasized*.
 98 | Some of these words _are emphasized also_.
 99 | 
100 | Use two asterisks for **strong emphasis**.
101 | Or, if you prefer, __use two underscores instead__.
102 | 
103 | 104 |

Output:

105 | 106 |
<p>Some of these words <em>are emphasized</em>.
107 | Some of these words <em>are emphasized also</em>.</p>
108 | 
109 | <p>Use two asterisks for <strong>strong emphasis</strong>.
110 | Or, if you prefer, <strong>use two underscores instead</strong>.</p>
111 | 
112 | 113 |

Lists

114 | 115 |

Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, 116 | +, and -) as list markers. These three markers are 117 | interchangable; this:

118 | 119 |
*   Candy.
120 | *   Gum.
121 | *   Booze.
122 | 
123 | 124 |

this:

125 | 126 |
+   Candy.
127 | +   Gum.
128 | +   Booze.
129 | 
130 | 131 |

and this:

132 | 133 |
-   Candy.
134 | -   Gum.
135 | -   Booze.
136 | 
137 | 138 |

all produce the same output:

139 | 140 |
<ul>
141 | <li>Candy.</li>
142 | <li>Gum.</li>
143 | <li>Booze.</li>
144 | </ul>
145 | 
146 | 147 |

Ordered (numbered) lists use regular numbers, followed by periods, as 148 | list markers:

149 | 150 |
1.  Red
151 | 2.  Green
152 | 3.  Blue
153 | 
154 | 155 |

Output:

156 | 157 |
<ol>
158 | <li>Red</li>
159 | <li>Green</li>
160 | <li>Blue</li>
161 | </ol>
162 | 
163 | 164 |

If you put blank lines between items, you'll get <p> tags for the 165 | list item text. You can create multi-paragraph list items by indenting 166 | the paragraphs by 4 spaces or 1 tab:

167 | 168 |
*   A list item.
169 | 
170 |     With multiple paragraphs.
171 | 
172 | *   Another item in the list.
173 | 
174 | 175 |

Output:

176 | 177 |
<ul>
178 | <li><p>A list item.</p>
179 | <p>With multiple paragraphs.</p></li>
180 | <li><p>Another item in the list.</p></li>
181 | </ul>
182 | 
183 | 184 |

Links

185 | 186 |

Markdown supports two styles for creating links: inline and 187 | reference. With both styles, you use square brackets to delimit the 188 | text you want to turn into a link.

189 | 190 |

Inline-style links use parentheses immediately after the link text. 191 | For example:

192 | 193 |
This is an [example link](http://example.com/).
194 | 
195 | 196 |

Output:

197 | 198 |
<p>This is an <a href="http://example.com/">
199 | example link</a>.</p>
200 | 
201 | 202 |

Optionally, you may include a title attribute in the parentheses:

203 | 204 |
This is an [example link](http://example.com/ "With a Title").
205 | 
206 | 207 |

Output:

208 | 209 |
<p>This is an <a href="http://example.com/" title="With a Title">
210 | example link</a>.</p>
211 | 
212 | 213 |

Reference-style links allow you to refer to your links by names, which 214 | you define elsewhere in your document:

215 | 216 |
I get 10 times more traffic from [Google][1] than from
217 | [Yahoo][2] or [MSN][3].
218 | 
219 | [1]: http://google.com/        "Google"
220 | [2]: http://search.yahoo.com/  "Yahoo Search"
221 | [3]: http://search.msn.com/    "MSN Search"
222 | 
223 | 224 |

Output:

225 | 226 |
<p>I get 10 times more traffic from <a href="http://google.com/"
227 | title="Google">Google</a> than from <a href="http://search.yahoo.com/"
228 | title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
229 | title="MSN Search">MSN</a>.</p>
230 | 
231 | 232 |

The title attribute is optional. Link names may contain letters, 233 | numbers and spaces, but are not case sensitive:

234 | 235 |
I start my morning with a cup of coffee and
236 | [The New York Times][NY Times].
237 | 
238 | [ny times]: http://www.nytimes.com/
239 | 
240 | 241 |

Output:

242 | 243 |
<p>I start my morning with a cup of coffee and
244 | <a href="http://www.nytimes.com/">The New York Times</a>.</p>
245 | 
246 | 247 |

Images

248 | 249 |

Image syntax is very much like link syntax.

250 | 251 |

Inline (titles are optional):

252 | 253 |
![alt text](/path/to/img.jpg "Title")
254 | 
255 | 256 |

Reference-style:

257 | 258 |
![alt text][id]
259 | 
260 | [id]: /path/to/img.jpg "Title"
261 | 
262 | 263 |

Both of the above examples produce the same output:

264 | 265 |
<img src="/path/to/img.jpg" alt="alt text" title="Title" />
266 | 
267 | 268 |

Code

269 | 270 |

In a regular paragraph, you can create code span by wrapping text in 271 | backtick quotes. Any ampersands (&) and angle brackets (< or 272 | >) will automatically be translated into HTML entities. This makes 273 | it easy to use Markdown to write about HTML example code:

274 | 275 |
I strongly recommend against using any `<blink>` tags.
276 | 
277 | I wish SmartyPants used named entities like `&mdash;`
278 | instead of decimal-encoded entites like `&#8212;`.
279 | 
280 | 281 |

Output:

282 | 283 |
<p>I strongly recommend against using any
284 | <code>&lt;blink&gt;</code> tags.</p>
285 | 
286 | <p>I wish SmartyPants used named entities like
287 | <code>&amp;mdash;</code> instead of decimal-encoded
288 | entites like <code>&amp;#8212;</code>.</p>
289 | 
290 | 291 |

To specify an entire block of pre-formatted code, indent every line of 292 | the block by 4 spaces or 1 tab. Just like with code spans, &, <, 293 | and > characters will be escaped automatically.

294 | 295 |

Markdown:

296 | 297 |
If you want your page to validate under XHTML 1.0 Strict,
298 | you've got to put paragraph tags in your blockquotes:
299 | 
300 |     <blockquote>
301 |         <p>For example.</p>
302 |     </blockquote>
303 | 
304 | 305 |

Output:

306 | 307 |
<p>If you want your page to validate under XHTML 1.0 Strict,
308 | you've got to put paragraph tags in your blockquotes:</p>
309 | 
310 | <pre><code>&lt;blockquote&gt;
311 |     &lt;p&gt;For example.&lt;/p&gt;
312 | &lt;/blockquote&gt;
313 | </code></pre>
314 | 
315 | -------------------------------------------------------------------------------- /test/original/markdown_documentation_basics.text: -------------------------------------------------------------------------------- 1 | Markdown: Basics 2 | ================ 3 | 4 | 11 | 12 | 13 | Getting the Gist of Markdown's Formatting Syntax 14 | ------------------------------------------------ 15 | 16 | This page offers a brief overview of what it's like to use Markdown. 17 | The [syntax page] [s] provides complete, detailed documentation for 18 | every feature, but Markdown should be very easy to pick up simply by 19 | looking at a few examples of it in action. The examples on this page 20 | are written in a before/after style, showing example syntax and the 21 | HTML output produced by Markdown. 22 | 23 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a 24 | web application that allows you type your own Markdown-formatted text 25 | and translate it to XHTML. 26 | 27 | **Note:** This document is itself written using Markdown; you 28 | can [see the source for it by adding '.text' to the URL] [src]. 29 | 30 | [s]: /projects/markdown/syntax "Markdown Syntax" 31 | [d]: /projects/markdown/dingus "Markdown Dingus" 32 | [src]: /projects/markdown/basics.text 33 | 34 | 35 | ## Paragraphs, Headers, Blockquotes ## 36 | 37 | A paragraph is simply one or more consecutive lines of text, separated 38 | by one or more blank lines. (A blank line is any line that looks like a 39 | blank line -- a line containing nothing spaces or tabs is considered 40 | blank.) Normal paragraphs should not be intended with spaces or tabs. 41 | 42 | Markdown offers two styles of headers: *Setext* and *atx*. 43 | Setext-style headers for `

` and `

` are created by 44 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively. 45 | To create an atx-style header, you put 1-6 hash marks (`#`) at the 46 | beginning of the line -- the number of hashes equals the resulting 47 | HTML header level. 48 | 49 | Blockquotes are indicated using email-style '`>`' angle brackets. 50 | 51 | Markdown: 52 | 53 | A First Level Header 54 | ==================== 55 | 56 | A Second Level Header 57 | --------------------- 58 | 59 | Now is the time for all good men to come to 60 | the aid of their country. This is just a 61 | regular paragraph. 62 | 63 | The quick brown fox jumped over the lazy 64 | dog's back. 65 | 66 | ### Header 3 67 | 68 | > This is a blockquote. 69 | > 70 | > This is the second paragraph in the blockquote. 71 | > 72 | > ## This is an H2 in a blockquote 73 | 74 | 75 | Output: 76 | 77 |

A First Level Header

78 | 79 |

A Second Level Header

80 | 81 |

Now is the time for all good men to come to 82 | the aid of their country. This is just a 83 | regular paragraph.

84 | 85 |

The quick brown fox jumped over the lazy 86 | dog's back.

87 | 88 |

Header 3

89 | 90 |
91 |

This is a blockquote.

92 | 93 |

This is the second paragraph in the blockquote.

94 | 95 |

This is an H2 in a blockquote

96 |
97 | 98 | 99 | 100 | ### Phrase Emphasis ### 101 | 102 | Markdown uses asterisks and underscores to indicate spans of emphasis. 103 | 104 | Markdown: 105 | 106 | Some of these words *are emphasized*. 107 | Some of these words _are emphasized also_. 108 | 109 | Use two asterisks for **strong emphasis**. 110 | Or, if you prefer, __use two underscores instead__. 111 | 112 | Output: 113 | 114 |

Some of these words are emphasized. 115 | Some of these words are emphasized also.

116 | 117 |

Use two asterisks for strong emphasis. 118 | Or, if you prefer, use two underscores instead.

119 | 120 | 121 | 122 | ## Lists ## 123 | 124 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, 125 | `+`, and `-`) as list markers. These three markers are 126 | interchangable; this: 127 | 128 | * Candy. 129 | * Gum. 130 | * Booze. 131 | 132 | this: 133 | 134 | + Candy. 135 | + Gum. 136 | + Booze. 137 | 138 | and this: 139 | 140 | - Candy. 141 | - Gum. 142 | - Booze. 143 | 144 | all produce the same output: 145 | 146 |
    147 |
  • Candy.
  • 148 |
  • Gum.
  • 149 |
  • Booze.
  • 150 |
151 | 152 | Ordered (numbered) lists use regular numbers, followed by periods, as 153 | list markers: 154 | 155 | 1. Red 156 | 2. Green 157 | 3. Blue 158 | 159 | Output: 160 | 161 |
    162 |
  1. Red
  2. 163 |
  3. Green
  4. 164 |
  5. Blue
  6. 165 |
166 | 167 | If you put blank lines between items, you'll get `

` tags for the 168 | list item text. You can create multi-paragraph list items by indenting 169 | the paragraphs by 4 spaces or 1 tab: 170 | 171 | * A list item. 172 | 173 | With multiple paragraphs. 174 | 175 | * Another item in the list. 176 | 177 | Output: 178 | 179 |

    180 |
  • A list item.

    181 |

    With multiple paragraphs.

  • 182 |
  • Another item in the list.

  • 183 |
184 | 185 | 186 | 187 | ### Links ### 188 | 189 | Markdown supports two styles for creating links: *inline* and 190 | *reference*. With both styles, you use square brackets to delimit the 191 | text you want to turn into a link. 192 | 193 | Inline-style links use parentheses immediately after the link text. 194 | For example: 195 | 196 | This is an [example link](http://example.com/). 197 | 198 | Output: 199 | 200 |

This is an 201 | example link.

202 | 203 | Optionally, you may include a title attribute in the parentheses: 204 | 205 | This is an [example link](http://example.com/ "With a Title"). 206 | 207 | Output: 208 | 209 |

This is an 210 | example link.

211 | 212 | Reference-style links allow you to refer to your links by names, which 213 | you define elsewhere in your document: 214 | 215 | I get 10 times more traffic from [Google][1] than from 216 | [Yahoo][2] or [MSN][3]. 217 | 218 | [1]: http://google.com/ "Google" 219 | [2]: http://search.yahoo.com/ "Yahoo Search" 220 | [3]: http://search.msn.com/ "MSN Search" 221 | 222 | Output: 223 | 224 |

I get 10 times more traffic from Google than from Yahoo or MSN.

228 | 229 | The title attribute is optional. Link names may contain letters, 230 | numbers and spaces, but are *not* case sensitive: 231 | 232 | I start my morning with a cup of coffee and 233 | [The New York Times][NY Times]. 234 | 235 | [ny times]: http://www.nytimes.com/ 236 | 237 | Output: 238 | 239 |

I start my morning with a cup of coffee and 240 | The New York Times.

241 | 242 | 243 | ### Images ### 244 | 245 | Image syntax is very much like link syntax. 246 | 247 | Inline (titles are optional): 248 | 249 | ![alt text](/path/to/img.jpg "Title") 250 | 251 | Reference-style: 252 | 253 | ![alt text][id] 254 | 255 | [id]: /path/to/img.jpg "Title" 256 | 257 | Both of the above examples produce the same output: 258 | 259 | alt text 260 | 261 | 262 | 263 | ### Code ### 264 | 265 | In a regular paragraph, you can create code span by wrapping text in 266 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or 267 | `>`) will automatically be translated into HTML entities. This makes 268 | it easy to use Markdown to write about HTML example code: 269 | 270 | I strongly recommend against using any `` tags. 271 | 272 | I wish SmartyPants used named entities like `—` 273 | instead of decimal-encoded entites like `—`. 274 | 275 | Output: 276 | 277 |

I strongly recommend against using any 278 | <blink> tags.

279 | 280 |

I wish SmartyPants used named entities like 281 | &mdash; instead of decimal-encoded 282 | entites like &#8212;.

283 | 284 | 285 | To specify an entire block of pre-formatted code, indent every line of 286 | the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, 287 | and `>` characters will be escaped automatically. 288 | 289 | Markdown: 290 | 291 | If you want your page to validate under XHTML 1.0 Strict, 292 | you've got to put paragraph tags in your blockquotes: 293 | 294 |
295 |

For example.

296 |
297 | 298 | Output: 299 | 300 |

If you want your page to validate under XHTML 1.0 Strict, 301 | you've got to put paragraph tags in your blockquotes:

302 | 303 |
<blockquote>
304 |         <p>For example.</p>
305 |     </blockquote>
306 |     
307 | -------------------------------------------------------------------------------- /test/original/nested_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /test/original/nested_blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /test/original/ordered_and_unordered_lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

4 | 5 |
    6 |
  • asterisk 1
  • 7 |
  • asterisk 2
  • 8 |
  • asterisk 3
  • 9 |
10 | 11 |

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 |
  • asterisk 2

  • 16 |
  • asterisk 3

  • 17 |
18 | 19 |
20 | 21 |

Pluses tight:

22 | 23 |
    24 |
  • Plus 1
  • 25 |
  • Plus 2
  • 26 |
  • Plus 3
  • 27 |
28 | 29 |

Pluses loose:

30 | 31 |
    32 |
  • Plus 1

  • 33 |
  • Plus 2

  • 34 |
  • Plus 3

  • 35 |
36 | 37 |
38 | 39 |

Minuses tight:

40 | 41 |
    42 |
  • Minus 1
  • 43 |
  • Minus 2
  • 44 |
  • Minus 3
  • 45 |
46 | 47 |

Minuses loose:

48 | 49 |
    50 |
  • Minus 1

  • 51 |
  • Minus 2

  • 52 |
  • Minus 3

  • 53 |
54 | 55 |

Ordered

56 | 57 |

Tight:

58 | 59 |
    60 |
  1. First
  2. 61 |
  3. Second
  4. 62 |
  5. Third
  6. 63 |
64 | 65 |

and:

66 | 67 |
    68 |
  1. One
  2. 69 |
  3. Two
  4. 70 |
  5. Three
  6. 71 |
72 | 73 |

Loose using tabs:

74 | 75 |
    76 |
  1. First

  2. 77 |
  3. Second

  4. 78 |
  5. Third

  6. 79 |
80 | 81 |

and using spaces:

82 | 83 |
    84 |
  1. One

  2. 85 |
  3. Two

  4. 86 |
  5. Three

  6. 87 |
88 | 89 |

Multiple paragraphs:

90 | 91 |
    92 |
  1. Item 1, graf one.

    93 | 94 |

    Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.

  2. 96 |
  3. Item 2.

  4. 97 |
  5. Item 3.

  6. 98 |
99 | 100 |

Nested

101 | 102 |
    103 |
  • Tab 104 |
      105 |
    • Tab 106 |
        107 |
      • Tab
      • 108 |
    • 109 |
  • 110 |
111 | 112 |

Here's another:

113 | 114 |
    115 |
  1. First
  2. 116 |
  3. Second: 117 |
      118 |
    • Fee
    • 119 |
    • Fie
    • 120 |
    • Foe
    • 121 |
  4. 122 |
  5. Third
  6. 123 |
124 | 125 |

Same thing but with paragraphs:

126 | 127 |
    128 |
  1. First

  2. 129 |
  3. Second:

    130 | 131 |
      132 |
    • Fee
    • 133 |
    • Fie
    • 134 |
    • Foe
    • 135 |
  4. 136 |
  5. Third

  6. 137 |
138 | 139 | 140 |

This was an error in Markdown 1.0.1:

141 | 142 |
    143 |
  • this

    144 | 145 |
    • sub
    146 | 147 |

    that

  • 148 |
149 | -------------------------------------------------------------------------------- /test/original/ordered_and_unordered_lists.text: -------------------------------------------------------------------------------- 1 | ## Unordered 2 | 3 | Asterisks tight: 4 | 5 | * asterisk 1 6 | * asterisk 2 7 | * asterisk 3 8 | 9 | 10 | Asterisks loose: 11 | 12 | * asterisk 1 13 | 14 | * asterisk 2 15 | 16 | * asterisk 3 17 | 18 | * * * 19 | 20 | Pluses tight: 21 | 22 | + Plus 1 23 | + Plus 2 24 | + Plus 3 25 | 26 | 27 | Pluses loose: 28 | 29 | + Plus 1 30 | 31 | + Plus 2 32 | 33 | + Plus 3 34 | 35 | * * * 36 | 37 | 38 | Minuses tight: 39 | 40 | - Minus 1 41 | - Minus 2 42 | - Minus 3 43 | 44 | 45 | Minuses loose: 46 | 47 | - Minus 1 48 | 49 | - Minus 2 50 | 51 | - Minus 3 52 | 53 | 54 | ## Ordered 55 | 56 | Tight: 57 | 58 | 1. First 59 | 2. Second 60 | 3. Third 61 | 62 | and: 63 | 64 | 1. One 65 | 2. Two 66 | 3. Three 67 | 68 | 69 | Loose using tabs: 70 | 71 | 1. First 72 | 73 | 2. Second 74 | 75 | 3. Third 76 | 77 | and using spaces: 78 | 79 | 1. One 80 | 81 | 2. Two 82 | 83 | 3. Three 84 | 85 | Multiple paragraphs: 86 | 87 | 1. Item 1, graf one. 88 | 89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's 90 | back. 91 | 92 | 2. Item 2. 93 | 94 | 3. Item 3. 95 | 96 | 97 | 98 | ## Nested 99 | 100 | * Tab 101 | * Tab 102 | * Tab 103 | 104 | Here's another: 105 | 106 | 1. First 107 | 2. Second: 108 | * Fee 109 | * Fie 110 | * Foe 111 | 3. Third 112 | 113 | Same thing but with paragraphs: 114 | 115 | 1. First 116 | 117 | 2. Second: 118 | * Fee 119 | * Fie 120 | * Foe 121 | 122 | 3. Third 123 | 124 | 125 | This was an error in Markdown 1.0.1: 126 | 127 | * this 128 | 129 | * sub 130 | 131 | that 132 | -------------------------------------------------------------------------------- /test/original/strong_and_em_together.html: -------------------------------------------------------------------------------- 1 |

This is strong and em.

2 | 3 |

So is this word.

4 | 5 |

This is strong and em.

6 | 7 |

So is this word.

8 | -------------------------------------------------------------------------------- /test/original/strong_and_em_together.text: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /test/original/tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 |
  • this is a list item 5 | indented with spaces

  • 6 |
7 | 8 |

Code:

9 | 10 |
this code block is indented by one tab
11 | 
12 | 13 |

And:

14 | 15 |
    this code block is indented by two tabs
16 | 
17 | 18 |

And:

19 | 20 |
+   this is an example list item
21 |     indented with tabs
22 | 
23 | +   this is an example list item
24 |     indented with spaces
25 | 
26 | -------------------------------------------------------------------------------- /test/original/tabs.text: -------------------------------------------------------------------------------- 1 | + this is a list item 2 | indented with tabs 3 | 4 | + this is a list item 5 | indented with spaces 6 | 7 | Code: 8 | 9 | this code block is indented by one tab 10 | 11 | And: 12 | 13 | this code block is indented by two tabs 14 | 15 | And: 16 | 17 | + this is an example list item 18 | indented with tabs 19 | 20 | + this is an example list item 21 | indented with spaces 22 | -------------------------------------------------------------------------------- /test/original/tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 |
    4 |
  • asterisk 1
  • 5 |
  • asterisk 2
  • 6 |
  • asterisk 3
  • 7 |
8 |
9 | -------------------------------------------------------------------------------- /test/original/tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /test/tests/amps_and_angles_encoding.html: -------------------------------------------------------------------------------- 1 |

AT&T has an ampersand in their name.

2 | 3 |

AT&T is another way to write it.

4 | 5 |

This & that.

6 | 7 |

4 < 5.

8 | 9 |

6 > 5.

10 | 11 |

Here's a link with an ampersand in the URL.

12 | 13 |

Here's a link with an amersand in the link text: AT&T.

14 | 15 |

Here's an inline link.

16 | 17 |

Here's an inline link.

18 | -------------------------------------------------------------------------------- /test/tests/amps_and_angles_encoding.text: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" 22 | -------------------------------------------------------------------------------- /test/tests/auto_links.html: -------------------------------------------------------------------------------- 1 |

Link: http://example.com/.

2 | 3 |

With an ampersand: http://example.com/?foo=1&bar=2

4 | 5 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

Auto-links should not occur here: <http://example.com/>

16 | 17 |
or here: <http://example.com/>
18 | 
19 | -------------------------------------------------------------------------------- /test/tests/auto_links.text: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: 14 | -------------------------------------------------------------------------------- /test/tests/autolink_lines.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | http://example.com 3 |

4 | -------------------------------------------------------------------------------- /test/tests/autolink_lines.text: -------------------------------------------------------------------------------- 1 | hello world 2 | 3 | -------------------------------------------------------------------------------- /test/tests/backslash_escapes.html: -------------------------------------------------------------------------------- 1 |

These should all get escaped:

2 | 3 |

Backslash: \

4 | 5 |

Backtick: `

6 | 7 |

Asterisk: *

8 | 9 |

Underscore: _

10 | 11 |

Left brace: {

12 | 13 |

Right brace: }

14 | 15 |

Left bracket: [

16 | 17 |

Right bracket: ]

18 | 19 |

Left paren: (

20 | 21 |

Right paren: )

22 | 23 |

Greater-than: >

24 | 25 |

Hash: #

26 | 27 |

Period: .

28 | 29 |

Bang: !

30 | 31 |

Plus: +

32 | 33 |

Minus: -

34 | 35 |

These should not, because they occur within a code block:

36 | 37 |
Backslash: \\
 38 | 
 39 | Backtick: \`
 40 | 
 41 | Asterisk: \*
 42 | 
 43 | Underscore: \_
 44 | 
 45 | Left brace: \{
 46 | 
 47 | Right brace: \}
 48 | 
 49 | Left bracket: \[
 50 | 
 51 | Right bracket: \]
 52 | 
 53 | Left paren: \(
 54 | 
 55 | Right paren: \)
 56 | 
 57 | Greater-than: \>
 58 | 
 59 | Hash: \#
 60 | 
 61 | Period: \.
 62 | 
 63 | Bang: \!
 64 | 
 65 | Plus: \+
 66 | 
 67 | Minus: \-
 68 | 
69 | 70 |

Nor should these, which occur in code spans:

71 | 72 |

Backslash: \\

73 | 74 |

Backtick: \`

75 | 76 |

Asterisk: \*

77 | 78 |

Underscore: \_

79 | 80 |

Left brace: \{

81 | 82 |

Right brace: \}

83 | 84 |

Left bracket: \[

85 | 86 |

Right bracket: \]

87 | 88 |

Left paren: \(

89 | 90 |

Right paren: \)

91 | 92 |

Greater-than: \>

93 | 94 |

Hash: \#

95 | 96 |

Period: \.

97 | 98 |

Bang: \!

99 | 100 |

Plus: \+

101 | 102 |

Minus: \-

103 | 104 | 105 |

These should get escaped, even though they're matching pairs for 106 | other Markdown constructs:

107 | 108 |

*asterisks*

109 | 110 |

_underscores_

111 | 112 |

`backticks`

113 | 114 |

This is a code span with a literal backslash-backtick sequence: \`

115 | 116 |

This is a tag with unescaped backticks bar.

117 | 118 |

This is a tag with backslashes bar.

119 | -------------------------------------------------------------------------------- /test/tests/backslash_escapes.text: -------------------------------------------------------------------------------- 1 | These should all get escaped: 2 | 3 | Backslash: \\ 4 | 5 | Backtick: \` 6 | 7 | Asterisk: \* 8 | 9 | Underscore: \_ 10 | 11 | Left brace: \{ 12 | 13 | Right brace: \} 14 | 15 | Left bracket: \[ 16 | 17 | Right bracket: \] 18 | 19 | Left paren: \( 20 | 21 | Right paren: \) 22 | 23 | Greater-than: \> 24 | 25 | Hash: \# 26 | 27 | Period: \. 28 | 29 | Bang: \! 30 | 31 | Plus: \+ 32 | 33 | Minus: \- 34 | 35 | 36 | 37 | These should not, because they occur within a code block: 38 | 39 | Backslash: \\ 40 | 41 | Backtick: \` 42 | 43 | Asterisk: \* 44 | 45 | Underscore: \_ 46 | 47 | Left brace: \{ 48 | 49 | Right brace: \} 50 | 51 | Left bracket: \[ 52 | 53 | Right bracket: \] 54 | 55 | Left paren: \( 56 | 57 | Right paren: \) 58 | 59 | Greater-than: \> 60 | 61 | Hash: \# 62 | 63 | Period: \. 64 | 65 | Bang: \! 66 | 67 | Plus: \+ 68 | 69 | Minus: \- 70 | 71 | 72 | Nor should these, which occur in code spans: 73 | 74 | Backslash: `\\` 75 | 76 | Backtick: `` \` `` 77 | 78 | Asterisk: `\*` 79 | 80 | Underscore: `\_` 81 | 82 | Left brace: `\{` 83 | 84 | Right brace: `\}` 85 | 86 | Left bracket: `\[` 87 | 88 | Right bracket: `\]` 89 | 90 | Left paren: `\(` 91 | 92 | Right paren: `\)` 93 | 94 | Greater-than: `\>` 95 | 96 | Hash: `\#` 97 | 98 | Period: `\.` 99 | 100 | Bang: `\!` 101 | 102 | Plus: `\+` 103 | 104 | Minus: `\-` 105 | 106 | 107 | These should get escaped, even though they're matching pairs for 108 | other Markdown constructs: 109 | 110 | \*asterisks\* 111 | 112 | \_underscores\_ 113 | 114 | \`backticks\` 115 | 116 | This is a code span with a literal backslash-backtick sequence: `` \` `` 117 | 118 | This is a tag with unescaped backticks bar. 119 | 120 | This is a tag with backslashes bar. 121 | -------------------------------------------------------------------------------- /test/tests/blockquote_list_item.html: -------------------------------------------------------------------------------- 1 |

This fails in markdown.pl and upskirt:

2 | 3 |
  • hello

    world

4 | -------------------------------------------------------------------------------- /test/tests/blockquote_list_item.text: -------------------------------------------------------------------------------- 1 | This fails in markdown.pl and upskirt: 2 | 3 | * hello 4 | > world 5 | -------------------------------------------------------------------------------- /test/tests/blockquotes_with_code_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

3 | 4 |
sub status {
 5 |     print "working";
 6 | }
 7 | 
8 | 9 |

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /test/tests/blockquotes_with_code_blocks.text: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /test/tests/case_insensitive_refs.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/tests/case_insensitive_refs.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [HI]: /url 4 | -------------------------------------------------------------------------------- /test/tests/code_blocks.html: -------------------------------------------------------------------------------- 1 |
code block on the first line
 2 | 
3 | 4 |

Regular text.

5 | 6 |
code block indented by spaces
 7 | 
8 | 9 |

Regular text.

10 | 11 |
the lines in this block  
12 | all contain trailing spaces  
13 | 
14 | 15 |

Regular Text.

16 | 17 |
code block on the last line
18 | 
19 | -------------------------------------------------------------------------------- /test/tests/code_blocks.text: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line 15 | -------------------------------------------------------------------------------- /test/tests/code_spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 | 3 |

Fix for backticks within HTML tag: like this

4 | 5 |

Here's how you put `backticks` in a code span.

6 | 7 | -------------------------------------------------------------------------------- /test/tests/code_spans.text: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. 6 | 7 | -------------------------------------------------------------------------------- /test/tests/def_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

hello 3 | [1]: hello

4 |
5 | 6 |
7 | 8 |
9 |

hello

10 |
11 | 12 | 13 |
    14 |
  • hello
  • 15 |
  • [3]: hello
  • 16 |
17 | 18 | 19 |
    20 |
  • hello
  • 21 |
22 | 23 | 24 |
25 |

foo 26 | bar 27 | bar

28 |
29 | -------------------------------------------------------------------------------- /test/tests/def_blocks.text: -------------------------------------------------------------------------------- 1 | > hello 2 | > [1]: hello 3 | 4 | * * * 5 | 6 | > hello 7 | [2]: hello 8 | 9 | 10 | * hello 11 | * [3]: hello 12 | 13 | 14 | * hello 15 | [4]: hello 16 | 17 | 18 | > foo 19 | > bar 20 | [1]: foo 21 | > bar 22 | -------------------------------------------------------------------------------- /test/tests/double_link.html: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 |

Already linked: http://example.com/.

4 | 5 |

Already linked: http://example.com/.

6 | -------------------------------------------------------------------------------- /test/tests/double_link.text: -------------------------------------------------------------------------------- 1 |

Already linked: http://example.com/.

2 | 3 | Already linked: [http://example.com/](http://example.com/). 4 | 5 | Already linked: **http://example.com/**. 6 | -------------------------------------------------------------------------------- /test/tests/escaped_angles.html: -------------------------------------------------------------------------------- 1 |

>

2 | -------------------------------------------------------------------------------- /test/tests/escaped_angles.text: -------------------------------------------------------------------------------- 1 | \> 2 | -------------------------------------------------------------------------------- /test/tests/gfm_break.html: -------------------------------------------------------------------------------- 1 |

Look at the
pretty line
breaks.

2 | -------------------------------------------------------------------------------- /test/tests/gfm_break.text: -------------------------------------------------------------------------------- 1 | Look at the 2 | pretty line 3 | breaks. 4 | -------------------------------------------------------------------------------- /test/tests/gfm_code.html: -------------------------------------------------------------------------------- 1 |
var a = 'hello';
2 | console.log(a + ' world');
3 |
echo "hello, ${WORLD}"
4 |
Q: What do you call a tall person who sells stolen goods?
5 |
A longfence!
6 | -------------------------------------------------------------------------------- /test/tests/gfm_code.text: -------------------------------------------------------------------------------- 1 | ``` js 2 | var a = 'hello'; 3 | console.log(a + ' world'); 4 | ``` 5 | 6 | ~~~bash 7 | echo "hello, ${WORLD}" 8 | ~~~ 9 | 10 | ```````longfence 11 | Q: What do you call a tall person who sells stolen goods? 12 | ``````` 13 | 14 | ~~~~~~~~~~ ManyTildes 15 | A longfence! 16 | ~~~~~~~~~~ 17 | -------------------------------------------------------------------------------- /test/tests/gfm_code_hr_list.html: -------------------------------------------------------------------------------- 1 |

foo

2 |
    3 |
  1. bar:

    4 |
    5 |
      6 |
    • one
        7 |
      • two
          8 |
        • three
        • 9 |
        • four
        • 10 |
        • five
        • 11 |
        12 |
      • 13 |
      14 |
    • 15 |
    16 |
    17 |
  2. 18 |
  3. foo:

    19 |
     line 1
    20 |  line 2
    21 |
  4. 22 |
  5. foo:

    23 |
      24 |
    1. foo bar bar:

      25 |
       some code here
      26 | 
      27 |
    2. 28 |
    3. foo bar bar:

      29 |
       foo
      30 |  ---
      31 |  bar
      32 |  ---
      33 |  foo
      34 |  bar
      35 |
    4. 36 |
    5. foo bar bar:

      37 |
       ---
      38 |  foo
      39 |  foo
      40 |  ---
      41 |  bar
      42 |
    6. 43 |
    7. foo bar bar:

      44 |
       foo
      45 |  ---
      46 |  bar
      47 |
    8. 48 |
    9. foo

      49 |
    10. 50 |
    51 |
  6. 52 |
53 | -------------------------------------------------------------------------------- /test/tests/gfm_code_hr_list.text: -------------------------------------------------------------------------------- 1 | ## foo 2 | 3 | 1. bar: 4 | 5 | > - one 6 | - two 7 | - three 8 | - four 9 | - five 10 | 11 | 1. foo: 12 | 13 | ``` 14 | line 1 15 | line 2 16 | ``` 17 | 18 | 1. foo: 19 | 20 | 1. foo `bar` bar: 21 | 22 | ``` erb 23 | some code here 24 | ``` 25 | 26 | 2. foo `bar` bar: 27 | 28 | ``` erb 29 | foo 30 | --- 31 | bar 32 | --- 33 | foo 34 | bar 35 | ``` 36 | 37 | 3. foo `bar` bar: 38 | 39 | ``` html 40 | --- 41 | foo 42 | foo 43 | --- 44 | bar 45 | ``` 46 | 47 | 4. foo `bar` bar: 48 | 49 | foo 50 | --- 51 | bar 52 | 53 | 5. foo 54 | -------------------------------------------------------------------------------- /test/tests/gfm_del.html: -------------------------------------------------------------------------------- 1 |

hello hi world

2 | -------------------------------------------------------------------------------- /test/tests/gfm_del.text: -------------------------------------------------------------------------------- 1 | hello ~~hi~~ world 2 | -------------------------------------------------------------------------------- /test/tests/gfm_em.html: -------------------------------------------------------------------------------- 1 |

These words should_not_be_emphasized.

2 | -------------------------------------------------------------------------------- /test/tests/gfm_em.text: -------------------------------------------------------------------------------- 1 | These words should_not_be_emphasized. 2 | -------------------------------------------------------------------------------- /test/tests/gfm_links.html: -------------------------------------------------------------------------------- 1 |

This should be a link: 2 | http://example.com/hello-world.

3 | -------------------------------------------------------------------------------- /test/tests/gfm_links.text: -------------------------------------------------------------------------------- 1 | This should be a link: http://example.com/hello-world. 2 | -------------------------------------------------------------------------------- /test/tests/gfm_tables.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Heading 1Heading 2
Cell 1Cell 2
Cell 3Cell 4
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
19 |
Test code
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Header 1Header 2
Cell 1Cell 2
Cell 3Cell 4
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
38 | 39 | -------------------------------------------------------------------------------- /test/tests/gfm_tables.text: -------------------------------------------------------------------------------- 1 | | Heading 1 | Heading 2 2 | | --------- | --------- 3 | | Cell 1 | Cell 2 4 | | Cell 3 | Cell 4 5 | 6 | | Header 1 | Header 2 | Header 3 | Header 4 | 7 | | :------: | -------: | :------- | -------- | 8 | | Cell 1 | Cell 2 | Cell 3 | Cell 4 | 9 | | Cell 5 | Cell 6 | Cell 7 | Cell 8 | 10 | 11 | Test code 12 | 13 | Header 1 | Header 2 14 | -------- | -------- 15 | Cell 1 | Cell 2 16 | Cell 3 | Cell 4 17 | 18 | Header 1|Header 2|Header 3|Header 4 19 | :-------|:------:|-------:|-------- 20 | Cell 1 |Cell 2 |Cell 3 |Cell 4 21 | *Cell 5*|Cell 6 |Cell 7 |Cell 8 22 | -------------------------------------------------------------------------------- /test/tests/hard_wrapped_paragraphs_with_list_like_lines.html: -------------------------------------------------------------------------------- 1 |

In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.

6 | 7 |

Here's one with a bullet. 8 | * criminey.

9 | -------------------------------------------------------------------------------- /test/tests/hard_wrapped_paragraphs_with_list_like_lines.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /test/tests/horizontal_rules.html: -------------------------------------------------------------------------------- 1 |

Dashes:

2 | 3 |
4 | 5 |
6 | 7 |
8 | 9 |
10 | 11 |
---
12 | 
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
- - -
23 | 
24 | 25 |

Asterisks:

26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
***
36 | 
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
* * *
47 | 
48 | 49 |

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | -------------------------------------------------------------------------------- /test/tests/horizontal_rules.text: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /test/tests/hr_list_break.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • hello 3 | world
  • 4 |
  • how 5 | are
  • 6 |
7 | 8 |
9 | 10 |

you today?

11 | -------------------------------------------------------------------------------- /test/tests/hr_list_break.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | * how 4 | are 5 | * * * 6 | you today? 7 | -------------------------------------------------------------------------------- /test/tests/inline_html_advanced.html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/tests/inline_html_advanced.text: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /test/tests/inline_html_comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 | 8 | 9 |

Paragraph two.

10 | 11 | 12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /test/tests/inline_html_comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /test/tests/inline_html_simple.html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 | 3 |
4 | foo 5 |
6 | 7 |

This should be a code block, though:

8 | 9 |
<div>
10 |     foo
11 | </div>
12 | 
13 | 14 |

As should this:

15 | 16 |
<div>foo</div>
17 | 
18 | 19 |

Now, nested:

20 | 21 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

This should just be an HTML comment:

30 | 31 | 32 | 33 |

Multiline:

34 | 35 | 39 | 40 |

Code block:

41 | 42 |
<!-- Comment -->
43 | 
44 | 45 |

Just plain comment, with trailing spaces on the line:

46 | 47 | 48 | 49 |

Code:

50 | 51 |
<hr>
52 | 
53 | 54 |

Hr's:

55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /test/tests/inline_html_simple.text: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /test/tests/lazy_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

hi there 3 | bud

4 |
5 | -------------------------------------------------------------------------------- /test/tests/lazy_blockquotes.text: -------------------------------------------------------------------------------- 1 | > hi there 2 | bud 3 | -------------------------------------------------------------------------------- /test/tests/links_inline_style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 | 3 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

URL and title.

10 | 11 |

Empty.

12 | -------------------------------------------------------------------------------- /test/tests/links_inline_style.text: -------------------------------------------------------------------------------- 1 | Just a [URL](/url/). 2 | 3 | [URL and title](/url/ "title"). 4 | 5 | [URL and title](/url/ "title preceded by two spaces"). 6 | 7 | [URL and title](/url/ "title preceded by a tab"). 8 | 9 | [URL and title](/url/ "title has spaces afterward" ). 10 | 11 | 12 | [Empty](). 13 | -------------------------------------------------------------------------------- /test/tests/links_reference_style.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | 5 |

Foo bar.

6 | 7 |

With embedded [brackets].

8 | 9 |

Indented once.

10 | 11 |

Indented twice.

12 | 13 |

Indented thrice.

14 | 15 |

Indented [four][] times.

16 | 17 |
[four]: /url
18 | 
19 | 20 |
21 | 22 |

this should work

23 | 24 |

So should this.

25 | 26 |

And this.

27 | 28 |

And this.

29 | 30 |

And this.

31 | 32 |

But not [that] [].

33 | 34 |

Nor [that][].

35 | 36 |

Nor [that].

37 | 38 |

[Something in brackets like this should work]

39 | 40 |

[Same with this.]

41 | 42 |

In this case, this points to something else.

43 | 44 |

Backslashing should suppress [this] and [this].

45 | 46 |
47 | 48 |

Here's one where the link 49 | breaks across lines.

50 | 51 |

Here's another where the link 52 | breaks across lines, but with a line-ending space.

53 | -------------------------------------------------------------------------------- /test/tests/links_reference_style.text: -------------------------------------------------------------------------------- 1 | Foo [bar] [1]. 2 | 3 | Foo [bar][1]. 4 | 5 | Foo [bar] 6 | [1]. 7 | 8 | [1]: /url/ "Title" 9 | 10 | 11 | With [embedded [brackets]] [b]. 12 | 13 | 14 | Indented [once][]. 15 | 16 | Indented [twice][]. 17 | 18 | Indented [thrice][]. 19 | 20 | Indented [four][] times. 21 | 22 | [once]: /url 23 | 24 | [twice]: /url 25 | 26 | [thrice]: /url 27 | 28 | [four]: /url 29 | 30 | 31 | [b]: /url/ 32 | 33 | * * * 34 | 35 | [this] [this] should work 36 | 37 | So should [this][this]. 38 | 39 | And [this] []. 40 | 41 | And [this][]. 42 | 43 | And [this]. 44 | 45 | But not [that] []. 46 | 47 | Nor [that][]. 48 | 49 | Nor [that]. 50 | 51 | [Something in brackets like [this][] should work] 52 | 53 | [Same with [this].] 54 | 55 | In this case, [this](/somethingelse/) points to something else. 56 | 57 | Backslashing should suppress \[this] and [this\]. 58 | 59 | [this]: foo 60 | 61 | 62 | * * * 63 | 64 | Here's one where the [link 65 | breaks] across lines. 66 | 67 | Here's another where the [link 68 | breaks] across lines, but with a line-ending space. 69 | 70 | 71 | [link breaks]: /url/ 72 | -------------------------------------------------------------------------------- /test/tests/links_shortcut_references.html: -------------------------------------------------------------------------------- 1 |

This is the simple case.

2 | 3 |

This one has a line 4 | break.

5 | 6 |

This one has a line 7 | break with a line-ending space.

8 | 9 |

this and the other

10 | -------------------------------------------------------------------------------- /test/tests/links_shortcut_references.text: -------------------------------------------------------------------------------- 1 | This is the [simple case]. 2 | 3 | [simple case]: /simple 4 | 5 | 6 | 7 | This one has a [line 8 | break]. 9 | 10 | This one has a [line 11 | break] with a line-ending space. 12 | 13 | [line break]: /foo 14 | 15 | 16 | [this] [that] and the [other] 17 | 18 | [this]: /this 19 | [that]: /that 20 | [other]: /other 21 | -------------------------------------------------------------------------------- /test/tests/list_item_text.html: -------------------------------------------------------------------------------- 1 |
  • item1

    • item2

    text

2 | -------------------------------------------------------------------------------- /test/tests/list_item_text.text: -------------------------------------------------------------------------------- 1 | * item1 2 | 3 | * item2 4 | 5 | text 6 | -------------------------------------------------------------------------------- /test/tests/literal_quotes_in_titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /test/tests/literal_quotes_in_titles.text: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /test/tests/loose_lists.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • hello 3 | world

    4 | 5 |

    how 6 | are

  • 7 |
  • you
  • 8 |
9 | 10 | 11 | 12 |

better behavior:

13 | 14 |
  • hello

    • world 15 | how

      are 16 | you

    • today

  • hi
17 | 18 | 19 | 20 |
    21 |
  • hello

  • 22 |
  • world

  • 23 |
  • hi
  • 24 |
25 | 26 | 27 | 28 |
    29 |
  • hello
  • 30 |
  • world

  • 31 |
  • hi

  • 32 |
33 | 34 | 35 | 36 |
    37 |
  • hello
  • 38 |
  • world

    39 | 40 |

    how

  • 41 |
  • hi
  • 42 |
43 | 44 | 45 | 46 |
    47 |
  • hello
  • 48 |
  • world
  • 49 |
  • how

    50 | 51 |

    are

  • 52 |
53 | 54 | 55 | 56 |
    57 |
  • hello
  • 58 |
  • world

  • 59 |
  • how

    60 | 61 |

    are

  • 62 |
63 | -------------------------------------------------------------------------------- /test/tests/loose_lists.text: -------------------------------------------------------------------------------- 1 | * hello 2 | world 3 | 4 | how 5 | are 6 | * you 7 | 8 | 9 | 10 | better behavior: 11 | 12 | * hello 13 | * world 14 | how 15 | 16 | are 17 | you 18 | 19 | * today 20 | * hi 21 | 22 | 23 | 24 | * hello 25 | 26 | * world 27 | * hi 28 | 29 | 30 | 31 | * hello 32 | * world 33 | 34 | * hi 35 | 36 | 37 | 38 | * hello 39 | * world 40 | 41 | how 42 | * hi 43 | 44 | 45 | 46 | * hello 47 | * world 48 | * how 49 | 50 | are 51 | 52 | 53 | 54 | * hello 55 | * world 56 | 57 | * how 58 | 59 | are 60 | -------------------------------------------------------------------------------- /test/tests/main.html: -------------------------------------------------------------------------------- 1 |

A heading

Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.

A link. Not anymore.

  • List Item 1

  • List Item 2

    • New List Item 1 Hi, this is a list item.
    • New List Item 2 Another item
      Code goes here.
      3 | Lots of it...
    • New List Item 3 The last item
  • List Item 3 The final item.

  • List Item 4 The real final item.

Paragraph.

  • bq Item 1
  • bq Item 2
    • New bq Item 1
    • New bq Item 2 Text here

Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again

Another Heading

Hello world. Here is a link. And an image alt.

Code goes here.
4 | Lots of it...
5 | -------------------------------------------------------------------------------- /test/tests/main.text: -------------------------------------------------------------------------------- 1 | [test]: http://google.com/ "Google" 2 | 3 | # A heading 4 | 5 | Just a note, I've found that I can't test my markdown parser vs others. 6 | For example, both markdown.js and showdown code blocks in lists wrong. They're 7 | also completely [inconsistent][test] with regards to paragraphs in list items. 8 | 9 | A link. Not anymore. 10 | 11 | 13 | 14 | * List Item 1 15 | 16 | * List Item 2 17 | * New List Item 1 18 | Hi, this is a list item. 19 | * New List Item 2 20 | Another item 21 | Code goes here. 22 | Lots of it... 23 | * New List Item 3 24 | The last item 25 | 26 | * List Item 3 27 | The final item. 28 | 29 | * List Item 4 30 | The real final item. 31 | 32 | Paragraph. 33 | 34 | > * bq Item 1 35 | > * bq Item 2 36 | > * New bq Item 1 37 | > * New bq Item 2 38 | > Text here 39 | 40 | * * * 41 | 42 | > Another blockquote! 43 | > I really need to get 44 | > more creative with 45 | > mockup text.. 46 | > markdown.js breaks here again 47 | 48 | Another Heading 49 | ------------- 50 | 51 | Hello *world*. Here is a [link](//hello). 52 | And an image ![alt](src). 53 | 54 | Code goes here. 55 | Lots of it... 56 | -------------------------------------------------------------------------------- /test/tests/markdown_documentation_basics.html: -------------------------------------------------------------------------------- 1 |

Markdown: Basics

2 | 3 | 10 | 11 |

Getting the Gist of Markdown's Formatting Syntax

12 | 13 |

This page offers a brief overview of what it's like to use Markdown. 14 | The syntax page provides complete, detailed documentation for 15 | every feature, but Markdown should be very easy to pick up simply by 16 | looking at a few examples of it in action. The examples on this page 17 | are written in a before/after style, showing example syntax and the 18 | HTML output produced by Markdown.

19 | 20 |

It's also helpful to simply try Markdown out; the Dingus is a 21 | web application that allows you type your own Markdown-formatted text 22 | and translate it to XHTML.

23 | 24 |

Note: This document is itself written using Markdown; you 25 | can see the source for it by adding '.text' to the URL.

26 | 27 |

Paragraphs, Headers, Blockquotes

28 | 29 |

A paragraph is simply one or more consecutive lines of text, separated 30 | by one or more blank lines. (A blank line is any line that looks like a 31 | blank line -- a line containing nothing spaces or tabs is considered 32 | blank.) Normal paragraphs should not be intended with spaces or tabs.

33 | 34 |

Markdown offers two styles of headers: Setext and atx. 35 | Setext-style headers for <h1> and <h2> are created by 36 | "underlining" with equal signs (=) and hyphens (-), respectively. 37 | To create an atx-style header, you put 1-6 hash marks (#) at the 38 | beginning of the line -- the number of hashes equals the resulting 39 | HTML header level.

40 | 41 |

Blockquotes are indicated using email-style '>' angle brackets.

42 | 43 |

Markdown:

44 | 45 |
A First Level Header
 46 | ====================
 47 | 
 48 | A Second Level Header
 49 | ---------------------
 50 | 
 51 | Now is the time for all good men to come to
 52 | the aid of their country. This is just a
 53 | regular paragraph.
 54 | 
 55 | The quick brown fox jumped over the lazy
 56 | dog's back.
 57 | 
 58 | ### Header 3
 59 | 
 60 | > This is a blockquote.
 61 | > 
 62 | > This is the second paragraph in the blockquote.
 63 | >
 64 | > ## This is an H2 in a blockquote
 65 | 
66 | 67 |

Output:

68 | 69 |
<h1>A First Level Header</h1>
 70 | 
 71 | <h2>A Second Level Header</h2>
 72 | 
 73 | <p>Now is the time for all good men to come to
 74 | the aid of their country. This is just a
 75 | regular paragraph.</p>
 76 | 
 77 | <p>The quick brown fox jumped over the lazy
 78 | dog's back.</p>
 79 | 
 80 | <h3>Header 3</h3>
 81 | 
 82 | <blockquote>
 83 |     <p>This is a blockquote.</p>
 84 | 
 85 |     <p>This is the second paragraph in the blockquote.</p>
 86 | 
 87 |     <h2>This is an H2 in a blockquote</h2>
 88 | </blockquote>
 89 | 
90 | 91 |

Phrase Emphasis

92 | 93 |

Markdown uses asterisks and underscores to indicate spans of emphasis.

94 | 95 |

Markdown:

96 | 97 |
Some of these words *are emphasized*.
 98 | Some of these words _are emphasized also_.
 99 | 
100 | Use two asterisks for **strong emphasis**.
101 | Or, if you prefer, __use two underscores instead__.
102 | 
103 | 104 |

Output:

105 | 106 |
<p>Some of these words <em>are emphasized</em>.
107 | Some of these words <em>are emphasized also</em>.</p>
108 | 
109 | <p>Use two asterisks for <strong>strong emphasis</strong>.
110 | Or, if you prefer, <strong>use two underscores instead</strong>.</p>
111 | 
112 | 113 |

Lists

114 | 115 |

Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, 116 | +, and -) as list markers. These three markers are 117 | interchangable; this:

118 | 119 |
*   Candy.
120 | *   Gum.
121 | *   Booze.
122 | 
123 | 124 |

this:

125 | 126 |
+   Candy.
127 | +   Gum.
128 | +   Booze.
129 | 
130 | 131 |

and this:

132 | 133 |
-   Candy.
134 | -   Gum.
135 | -   Booze.
136 | 
137 | 138 |

all produce the same output:

139 | 140 |
<ul>
141 | <li>Candy.</li>
142 | <li>Gum.</li>
143 | <li>Booze.</li>
144 | </ul>
145 | 
146 | 147 |

Ordered (numbered) lists use regular numbers, followed by periods, as 148 | list markers:

149 | 150 |
1.  Red
151 | 2.  Green
152 | 3.  Blue
153 | 
154 | 155 |

Output:

156 | 157 |
<ol>
158 | <li>Red</li>
159 | <li>Green</li>
160 | <li>Blue</li>
161 | </ol>
162 | 
163 | 164 |

If you put blank lines between items, you'll get <p> tags for the 165 | list item text. You can create multi-paragraph list items by indenting 166 | the paragraphs by 4 spaces or 1 tab:

167 | 168 |
*   A list item.
169 | 
170 |     With multiple paragraphs.
171 | 
172 | *   Another item in the list.
173 | 
174 | 175 |

Output:

176 | 177 |
<ul>
178 | <li><p>A list item.</p>
179 | <p>With multiple paragraphs.</p></li>
180 | <li><p>Another item in the list.</p></li>
181 | </ul>
182 | 
183 | 184 |

Links

185 | 186 |

Markdown supports two styles for creating links: inline and 187 | reference. With both styles, you use square brackets to delimit the 188 | text you want to turn into a link.

189 | 190 |

Inline-style links use parentheses immediately after the link text. 191 | For example:

192 | 193 |
This is an [example link](http://example.com/).
194 | 
195 | 196 |

Output:

197 | 198 |
<p>This is an <a href="http://example.com/">
199 | example link</a>.</p>
200 | 
201 | 202 |

Optionally, you may include a title attribute in the parentheses:

203 | 204 |
This is an [example link](http://example.com/ "With a Title").
205 | 
206 | 207 |

Output:

208 | 209 |
<p>This is an <a href="http://example.com/" title="With a Title">
210 | example link</a>.</p>
211 | 
212 | 213 |

Reference-style links allow you to refer to your links by names, which 214 | you define elsewhere in your document:

215 | 216 |
I get 10 times more traffic from [Google][1] than from
217 | [Yahoo][2] or [MSN][3].
218 | 
219 | [1]: http://google.com/        "Google"
220 | [2]: http://search.yahoo.com/  "Yahoo Search"
221 | [3]: http://search.msn.com/    "MSN Search"
222 | 
223 | 224 |

Output:

225 | 226 |
<p>I get 10 times more traffic from <a href="http://google.com/"
227 | title="Google">Google</a> than from <a href="http://search.yahoo.com/"
228 | title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
229 | title="MSN Search">MSN</a>.</p>
230 | 
231 | 232 |

The title attribute is optional. Link names may contain letters, 233 | numbers and spaces, but are not case sensitive:

234 | 235 |
I start my morning with a cup of coffee and
236 | [The New York Times][NY Times].
237 | 
238 | [ny times]: http://www.nytimes.com/
239 | 
240 | 241 |

Output:

242 | 243 |
<p>I start my morning with a cup of coffee and
244 | <a href="http://www.nytimes.com/">The New York Times</a>.</p>
245 | 
246 | 247 |

Images

248 | 249 |

Image syntax is very much like link syntax.

250 | 251 |

Inline (titles are optional):

252 | 253 |
![alt text](/path/to/img.jpg "Title")
254 | 
255 | 256 |

Reference-style:

257 | 258 |
![alt text][id]
259 | 
260 | [id]: /path/to/img.jpg "Title"
261 | 
262 | 263 |

Both of the above examples produce the same output:

264 | 265 |
<img src="/path/to/img.jpg" alt="alt text" title="Title" />
266 | 
267 | 268 |

Code

269 | 270 |

In a regular paragraph, you can create code span by wrapping text in 271 | backtick quotes. Any ampersands (&) and angle brackets (< or 272 | >) will automatically be translated into HTML entities. This makes 273 | it easy to use Markdown to write about HTML example code:

274 | 275 |
I strongly recommend against using any `<blink>` tags.
276 | 
277 | I wish SmartyPants used named entities like `&mdash;`
278 | instead of decimal-encoded entites like `&#8212;`.
279 | 
280 | 281 |

Output:

282 | 283 |
<p>I strongly recommend against using any
284 | <code>&lt;blink&gt;</code> tags.</p>
285 | 
286 | <p>I wish SmartyPants used named entities like
287 | <code>&amp;mdash;</code> instead of decimal-encoded
288 | entites like <code>&amp;#8212;</code>.</p>
289 | 
290 | 291 |

To specify an entire block of pre-formatted code, indent every line of 292 | the block by 4 spaces or 1 tab. Just like with code spans, &, <, 293 | and > characters will be escaped automatically.

294 | 295 |

Markdown:

296 | 297 |
If you want your page to validate under XHTML 1.0 Strict,
298 | you've got to put paragraph tags in your blockquotes:
299 | 
300 |     <blockquote>
301 |         <p>For example.</p>
302 |     </blockquote>
303 | 
304 | 305 |

Output:

306 | 307 |
<p>If you want your page to validate under XHTML 1.0 Strict,
308 | you've got to put paragraph tags in your blockquotes:</p>
309 | 
310 | <pre><code>&lt;blockquote&gt;
311 |     &lt;p&gt;For example.&lt;/p&gt;
312 | &lt;/blockquote&gt;
313 | </code></pre>
314 | 
315 | -------------------------------------------------------------------------------- /test/tests/markdown_documentation_basics.text: -------------------------------------------------------------------------------- 1 | Markdown: Basics 2 | ================ 3 | 4 | 11 | 12 | 13 | Getting the Gist of Markdown's Formatting Syntax 14 | ------------------------------------------------ 15 | 16 | This page offers a brief overview of what it's like to use Markdown. 17 | The [syntax page] [s] provides complete, detailed documentation for 18 | every feature, but Markdown should be very easy to pick up simply by 19 | looking at a few examples of it in action. The examples on this page 20 | are written in a before/after style, showing example syntax and the 21 | HTML output produced by Markdown. 22 | 23 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a 24 | web application that allows you type your own Markdown-formatted text 25 | and translate it to XHTML. 26 | 27 | **Note:** This document is itself written using Markdown; you 28 | can [see the source for it by adding '.text' to the URL] [src]. 29 | 30 | [s]: /projects/markdown/syntax "Markdown Syntax" 31 | [d]: /projects/markdown/dingus "Markdown Dingus" 32 | [src]: /projects/markdown/basics.text 33 | 34 | 35 | ## Paragraphs, Headers, Blockquotes ## 36 | 37 | A paragraph is simply one or more consecutive lines of text, separated 38 | by one or more blank lines. (A blank line is any line that looks like a 39 | blank line -- a line containing nothing spaces or tabs is considered 40 | blank.) Normal paragraphs should not be intended with spaces or tabs. 41 | 42 | Markdown offers two styles of headers: *Setext* and *atx*. 43 | Setext-style headers for `

` and `

` are created by 44 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively. 45 | To create an atx-style header, you put 1-6 hash marks (`#`) at the 46 | beginning of the line -- the number of hashes equals the resulting 47 | HTML header level. 48 | 49 | Blockquotes are indicated using email-style '`>`' angle brackets. 50 | 51 | Markdown: 52 | 53 | A First Level Header 54 | ==================== 55 | 56 | A Second Level Header 57 | --------------------- 58 | 59 | Now is the time for all good men to come to 60 | the aid of their country. This is just a 61 | regular paragraph. 62 | 63 | The quick brown fox jumped over the lazy 64 | dog's back. 65 | 66 | ### Header 3 67 | 68 | > This is a blockquote. 69 | > 70 | > This is the second paragraph in the blockquote. 71 | > 72 | > ## This is an H2 in a blockquote 73 | 74 | 75 | Output: 76 | 77 |

A First Level Header

78 | 79 |

A Second Level Header

80 | 81 |

Now is the time for all good men to come to 82 | the aid of their country. This is just a 83 | regular paragraph.

84 | 85 |

The quick brown fox jumped over the lazy 86 | dog's back.

87 | 88 |

Header 3

89 | 90 |
91 |

This is a blockquote.

92 | 93 |

This is the second paragraph in the blockquote.

94 | 95 |

This is an H2 in a blockquote

96 |
97 | 98 | 99 | 100 | ### Phrase Emphasis ### 101 | 102 | Markdown uses asterisks and underscores to indicate spans of emphasis. 103 | 104 | Markdown: 105 | 106 | Some of these words *are emphasized*. 107 | Some of these words _are emphasized also_. 108 | 109 | Use two asterisks for **strong emphasis**. 110 | Or, if you prefer, __use two underscores instead__. 111 | 112 | Output: 113 | 114 |

Some of these words are emphasized. 115 | Some of these words are emphasized also.

116 | 117 |

Use two asterisks for strong emphasis. 118 | Or, if you prefer, use two underscores instead.

119 | 120 | 121 | 122 | ## Lists ## 123 | 124 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, 125 | `+`, and `-`) as list markers. These three markers are 126 | interchangable; this: 127 | 128 | * Candy. 129 | * Gum. 130 | * Booze. 131 | 132 | this: 133 | 134 | + Candy. 135 | + Gum. 136 | + Booze. 137 | 138 | and this: 139 | 140 | - Candy. 141 | - Gum. 142 | - Booze. 143 | 144 | all produce the same output: 145 | 146 |
    147 |
  • Candy.
  • 148 |
  • Gum.
  • 149 |
  • Booze.
  • 150 |
151 | 152 | Ordered (numbered) lists use regular numbers, followed by periods, as 153 | list markers: 154 | 155 | 1. Red 156 | 2. Green 157 | 3. Blue 158 | 159 | Output: 160 | 161 |
    162 |
  1. Red
  2. 163 |
  3. Green
  4. 164 |
  5. Blue
  6. 165 |
166 | 167 | If you put blank lines between items, you'll get `

` tags for the 168 | list item text. You can create multi-paragraph list items by indenting 169 | the paragraphs by 4 spaces or 1 tab: 170 | 171 | * A list item. 172 | 173 | With multiple paragraphs. 174 | 175 | * Another item in the list. 176 | 177 | Output: 178 | 179 |

    180 |
  • A list item.

    181 |

    With multiple paragraphs.

  • 182 |
  • Another item in the list.

  • 183 |
184 | 185 | 186 | 187 | ### Links ### 188 | 189 | Markdown supports two styles for creating links: *inline* and 190 | *reference*. With both styles, you use square brackets to delimit the 191 | text you want to turn into a link. 192 | 193 | Inline-style links use parentheses immediately after the link text. 194 | For example: 195 | 196 | This is an [example link](http://example.com/). 197 | 198 | Output: 199 | 200 |

This is an 201 | example link.

202 | 203 | Optionally, you may include a title attribute in the parentheses: 204 | 205 | This is an [example link](http://example.com/ "With a Title"). 206 | 207 | Output: 208 | 209 |

This is an 210 | example link.

211 | 212 | Reference-style links allow you to refer to your links by names, which 213 | you define elsewhere in your document: 214 | 215 | I get 10 times more traffic from [Google][1] than from 216 | [Yahoo][2] or [MSN][3]. 217 | 218 | [1]: http://google.com/ "Google" 219 | [2]: http://search.yahoo.com/ "Yahoo Search" 220 | [3]: http://search.msn.com/ "MSN Search" 221 | 222 | Output: 223 | 224 |

I get 10 times more traffic from Google than from Yahoo or MSN.

228 | 229 | The title attribute is optional. Link names may contain letters, 230 | numbers and spaces, but are *not* case sensitive: 231 | 232 | I start my morning with a cup of coffee and 233 | [The New York Times][NY Times]. 234 | 235 | [ny times]: http://www.nytimes.com/ 236 | 237 | Output: 238 | 239 |

I start my morning with a cup of coffee and 240 | The New York Times.

241 | 242 | 243 | ### Images ### 244 | 245 | Image syntax is very much like link syntax. 246 | 247 | Inline (titles are optional): 248 | 249 | ![alt text](/path/to/img.jpg "Title") 250 | 251 | Reference-style: 252 | 253 | ![alt text][id] 254 | 255 | [id]: /path/to/img.jpg "Title" 256 | 257 | Both of the above examples produce the same output: 258 | 259 | alt text 260 | 261 | 262 | 263 | ### Code ### 264 | 265 | In a regular paragraph, you can create code span by wrapping text in 266 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or 267 | `>`) will automatically be translated into HTML entities. This makes 268 | it easy to use Markdown to write about HTML example code: 269 | 270 | I strongly recommend against using any `` tags. 271 | 272 | I wish SmartyPants used named entities like `—` 273 | instead of decimal-encoded entites like `—`. 274 | 275 | Output: 276 | 277 |

I strongly recommend against using any 278 | <blink> tags.

279 | 280 |

I wish SmartyPants used named entities like 281 | &mdash; instead of decimal-encoded 282 | entites like &#8212;.

283 | 284 | 285 | To specify an entire block of pre-formatted code, indent every line of 286 | the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, 287 | and `>` characters will be escaped automatically. 288 | 289 | Markdown: 290 | 291 | If you want your page to validate under XHTML 1.0 Strict, 292 | you've got to put paragraph tags in your blockquotes: 293 | 294 |
295 |

For example.

296 |
297 | 298 | Output: 299 | 300 |

If you want your page to validate under XHTML 1.0 Strict, 301 | you've got to put paragraph tags in your blockquotes:

302 | 303 |
<blockquote>
304 |         <p>For example.</p>
305 |     </blockquote>
306 |     
307 | -------------------------------------------------------------------------------- /test/tests/nested_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /test/tests/nested_blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /test/tests/nested_code.html: -------------------------------------------------------------------------------- 1 |

hi ther `` ok ```

2 | -------------------------------------------------------------------------------- /test/tests/nested_code.text: -------------------------------------------------------------------------------- 1 | ````` hi ther `` ok ``` ````` 2 | -------------------------------------------------------------------------------- /test/tests/nested_em.html: -------------------------------------------------------------------------------- 1 |

test test test

2 | 3 |

test test test

4 | -------------------------------------------------------------------------------- /test/tests/nested_em.text: -------------------------------------------------------------------------------- 1 | *test **test** test* 2 | 3 | _test __test__ test_ 4 | -------------------------------------------------------------------------------- /test/tests/nested_square_link.html: -------------------------------------------------------------------------------- 1 |

the ] character

2 | -------------------------------------------------------------------------------- /test/tests/nested_square_link.text: -------------------------------------------------------------------------------- 1 | [the `]` character](/url) 2 | -------------------------------------------------------------------------------- /test/tests/not_a_link.html: -------------------------------------------------------------------------------- 1 |

\[test](not a link)

2 | -------------------------------------------------------------------------------- /test/tests/not_a_link.text: -------------------------------------------------------------------------------- 1 | \\[test](not a link) 2 | -------------------------------------------------------------------------------- /test/tests/ordered_and_unordered_lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

4 | 5 |
    6 |
  • asterisk 1
  • 7 |
  • asterisk 2
  • 8 |
  • asterisk 3
  • 9 |
10 | 11 |

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 |
  • asterisk 2

  • 16 |
  • asterisk 3

  • 17 |
18 | 19 |
20 | 21 |

Pluses tight:

22 | 23 |
    24 |
  • Plus 1
  • 25 |
  • Plus 2
  • 26 |
  • Plus 3
  • 27 |
28 | 29 |

Pluses loose:

30 | 31 |
    32 |
  • Plus 1

  • 33 |
  • Plus 2

  • 34 |
  • Plus 3

  • 35 |
36 | 37 |
38 | 39 |

Minuses tight:

40 | 41 |
    42 |
  • Minus 1
  • 43 |
  • Minus 2
  • 44 |
  • Minus 3
  • 45 |
46 | 47 |

Minuses loose:

48 | 49 |
    50 |
  • Minus 1

  • 51 |
  • Minus 2

  • 52 |
  • Minus 3

  • 53 |
54 | 55 |

Ordered

56 | 57 |

Tight:

58 | 59 |
    60 |
  1. First
  2. 61 |
  3. Second
  4. 62 |
  5. Third
  6. 63 |
64 | 65 |

and:

66 | 67 |
    68 |
  1. One
  2. 69 |
  3. Two
  4. 70 |
  5. Three
  6. 71 |
72 | 73 |

Loose using tabs:

74 | 75 |
    76 |
  1. First

  2. 77 |
  3. Second

  4. 78 |
  5. Third

  6. 79 |
80 | 81 |

and using spaces:

82 | 83 |
    84 |
  1. One

  2. 85 |
  3. Two

  4. 86 |
  5. Three

  6. 87 |
88 | 89 |

Multiple paragraphs:

90 | 91 |
    92 |
  1. Item 1, graf one.

    93 | 94 |

    Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.

  2. 96 |
  3. Item 2.

  4. 97 |
  5. Item 3.

  6. 98 |
99 | 100 |

Nested

101 | 102 |
    103 |
  • Tab 104 |
      105 |
    • Tab 106 |
        107 |
      • Tab
      • 108 |
    • 109 |
  • 110 |
111 | 112 |

Here's another:

113 | 114 |
    115 |
  1. First
  2. 116 |
  3. Second: 117 |
      118 |
    • Fee
    • 119 |
    • Fie
    • 120 |
    • Foe
    • 121 |
  4. 122 |
  5. Third
  6. 123 |
124 | 125 |

Same thing but with paragraphs:

126 | 127 |
    128 |
  1. First

  2. 129 |
  3. Second:

    130 | 131 |
      132 |
    • Fee
    • 133 |
    • Fie
    • 134 |
    • Foe
    • 135 |
  4. 136 |
  5. Third

  6. 137 |
138 | 139 | 140 |

This was an error in Markdown 1.0.1:

141 | 142 |
    143 |
  • this

    144 | 145 |
    • sub
    146 | 147 |

    that

  • 148 |
149 | -------------------------------------------------------------------------------- /test/tests/ordered_and_unordered_lists.text: -------------------------------------------------------------------------------- 1 | ## Unordered 2 | 3 | Asterisks tight: 4 | 5 | * asterisk 1 6 | * asterisk 2 7 | * asterisk 3 8 | 9 | 10 | Asterisks loose: 11 | 12 | * asterisk 1 13 | 14 | * asterisk 2 15 | 16 | * asterisk 3 17 | 18 | * * * 19 | 20 | Pluses tight: 21 | 22 | + Plus 1 23 | + Plus 2 24 | + Plus 3 25 | 26 | 27 | Pluses loose: 28 | 29 | + Plus 1 30 | 31 | + Plus 2 32 | 33 | + Plus 3 34 | 35 | * * * 36 | 37 | 38 | Minuses tight: 39 | 40 | - Minus 1 41 | - Minus 2 42 | - Minus 3 43 | 44 | 45 | Minuses loose: 46 | 47 | - Minus 1 48 | 49 | - Minus 2 50 | 51 | - Minus 3 52 | 53 | 54 | ## Ordered 55 | 56 | Tight: 57 | 58 | 1. First 59 | 2. Second 60 | 3. Third 61 | 62 | and: 63 | 64 | 1. One 65 | 2. Two 66 | 3. Three 67 | 68 | 69 | Loose using tabs: 70 | 71 | 1. First 72 | 73 | 2. Second 74 | 75 | 3. Third 76 | 77 | and using spaces: 78 | 79 | 1. One 80 | 81 | 2. Two 82 | 83 | 3. Three 84 | 85 | Multiple paragraphs: 86 | 87 | 1. Item 1, graf one. 88 | 89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's 90 | back. 91 | 92 | 2. Item 2. 93 | 94 | 3. Item 3. 95 | 96 | 97 | 98 | ## Nested 99 | 100 | * Tab 101 | * Tab 102 | * Tab 103 | 104 | Here's another: 105 | 106 | 1. First 107 | 2. Second: 108 | * Fee 109 | * Fie 110 | * Foe 111 | 3. Third 112 | 113 | Same thing but with paragraphs: 114 | 115 | 1. First 116 | 117 | 2. Second: 118 | * Fee 119 | * Fie 120 | * Foe 121 | 122 | 3. Third 123 | 124 | 125 | This was an error in Markdown 1.0.1: 126 | 127 | * this 128 | 129 | * sub 130 | 131 | that 132 | -------------------------------------------------------------------------------- /test/tests/ref_paren.html: -------------------------------------------------------------------------------- 1 |

hi

2 | -------------------------------------------------------------------------------- /test/tests/ref_paren.text: -------------------------------------------------------------------------------- 1 | [hi] 2 | 3 | [hi]: /url (there) 4 | -------------------------------------------------------------------------------- /test/tests/same_bullet.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • test
  • 3 |
  • test
  • 4 |
  • test
  • 5 |
6 | -------------------------------------------------------------------------------- /test/tests/same_bullet.text: -------------------------------------------------------------------------------- 1 | * test 2 | + test 3 | - test 4 | -------------------------------------------------------------------------------- /test/tests/strong_and_em_together.html: -------------------------------------------------------------------------------- 1 |

This is strong and em.

2 | 3 |

So is this word.

4 | 5 |

This is strong and em.

6 | 7 |

So is this word.

8 | -------------------------------------------------------------------------------- /test/tests/strong_and_em_together.text: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /test/tests/tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 |
  • this is a list item 5 | indented with spaces

  • 6 |
7 | 8 |

Code:

9 | 10 |
this code block is indented by one tab
11 | 
12 | 13 |

And:

14 | 15 |
    this code block is indented by two tabs
16 | 
17 | 18 |

And:

19 | 20 |
+   this is an example list item
21 |     indented with tabs
22 | 
23 | +   this is an example list item
24 |     indented with spaces
25 | 
26 | -------------------------------------------------------------------------------- /test/tests/tabs.text: -------------------------------------------------------------------------------- 1 | + this is a list item 2 | indented with tabs 3 | 4 | + this is a list item 5 | indented with spaces 6 | 7 | Code: 8 | 9 | this code block is indented by one tab 10 | 11 | And: 12 | 13 | this code block is indented by two tabs 14 | 15 | And: 16 | 17 | + this is an example list item 18 | indented with tabs 19 | 20 | + this is an example list item 21 | indented with spaces 22 | -------------------------------------------------------------------------------- /test/tests/text.smartypants.html: -------------------------------------------------------------------------------- 1 |

Hello world ‘how’ “are” you — today…

2 | -------------------------------------------------------------------------------- /test/tests/text.smartypants.text: -------------------------------------------------------------------------------- 1 | Hello world 'how' "are" you -- today... 2 | -------------------------------------------------------------------------------- /test/tests/tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 |
    4 |
  • asterisk 1
  • 5 |
  • asterisk 2
  • 6 |
  • asterisk 3
  • 7 |
8 |
9 | -------------------------------------------------------------------------------- /test/tests/tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /test/tests/toplevel_paragraphs.html: -------------------------------------------------------------------------------- 1 |

hello world 2 | how are you 3 | how are you

4 | 5 |

hello world

6 |
how are you
7 | 8 |

hello world

9 |
10 | 11 |

hello world

12 |

how are you

13 | 14 |

hello world

15 |

how are you

16 | 17 |

hello world

18 |

how are you

19 | 20 |

hello world 21 | * how are you

22 | 23 |

hello world

24 |
how are you
25 | 26 |

hello world 27 | how are you

28 | 29 |

hello world 30 |

31 | 32 |
hello
33 | 34 |

hello

35 | -------------------------------------------------------------------------------- /test/tests/toplevel_paragraphs.text: -------------------------------------------------------------------------------- 1 | hello world 2 | how are you 3 | how are you 4 | 5 | hello world 6 | ``` 7 | how are you 8 | ``` 9 | 10 | hello world 11 | * * * 12 | 13 | hello world 14 | # how are you 15 | 16 | hello world 17 | how are you 18 | =========== 19 | 20 | hello world 21 | > how are you 22 | 23 | hello world 24 | * how are you 25 | 26 | hello world 27 |
how are you
28 | 29 | hello world 30 | how are you 31 | 32 | hello [world][how] 33 | [how]: /are/you 34 | 35 |
hello
36 | 37 | hello 38 | -------------------------------------------------------------------------------- /test/tests/tricky_list.html: -------------------------------------------------------------------------------- 1 |

hello world

2 | 3 |
    4 |
  • hello world
  • 5 |
6 | 7 |

hello world

8 | 9 |
    10 |
  • hello world
  • 11 |
12 | 13 |

hello world

14 | 15 |
    16 |
  • Hello world
  • 17 |
18 | 19 |

hello world

20 | 21 |
    22 |
  • hello world
  • 23 |
24 | -------------------------------------------------------------------------------- /test/tests/tricky_list.text: -------------------------------------------------------------------------------- 1 | **hello** _world_ 2 | 3 | * hello world 4 | 5 | **hello** _world_ 6 | 7 | * hello world 8 | 9 | **hello** _world_ 10 | 11 | * Hello world 12 | 13 | **hello** _world_ 14 | 15 | * hello world 16 | --------------------------------------------------------------------------------