templates/static/js/codemirror/mode/markdown/test.js in swagr-0.0.8 vs templates/static/js/codemirror/mode/markdown/test.js in swagr-0.0.10
- old
+ new
@@ -1,1266 +1,579 @@
-// Initiate ModeTest and set defaults
-var MT = ModeTest;
-MT.modeName = 'markdown';
-MT.modeOptions = {};
+(function() {
+ var mode = CodeMirror.getMode({tabSize: 4}, "markdown");
+ function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
-MT.testMode(
- 'plainText',
- 'foo',
- [
- null, 'foo'
- ]
-);
+ MT("plainText",
+ "foo");
-// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
-MT.testMode(
- 'codeBlocksUsing4Spaces',
- ' foo',
- [
- null, ' ',
- 'comment', 'foo'
- ]
-);
-// Code blocks using 4 spaces with internal indentation
-MT.testMode(
- 'codeBlocksUsing4SpacesIndentation',
- ' bar\n hello\n world\n foo\nbar',
- [
- null, ' ',
- 'comment', 'bar',
- null, ' ',
- 'comment', 'hello',
- null, ' ',
- 'comment', 'world',
- null, ' ',
- 'comment', 'foo',
- null, 'bar'
- ]
-);
-// Code blocks using 4 spaces with internal indentation
-MT.testMode(
- 'codeBlocksUsing4SpacesIndentation',
- ' foo\n bar\n hello\n world',
- [
- null, ' foo',
- null, ' ',
- 'comment', 'bar',
- null, ' ',
- 'comment', 'hello',
- null, ' ',
- 'comment', 'world'
- ]
-);
+ // Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
+ MT("codeBlocksUsing4Spaces",
+ " [comment foo]");
-// Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
-MT.testMode(
- 'codeBlocksUsing1Tab',
- '\tfoo',
- [
- null, '\t',
- 'comment', 'foo'
- ]
-);
+ // Code blocks using 4 spaces with internal indentation
+ MT("codeBlocksUsing4SpacesIndentation",
+ " [comment bar]",
+ " [comment hello]",
+ " [comment world]",
+ " [comment foo]",
+ "bar");
-// Inline code using backticks
-MT.testMode(
- 'inlineCodeUsingBackticks',
- 'foo `bar`',
- [
- null, 'foo ',
- 'comment', '`bar`'
- ]
-);
+ // Code blocks using 4 spaces with internal indentation
+ MT("codeBlocksUsing4SpacesIndentation",
+ " foo",
+ " [comment bar]",
+ " [comment hello]",
+ " [comment world]");
-// Block code using single backtick (shouldn't work)
-MT.testMode(
- 'blockCodeSingleBacktick',
- '`\nfoo\n`',
- [
- 'comment', '`',
- null, 'foo',
- 'comment', '`'
- ]
-);
+ // Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
+ MT("codeBlocksUsing1Tab",
+ "\t[comment foo]");
-// Unclosed backticks
-// Instead of simply marking as CODE, it would be nice to have an
-// incomplete flag for CODE, that is styled slightly different.
-MT.testMode(
- 'unclosedBackticks',
- 'foo `bar',
- [
- null, 'foo ',
- 'comment', '`bar'
- ]
-);
+ // Inline code using backticks
+ MT("inlineCodeUsingBackticks",
+ "foo [comment `bar`]");
-// Per documentation: "To include a literal backtick character within a
-// code span, you can use multiple backticks as the opening and closing
-// delimiters"
-MT.testMode(
- 'doubleBackticks',
- '``foo ` bar``',
- [
- 'comment', '``foo ` bar``'
- ]
-);
+ // Block code using single backtick (shouldn't work)
+ MT("blockCodeSingleBacktick",
+ "[comment `]",
+ "foo",
+ "[comment `]");
-// Tests based on Dingus
-// http://daringfireball.net/projects/markdown/dingus
-//
-// Multiple backticks within an inline code block
-MT.testMode(
- 'consecutiveBackticks',
- '`foo```bar`',
- [
- 'comment', '`foo```bar`'
- ]
-);
-// Multiple backticks within an inline code block with a second code block
-MT.testMode(
- 'consecutiveBackticks',
- '`foo```bar` hello `world`',
- [
- 'comment', '`foo```bar`',
- null, ' hello ',
- 'comment', '`world`'
- ]
-);
-// Unclosed with several different groups of backticks
-MT.testMode(
- 'unclosedBackticks',
- '``foo ``` bar` hello',
- [
- 'comment', '``foo ``` bar` hello'
- ]
-);
-// Closed with several different groups of backticks
-MT.testMode(
- 'closedBackticks',
- '``foo ``` bar` hello`` world',
- [
- 'comment', '``foo ``` bar` hello``',
- null, ' world'
- ]
-);
+ // Unclosed backticks
+ // Instead of simply marking as CODE, it would be nice to have an
+ // incomplete flag for CODE, that is styled slightly different.
+ MT("unclosedBackticks",
+ "foo [comment `bar]");
-// atx headers
-// http://daringfireball.net/projects/markdown/syntax#header
-//
-// H1
-MT.testMode(
- 'atxH1',
- '# foo',
- [
- 'header', '# foo'
- ]
-);
-// H2
-MT.testMode(
- 'atxH2',
- '## foo',
- [
- 'header', '## foo'
- ]
-);
-// H3
-MT.testMode(
- 'atxH3',
- '### foo',
- [
- 'header', '### foo'
- ]
-);
-// H4
-MT.testMode(
- 'atxH4',
- '#### foo',
- [
- 'header', '#### foo'
- ]
-);
-// H5
-MT.testMode(
- 'atxH5',
- '##### foo',
- [
- 'header', '##### foo'
- ]
-);
-// H6
-MT.testMode(
- 'atxH6',
- '###### foo',
- [
- 'header', '###### foo'
- ]
-);
-// H6 - 7x '#' should still be H6, per Dingus
-// http://daringfireball.net/projects/markdown/dingus
-MT.testMode(
- 'atxH6NotH7',
- '####### foo',
- [
- 'header', '####### foo'
- ]
-);
+ // Per documentation: "To include a literal backtick character within a
+ // code span, you can use multiple backticks as the opening and closing
+ // delimiters"
+ MT("doubleBackticks",
+ "[comment ``foo ` bar``]");
-// Setext headers - H1, H2
-// Per documentation, "Any number of underlining =’s or -’s will work."
-// http://daringfireball.net/projects/markdown/syntax#header
-// Ideally, the text would be marked as `header` as well, but this is
-// not really feasible at the moment. So, instead, we're testing against
-// what works today, to avoid any regressions.
-//
-// Check if single underlining = works
-MT.testMode(
- 'setextH1',
- 'foo\n=',
- [
- null, 'foo',
- 'header', '='
- ]
-);
-// Check if 3+ ='s work
-MT.testMode(
- 'setextH1',
- 'foo\n===',
- [
- null, 'foo',
- 'header', '==='
- ]
-);
-// Check if single underlining - works
-MT.testMode(
- 'setextH2',
- 'foo\n-',
- [
- null, 'foo',
- 'header', '-'
- ]
-);
-// Check if 3+ -'s work
-MT.testMode(
- 'setextH2',
- 'foo\n---',
- [
- null, 'foo',
- 'header', '---'
- ]
-);
+ // Tests based on Dingus
+ // http://daringfireball.net/projects/markdown/dingus
+ //
+ // Multiple backticks within an inline code block
+ MT("consecutiveBackticks",
+ "[comment `foo```bar`]");
-// Single-line blockquote with trailing space
-MT.testMode(
- 'blockquoteSpace',
- '> foo',
- [
- 'quote', '> foo'
- ]
-);
+ // Multiple backticks within an inline code block with a second code block
+ MT("consecutiveBackticks",
+ "[comment `foo```bar`] hello [comment `world`]");
-// Single-line blockquote
-MT.testMode(
- 'blockquoteNoSpace',
- '>foo',
- [
- 'quote', '>foo'
- ]
-);
+ // Unclosed with several different groups of backticks
+ MT("unclosedBackticks",
+ "[comment ``foo ``` bar` hello]");
-// Single-line blockquote followed by normal paragraph
-MT.testMode(
- 'blockquoteThenParagraph',
- '>foo\n\nbar',
- [
- 'quote', '>foo',
- null, 'bar'
- ]
-);
+ // Closed with several different groups of backticks
+ MT("closedBackticks",
+ "[comment ``foo ``` bar` hello``] world");
-// Multi-line blockquote (lazy mode)
-MT.testMode(
- 'multiBlockquoteLazy',
- '>foo\nbar',
- [
- 'quote', '>foo',
- 'quote', 'bar'
- ]
-);
+ // atx headers
+ // http://daringfireball.net/projects/markdown/syntax#header
-// Multi-line blockquote followed by normal paragraph (lazy mode)
-MT.testMode(
- 'multiBlockquoteLazyThenParagraph',
- '>foo\nbar\n\nhello',
- [
- 'quote', '>foo',
- 'quote', 'bar',
- null, 'hello'
- ]
-);
+ MT("atxH1",
+ "[header # foo]");
-// Multi-line blockquote (non-lazy mode)
-MT.testMode(
- 'multiBlockquote',
- '>foo\n>bar',
- [
- 'quote', '>foo',
- 'quote', '>bar'
- ]
-);
+ MT("atxH2",
+ "[header ## foo]");
-// Multi-line blockquote followed by normal paragraph (non-lazy mode)
-MT.testMode(
- 'multiBlockquoteThenParagraph',
- '>foo\n>bar\n\nhello',
- [
- 'quote', '>foo',
- 'quote', '>bar',
- null, 'hello'
- ]
-);
+ MT("atxH3",
+ "[header ### foo]");
-// Check list types
-MT.testMode(
- 'listAsterisk',
- '* foo\n* bar',
- [
- 'string', '* foo',
- 'string', '* bar'
- ]
-);
-MT.testMode(
- 'listPlus',
- '+ foo\n+ bar',
- [
- 'string', '+ foo',
- 'string', '+ bar'
- ]
-);
-MT.testMode(
- 'listDash',
- '- foo\n- bar',
- [
- 'string', '- foo',
- 'string', '- bar'
- ]
-);
-MT.testMode(
- 'listNumber',
- '1. foo\n2. bar',
- [
- 'string', '1. foo',
- 'string', '2. bar'
- ]
-);
+ MT("atxH4",
+ "[header #### foo]");
-// Formatting in lists (*)
-MT.testMode(
- 'listAsteriskFormatting',
- '* *foo* bar\n\n* **foo** bar\n\n* ***foo*** bar\n\n* `foo` bar',
- [
- 'string', '* ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '* ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '* ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '* ',
- 'string comment', '`foo`',
- 'string', ' bar'
- ]
-);
-// Formatting in lists (+)
-MT.testMode(
- 'listPlusFormatting',
- '+ *foo* bar\n\n+ **foo** bar\n\n+ ***foo*** bar\n\n+ `foo` bar',
- [
- 'string', '+ ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '+ ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '+ ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '+ ',
- 'string comment', '`foo`',
- 'string', ' bar'
- ]
-);
-// Formatting in lists (-)
-MT.testMode(
- 'listDashFormatting',
- '- *foo* bar\n\n- **foo** bar\n\n- ***foo*** bar\n\n- `foo` bar',
- [
- 'string', '- ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '- ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '- ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '- ',
- 'string comment', '`foo`',
- 'string', ' bar'
- ]
-);
-// Formatting in lists (1.)
-MT.testMode(
- 'listNumberFormatting',
- '1. *foo* bar\n\n2. **foo** bar\n\n3. ***foo*** bar\n\n4. `foo` bar',
- [
- 'string', '1. ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '2. ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '3. ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '4. ',
- 'string comment', '`foo`',
- 'string', ' bar'
- ]
-);
+ MT("atxH5",
+ "[header ##### foo]");
-// Paragraph lists
-MT.testMode(
- 'listParagraph',
- '* foo\n\n* bar',
- [
- 'string', '* foo',
- 'string', '* bar'
- ]
-);
+ MT("atxH6",
+ "[header ###### foo]");
-// Multi-paragraph lists
-//
-// 4 spaces
-MT.testMode(
- 'listMultiParagraph',
- '* foo\n\n* bar\n\n hello',
- [
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string', 'hello'
- ]
-);
-// 4 spaces, extra blank lines (should still be list, per Dingus)
-MT.testMode(
- 'listMultiParagraphExtra',
- '* foo\n\n* bar\n\n\n hello',
- [
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string', 'hello'
- ]
-);
-// 4 spaces, plus 1 space (should still be list, per Dingus)
-MT.testMode(
- 'listMultiParagraphExtraSpace',
- '* foo\n\n* bar\n\n hello\n\n world',
- [
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string', 'hello',
- null, ' ',
- 'string', 'world'
- ]
-);
-// 1 tab
-MT.testMode(
- 'listTab',
- '* foo\n\n* bar\n\n\thello',
- [
- 'string', '* foo',
- 'string', '* bar',
- null, '\t',
- 'string', 'hello'
- ]
-);
-// No indent
-MT.testMode(
- 'listNoIndent',
- '* foo\n\n* bar\n\nhello',
- [
- 'string', '* foo',
- 'string', '* bar',
- null, 'hello'
- ]
-);
-// Blockquote
-MT.testMode(
- 'blockquote',
- '* foo\n\n* bar\n\n > hello',
- [
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string quote', '> hello'
- ]
-);
-// Code block
-MT.testMode(
- 'blockquoteCode',
- '* foo\n\n* bar\n\n > hello\n\n world',
- [
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'comment', '> hello',
- null, ' ',
- 'string', 'world'
- ]
-);
-// Code block followed by text
-MT.testMode(
- 'blockquoteCodeText',
- '* foo\n\n bar\n\n hello\n\n world',
- [
- 'string', '* foo',
- null, ' ',
- 'string', 'bar',
- null, ' ',
- 'comment', 'hello',
- null, ' ',
- 'string', 'world'
- ]
-);
+ // H6 - 7x '#' should still be H6, per Dingus
+ // http://daringfireball.net/projects/markdown/dingus
+ MT("atxH6NotH7",
+ "[header ####### foo]");
-// Nested list
-//
-// *
-MT.testMode(
- 'listAsteriskNested',
- '* foo\n\n * bar',
- [
- 'string', '* foo',
- null, ' ',
- 'string', '* bar'
- ]
-);
-// +
-MT.testMode(
- 'listPlusNested',
- '+ foo\n\n + bar',
- [
- 'string', '+ foo',
- null, ' ',
- 'string', '+ bar'
- ]
-);
-// -
-MT.testMode(
- 'listDashNested',
- '- foo\n\n - bar',
- [
- 'string', '- foo',
- null, ' ',
- 'string', '- bar'
- ]
-);
-// 1.
-MT.testMode(
- 'listNumberNested',
- '1. foo\n\n 2. bar',
- [
- 'string', '1. foo',
- null, ' ',
- 'string', '2. bar'
- ]
-);
-// Mixed
-MT.testMode(
- 'listMixed',
- '* foo\n\n + bar\n\n - hello\n\n 1. world',
- [
- 'string', '* foo',
- null, ' ',
- 'string', '+ bar',
- null, ' ',
- 'string', '- hello',
- null, ' ',
- 'string', '1. world'
- ]
-);
-// Blockquote
-MT.testMode(
- 'listBlockquote',
- '* foo\n\n + bar\n\n > hello',
- [
- 'string', '* foo',
- null, ' ',
- 'string', '+ bar',
- null, ' ',
- 'quote string', '> hello'
- ]
-);
-// Code
-MT.testMode(
- 'listCode',
- '* foo\n\n + bar\n\n hello',
- [
- 'string', '* foo',
- null, ' ',
- 'string', '+ bar',
- null, ' ',
- 'comment', 'hello'
- ]
-);
-// Code with internal indentation
-MT.testMode(
- 'listCodeIndentation',
- '* foo\n\n bar\n hello\n world\n foo\n bar',
- [
- 'string', '* foo',
- null, ' ',
- 'comment', 'bar',
- null, ' ',
- 'comment', 'hello',
- null, ' ',
- 'comment', 'world',
- null, ' ',
- 'comment', 'foo',
- null, ' ',
- 'string', 'bar'
- ]
-);
-// Code followed by text
-MT.testMode(
- 'listCodeText',
- '* foo\n\n bar\n\nhello',
- [
- 'string', '* foo',
- null, ' ',
- 'comment', 'bar',
- null, 'hello'
- ]
-);
+ // Setext headers - H1, H2
+ // Per documentation, "Any number of underlining =’s or -’s will work."
+ // http://daringfireball.net/projects/markdown/syntax#header
+ // Ideally, the text would be marked as `header` as well, but this is
+ // not really feasible at the moment. So, instead, we're testing against
+ // what works today, to avoid any regressions.
+ //
+ // Check if single underlining = works
+ MT("setextH1",
+ "foo",
+ "[header =]");
-// Following tests directly from official Markdown documentation
-// http://daringfireball.net/projects/markdown/syntax#hr
-MT.testMode(
- 'hrSpace',
- '* * *',
- [
- 'hr', '* * *'
- ]
-);
+ // Check if 3+ ='s work
+ MT("setextH1",
+ "foo",
+ "[header ===]");
-MT.testMode(
- 'hr',
- '***',
- [
- 'hr', '***'
- ]
-);
+ // Check if single underlining - works
+ MT("setextH2",
+ "foo",
+ "[header -]");
-MT.testMode(
- 'hrLong',
- '*****',
- [
- 'hr', '*****'
- ]
-);
+ // Check if 3+ -'s work
+ MT("setextH2",
+ "foo",
+ "[header ---]");
-MT.testMode(
- 'hrSpaceDash',
- '- - -',
- [
- 'hr', '- - -'
- ]
-);
+ // Single-line blockquote with trailing space
+ MT("blockquoteSpace",
+ "[quote > foo]");
-MT.testMode(
- 'hrDashLong',
- '---------------------------------------',
- [
- 'hr', '---------------------------------------'
- ]
-);
+ // Single-line blockquote
+ MT("blockquoteNoSpace",
+ "[quote >foo]");
-// Inline link with title
-MT.testMode(
- 'linkTitle',
- '[foo](http://example.com/ "bar") hello',
- [
- 'link', '[foo]',
- 'string', '(http://example.com/ "bar")',
- null, ' hello'
- ]
-);
+ // Single-line blockquote followed by normal paragraph
+ MT("blockquoteThenParagraph",
+ "[quote >foo]",
+ "",
+ "bar");
-// Inline link without title
-MT.testMode(
- 'linkNoTitle',
- '[foo](http://example.com/) bar',
- [
- 'link', '[foo]',
- 'string', '(http://example.com/)',
- null, ' bar'
- ]
-);
+ // Multi-line blockquote (lazy mode)
+ MT("multiBlockquoteLazy",
+ "[quote >foo]",
+ "[quote bar]");
-// Inline link with Em
-MT.testMode(
- 'linkEm',
- '[*foo*](http://example.com/) bar',
- [
- 'link', '[',
- 'link em', '*foo*',
- 'link', ']',
- 'string', '(http://example.com/)',
- null, ' bar'
- ]
-);
+ // Multi-line blockquote followed by normal paragraph (lazy mode)
+ MT("multiBlockquoteLazyThenParagraph",
+ "[quote >foo]",
+ "[quote bar]",
+ "",
+ "hello");
-// Inline link with Strong
-MT.testMode(
- 'linkStrong',
- '[**foo**](http://example.com/) bar',
- [
- 'link', '[',
- 'link strong', '**foo**',
- 'link', ']',
- 'string', '(http://example.com/)',
- null, ' bar'
- ]
-);
+ // Multi-line blockquote (non-lazy mode)
+ MT("multiBlockquote",
+ "[quote >foo]",
+ "[quote >bar]");
-// Inline link with EmStrong
-MT.testMode(
- 'linkEmStrong',
- '[***foo***](http://example.com/) bar',
- [
- 'link', '[',
- 'link strong', '**',
- 'link emstrong', '*foo**',
- 'link em', '*',
- 'link', ']',
- 'string', '(http://example.com/)',
- null, ' bar'
- ]
-);
+ // Multi-line blockquote followed by normal paragraph (non-lazy mode)
+ MT("multiBlockquoteThenParagraph",
+ "[quote >foo]",
+ "[quote >bar]",
+ "",
+ "hello");
-// Image with title
-MT.testMode(
- 'imageTitle',
- '![foo](http://example.com/ "bar") hello',
- [
- 'tag', '![foo]',
- 'string', '(http://example.com/ "bar")',
- null, ' hello'
- ]
-);
+ // Check list types
-// Image without title
-MT.testMode(
- 'imageNoTitle',
- '![foo](http://example.com/) bar',
- [
- 'tag', '![foo]',
- 'string', '(http://example.com/)',
- null, ' bar'
- ]
-);
+ MT("listAsterisk",
+ "[string * foo]",
+ "[string * bar]");
-// Image with asterisks
-MT.testMode(
- 'imageAsterisks',
- '![*foo*](http://example.com/) bar',
- [
- 'tag', '![*foo*]',
- 'string', '(http://example.com/)',
- null, ' bar'
- ]
-);
+ MT("listPlus",
+ "[string + foo]",
+ "[string + bar]");
-// Not a link. Should be normal text due to square brackets being used
-// regularly in text, especially in quoted material, and no space is allowed
-// between square brackets and parentheses (per Dingus).
-MT.testMode(
- 'notALink',
- '[foo] (bar)',
- [
- null, '[foo] (bar)'
- ]
-);
+ MT("listDash",
+ "[string - foo]",
+ "[string - bar]");
-// Reference-style links
-MT.testMode(
- 'linkReference',
- '[foo][bar] hello',
- [
- 'link', '[foo]',
- 'string', '[bar]',
- null, ' hello'
- ]
-);
-// Reference-style links with Em
-MT.testMode(
- 'linkReferenceEm',
- '[*foo*][bar] hello',
- [
- 'link', '[',
- 'link em', '*foo*',
- 'link', ']',
- 'string', '[bar]',
- null, ' hello'
- ]
-);
-// Reference-style links with Strong
-MT.testMode(
- 'linkReferenceStrong',
- '[**foo**][bar] hello',
- [
- 'link', '[',
- 'link strong', '**foo**',
- 'link', ']',
- 'string', '[bar]',
- null, ' hello'
- ]
-);
-// Reference-style links with EmStrong
-MT.testMode(
- 'linkReferenceEmStrong',
- '[***foo***][bar] hello',
- [
- 'link', '[',
- 'link strong', '**',
- 'link emstrong', '*foo**',
- 'link em', '*',
- 'link', ']',
- 'string', '[bar]',
- null, ' hello'
- ]
-);
+ MT("listNumber",
+ "[string 1. foo]",
+ "[string 2. bar]");
-// Reference-style links with optional space separator (per docuentation)
-// "You can optionally use a space to separate the sets of brackets"
-MT.testMode(
- 'linkReferenceSpace',
- '[foo] [bar] hello',
- [
- 'link', '[foo]',
- null, ' ',
- 'string', '[bar]',
- null, ' hello'
- ]
-);
-// Should only allow a single space ("...use *a* space...")
-MT.testMode(
- 'linkReferenceDoubleSpace',
- '[foo] [bar] hello',
- [
- null, '[foo] [bar] hello'
- ]
-);
+ // Formatting in lists (*)
+ MT("listAsteriskFormatting",
+ "[string * ][string&em *foo*][string bar]",
+ "[string * ][string&strong **foo**][string bar]",
+ "[string * ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
+ "[string * ][string&comment `foo`][string bar]");
-// Reference-style links with implicit link name
-MT.testMode(
- 'linkImplicit',
- '[foo][] hello',
- [
- 'link', '[foo]',
- 'string', '[]',
- null, ' hello'
- ]
-);
+ // Formatting in lists (+)
+ MT("listPlusFormatting",
+ "[string + ][string&em *foo*][string bar]",
+ "[string + ][string&strong **foo**][string bar]",
+ "[string + ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
+ "[string + ][string&comment `foo`][string bar]");
-// @todo It would be nice if, at some point, the document was actually
-// checked to see if the referenced link exists
+ // Formatting in lists (-)
+ MT("listDashFormatting",
+ "[string - ][string&em *foo*][string bar]",
+ "[string - ][string&strong **foo**][string bar]",
+ "[string - ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
+ "[string - ][string&comment `foo`][string bar]");
-// Link label, for reference-style links (taken from documentation)
-//
-// No title
-MT.testMode(
- 'labelNoTitle',
- '[foo]: http://example.com/',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/'
- ]
-);
-// Space in ID and title
-MT.testMode(
- 'labelSpaceTitle',
- '[foo bar]: http://example.com/ "hello"',
- [
- 'link', '[foo bar]:',
- null, ' ',
- 'string', 'http://example.com/ "hello"'
- ]
-);
-// Double title
-MT.testMode(
- 'labelDoubleTitle',
- '[foo bar]: http://example.com/ "hello" "world"',
- [
- 'link', '[foo bar]:',
- null, ' ',
- 'string', 'http://example.com/ "hello"',
- null, ' "world"'
- ]
-);
-// Double quotes around title
-MT.testMode(
- 'labelTitleDoubleQuotes',
- '[foo]: http://example.com/ "bar"',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/ "bar"'
- ]
-);
-// Single quotes around title
-MT.testMode(
- 'labelTitleSingleQuotes',
- '[foo]: http://example.com/ \'bar\'',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/ \'bar\''
- ]
-);
-// Parentheses around title
-MT.testMode(
- 'labelTitleParenthese',
- '[foo]: http://example.com/ (bar)',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/ (bar)'
- ]
-);
-// Invalid title
-MT.testMode(
- 'labelTitleInvalid',
- '[foo]: http://example.com/ bar',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- null, ' bar'
- ]
-);
-// Angle brackets around URL
-MT.testMode(
- 'labelLinkAngleBrackets',
- '[foo]: <http://example.com/> "bar"',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', '<http://example.com/> "bar"'
- ]
-);
-// Title on next line per documentation (double quotes)
-MT.testMode(
- 'labelTitleNextDoubleQuotes',
- '[foo]: http://example.com/\n"bar" hello',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- 'string', '"bar"',
- null, ' hello'
- ]
-);
-// Title on next line per documentation (single quotes)
-MT.testMode(
- 'labelTitleNextSingleQuotes',
- '[foo]: http://example.com/\n\'bar\' hello',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- 'string', '\'bar\'',
- null, ' hello'
- ]
-);
-// Title on next line per documentation (parentheses)
-MT.testMode(
- 'labelTitleNextParenthese',
- '[foo]: http://example.com/\n(bar) hello',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- 'string', '(bar)',
- null, ' hello'
- ]
-);
-// Title on next line per documentation (mixed)
-MT.testMode(
- 'labelTitleNextMixed',
- '[foo]: http://example.com/\n(bar" hello',
- [
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- null, '(bar" hello'
- ]
-);
+ // Formatting in lists (1.)
+ MT("listNumberFormatting",
+ "[string 1. ][string&em *foo*][string bar]",
+ "[string 2. ][string&strong **foo**][string bar]",
+ "[string 3. ][string&strong **][string&emstrong *foo**][string&em *][string bar]",
+ "[string 4. ][string&comment `foo`][string bar]");
-// Automatic links
-MT.testMode(
- 'linkWeb',
- '<http://example.com/> foo',
- [
- 'link', '<http://example.com/>',
- null, ' foo'
- ]
-);
+ // Paragraph lists
+ MT("listParagraph",
+ "[string * foo]",
+ "",
+ "[string * bar]");
-// Automatic email links
-MT.testMode(
- 'linkEmail',
- '<user@example.com> foo',
- [
- 'link', '<user@example.com>',
- null, ' foo'
- ]
-);
+ // Multi-paragraph lists
+ //
+ // 4 spaces
+ MT("listMultiParagraph",
+ "[string * foo]",
+ "",
+ "[string * bar]",
+ "",
+ " [string hello]");
-// Single asterisk
-MT.testMode(
- 'emAsterisk',
- '*foo* bar',
- [
- 'em', '*foo*',
- null, ' bar'
- ]
-);
+ // 4 spaces, extra blank lines (should still be list, per Dingus)
+ MT("listMultiParagraphExtra",
+ "[string * foo]",
+ "",
+ "[string * bar]",
+ "",
+ " [string hello]");
-// Single underscore
-MT.testMode(
- 'emUnderscore',
- '_foo_ bar',
- [
- 'em', '_foo_',
- null, ' bar'
- ]
-);
+ // 4 spaces, plus 1 space (should still be list, per Dingus)
+ MT("listMultiParagraphExtraSpace",
+ "[string * foo]",
+ "",
+ "[string * bar]",
+ "",
+ " [string hello]",
+ "",
+ " [string world]");
-// Emphasis characters within a word
-MT.testMode(
- 'emInWordAsterisk',
- 'foo*bar*hello',
- [
- null, 'foo',
- 'em', '*bar*',
- null, 'hello'
- ]
-);
-MT.testMode(
- 'emInWordUnderscore',
- 'foo_bar_hello',
- [
- null, 'foo',
- 'em', '_bar_',
- null, 'hello'
- ]
-);
-// Per documentation: "...surround an * or _ with spaces, it’ll be
-// treated as a literal asterisk or underscore."
-//
-// Inside EM
-MT.testMode(
- 'emEscapedBySpaceIn',
- 'foo _bar _ hello_ world',
- [
- null, 'foo ',
- 'em', '_bar _ hello_',
- null, ' world'
- ]
-);
-// Outside EM
-MT.testMode(
- 'emEscapedBySpaceOut',
- 'foo _ bar_hello_world',
- [
- null, 'foo _ bar',
- 'em', '_hello_',
- null, 'world'
- ]
-);
+ // 1 tab
+ MT("listTab",
+ "[string * foo]",
+ "",
+ "[string * bar]",
+ "",
+ "\t[string hello]");
-// Unclosed emphasis characters
-// Instead of simply marking as EM / STRONG, it would be nice to have an
-// incomplete flag for EM and STRONG, that is styled slightly different.
-MT.testMode(
- 'emIncompleteAsterisk',
- 'foo *bar',
- [
- null, 'foo ',
- 'em', '*bar'
- ]
-);
-MT.testMode(
- 'emIncompleteUnderscore',
- 'foo _bar',
- [
- null, 'foo ',
- 'em', '_bar'
- ]
-);
+ // No indent
+ MT("listNoIndent",
+ "[string * foo]",
+ "",
+ "[string * bar]",
+ "",
+ "hello");
-// Double asterisk
-MT.testMode(
- 'strongAsterisk',
- '**foo** bar',
- [
- 'strong', '**foo**',
- null, ' bar'
- ]
-);
+ // Blockquote
+ MT("blockquote",
+ "[string * foo]",
+ "",
+ "[string * bar]",
+ "",
+ " [string"e > hello]");
-// Double underscore
-MT.testMode(
- 'strongUnderscore',
- '__foo__ bar',
- [
- 'strong', '__foo__',
- null, ' bar'
- ]
-);
+ // Code block
+ MT("blockquoteCode",
+ "[string * foo]",
+ "",
+ "[string * bar]",
+ "",
+ " [comment > hello]",
+ "",
+ " [string world]");
-// Triple asterisk
-MT.testMode(
- 'emStrongAsterisk',
- '*foo**bar*hello** world',
- [
- 'em', '*foo',
- 'emstrong', '**bar*',
- 'strong', 'hello**',
- null, ' world'
- ]
-);
+ // Code block followed by text
+ MT("blockquoteCodeText",
+ "[string * foo]",
+ "",
+ " [string bar]",
+ "",
+ " [comment hello]",
+ "",
+ " [string world]");
-// Triple underscore
-MT.testMode(
- 'emStrongUnderscore',
- '_foo__bar_hello__ world',
- [
- 'em', '_foo',
- 'emstrong', '__bar_',
- 'strong', 'hello__',
- null, ' world'
- ]
-);
+ // Nested list
-// Triple mixed
-// "...same character must be used to open and close an emphasis span.""
-MT.testMode(
- 'emStrongMixed',
- '_foo**bar*hello__ world',
- [
- 'em', '_foo',
- 'emstrong', '**bar*hello__ world'
- ]
-);
+ MT("listAsteriskNested",
+ "[string * foo]",
+ "",
+ " [string * bar]");
-MT.testMode(
- 'emStrongMixed',
- '*foo__bar_hello** world',
- [
- 'em', '*foo',
- 'emstrong', '__bar_hello** world'
- ]
-);
+ MT("listPlusNested",
+ "[string + foo]",
+ "",
+ " [string + bar]");
-// These characters should be escaped:
-// \ backslash
-// ` backtick
-// * asterisk
-// _ underscore
-// {} curly braces
-// [] square brackets
-// () parentheses
-// # hash mark
-// + plus sign
-// - minus sign (hyphen)
-// . dot
-// ! exclamation mark
-//
-// Backtick (code)
-MT.testMode(
- 'escapeBacktick',
- 'foo \\`bar\\`',
- [
- null, 'foo \\`bar\\`'
- ]
-);
-MT.testMode(
- 'doubleEscapeBacktick',
- 'foo \\\\`bar\\\\`',
- [
- null, 'foo \\\\',
- 'comment', '`bar\\\\`'
- ]
-);
-// Asterisk (em)
-MT.testMode(
- 'escapeAsterisk',
- 'foo \\*bar\\*',
- [
- null, 'foo \\*bar\\*'
- ]
-);
-MT.testMode(
- 'doubleEscapeAsterisk',
- 'foo \\\\*bar\\\\*',
- [
- null, 'foo \\\\',
- 'em', '*bar\\\\*'
- ]
-);
-// Underscore (em)
-MT.testMode(
- 'escapeUnderscore',
- 'foo \\_bar\\_',
- [
- null, 'foo \\_bar\\_'
- ]
-);
-MT.testMode(
- 'doubleEscapeUnderscore',
- 'foo \\\\_bar\\\\_',
- [
- null, 'foo \\\\',
- 'em', '_bar\\\\_'
- ]
-);
-// Hash mark (headers)
-MT.testMode(
- 'escapeHash',
- '\\# foo',
- [
- null, '\\# foo'
- ]
-);
-MT.testMode(
- 'doubleEscapeHash',
- '\\\\# foo',
- [
- null, '\\\\# foo'
- ]
-);
+ MT("listDashNested",
+ "[string - foo]",
+ "",
+ " [string - bar]");
+
+ MT("listNumberNested",
+ "[string 1. foo]",
+ "",
+ " [string 2. bar]");
+
+ MT("listMixed",
+ "[string * foo]",
+ "",
+ " [string + bar]",
+ "",
+ " [string - hello]",
+ "",
+ " [string 1. world]");
+
+ MT("listBlockquote",
+ "[string * foo]",
+ "",
+ " [string + bar]",
+ "",
+ " [quote&string > hello]");
+
+ MT("listCode",
+ "[string * foo]",
+ "",
+ " [string + bar]",
+ "",
+ " [comment hello]");
+
+ // Code with internal indentation
+ MT("listCodeIndentation",
+ "[string * foo]",
+ "",
+ " [comment bar]",
+ " [comment hello]",
+ " [comment world]",
+ " [comment foo]",
+ " [string bar]");
+
+ // Code followed by text
+ MT("listCodeText",
+ "[string * foo]",
+ "",
+ " [comment bar]",
+ "",
+ "hello");
+
+ // Following tests directly from official Markdown documentation
+ // http://daringfireball.net/projects/markdown/syntax#hr
+
+ MT("hrSpace",
+ "[hr * * *]");
+
+ MT("hr",
+ "[hr ***]");
+
+ MT("hrLong",
+ "[hr *****]");
+
+ MT("hrSpaceDash",
+ "[hr - - -]");
+
+ MT("hrDashLong",
+ "[hr ---------------------------------------]");
+
+ // Inline link with title
+ MT("linkTitle",
+ "[link [[foo]]][string (http://example.com/ \"bar\")] hello");
+
+ // Inline link without title
+ MT("linkNoTitle",
+ "[link [[foo]]][string (http://example.com/)] bar");
+
+ // Inline link with image
+ MT("linkImage",
+ "[link [[][tag ![[foo]]][string (http://example.com/)][link ]]][string (http://example.com/)] bar");
+
+ // Inline link with Em
+ MT("linkEm",
+ "[link [[][link&em *foo*][link ]]][string (http://example.com/)] bar");
+
+ // Inline link with Strong
+ MT("linkStrong",
+ "[link [[][link&strong **foo**][link ]]][string (http://example.com/)] bar");
+
+ // Inline link with EmStrong
+ MT("linkEmStrong",
+ "[link [[][link&strong **][link&emstrong *foo**][link&em *][link ]]][string (http://example.com/)] bar");
+
+ // Image with title
+ MT("imageTitle",
+ "[tag ![[foo]]][string (http://example.com/ \"bar\")] hello");
+
+ // Image without title
+ MT("imageNoTitle",
+ "[tag ![[foo]]][string (http://example.com/)] bar");
+
+ // Image with asterisks
+ MT("imageAsterisks",
+ "[tag ![[*foo*]]][string (http://example.com/)] bar");
+
+ // Not a link. Should be normal text due to square brackets being used
+ // regularly in text, especially in quoted material, and no space is allowed
+ // between square brackets and parentheses (per Dingus).
+ MT("notALink",
+ "[[foo]] (bar)");
+
+ // Reference-style links
+ MT("linkReference",
+ "[link [[foo]]][string [[bar]]] hello");
+
+ // Reference-style links with Em
+ MT("linkReferenceEm",
+ "[link [[][link&em *foo*][link ]]][string [[bar]]] hello");
+
+ // Reference-style links with Strong
+ MT("linkReferenceStrong",
+ "[link [[][link&strong **foo**][link ]]][string [[bar]]] hello");
+
+ // Reference-style links with EmStrong
+ MT("linkReferenceEmStrong",
+ "[link [[][link&strong **][link&emstrong *foo**][link&em *][link ]]][string [[bar]]] hello");
+
+ // Reference-style links with optional space separator (per docuentation)
+ // "You can optionally use a space to separate the sets of brackets"
+ MT("linkReferenceSpace",
+ "[link [[foo]]] [string [[bar]]] hello");
+
+ // Should only allow a single space ("...use *a* space...")
+ MT("linkReferenceDoubleSpace",
+ "[[foo]] [[bar]] hello");
+
+ // Reference-style links with implicit link name
+ MT("linkImplicit",
+ "[link [[foo]]][string [[]]] hello");
+
+ // @todo It would be nice if, at some point, the document was actually
+ // checked to see if the referenced link exists
+
+ // Link label, for reference-style links (taken from documentation)
+
+ MT("labelNoTitle",
+ "[link [[foo]]:] [string http://example.com/]");
+
+ MT("labelIndented",
+ " [link [[foo]]:] [string http://example.com/]");
+
+ MT("labelSpaceTitle",
+ "[link [[foo bar]]:] [string http://example.com/ \"hello\"]");
+
+ MT("labelDoubleTitle",
+ "[link [[foo bar]]:] [string http://example.com/ \"hello\"] \"world\"");
+
+ MT("labelTitleDoubleQuotes",
+ "[link [[foo]]:] [string http://example.com/ \"bar\"]");
+
+ MT("labelTitleSingleQuotes",
+ "[link [[foo]]:] [string http://example.com/ 'bar']");
+
+ MT("labelTitleParenthese",
+ "[link [[foo]]:] [string http://example.com/ (bar)]");
+
+ MT("labelTitleInvalid",
+ "[link [[foo]]:] [string http://example.com/] bar");
+
+ MT("labelLinkAngleBrackets",
+ "[link [[foo]]:] [string <http://example.com/> \"bar\"]");
+
+ MT("labelTitleNextDoubleQuotes",
+ "[link [[foo]]:] [string http://example.com/]",
+ "[string \"bar\"] hello");
+
+ MT("labelTitleNextSingleQuotes",
+ "[link [[foo]]:] [string http://example.com/]",
+ "[string 'bar'] hello");
+
+ MT("labelTitleNextParenthese",
+ "[link [[foo]]:] [string http://example.com/]",
+ "[string (bar)] hello");
+
+ MT("labelTitleNextMixed",
+ "[link [[foo]]:] [string http://example.com/]",
+ "(bar\" hello");
+
+ MT("linkWeb",
+ "[link <http://example.com/>] foo");
+
+ MT("linkEmail",
+ "[link <user@example.com>] foo");
+
+ MT("emAsterisk",
+ "[em *foo*] bar");
+
+ MT("emUnderscore",
+ "[em _foo_] bar");
+
+ MT("emInWordAsterisk",
+ "foo[em *bar*]hello");
+
+ MT("emInWordUnderscore",
+ "foo[em _bar_]hello");
+
+ // Per documentation: "...surround an * or _ with spaces, it’ll be
+ // treated as a literal asterisk or underscore."
+
+ MT("emEscapedBySpaceIn",
+ "foo [em _bar _ hello_] world");
+
+ MT("emEscapedBySpaceOut",
+ "foo _ bar[em _hello_]world");
+
+ // Unclosed emphasis characters
+ // Instead of simply marking as EM / STRONG, it would be nice to have an
+ // incomplete flag for EM and STRONG, that is styled slightly different.
+ MT("emIncompleteAsterisk",
+ "foo [em *bar]");
+
+ MT("emIncompleteUnderscore",
+ "foo [em _bar]");
+
+ MT("strongAsterisk",
+ "[strong **foo**] bar");
+
+ MT("strongUnderscore",
+ "[strong __foo__] bar");
+
+ MT("emStrongAsterisk",
+ "[em *foo][emstrong **bar*][strong hello**] world");
+
+ MT("emStrongUnderscore",
+ "[em _foo][emstrong __bar_][strong hello__] world");
+
+ // "...same character must be used to open and close an emphasis span.""
+ MT("emStrongMixed",
+ "[em _foo][emstrong **bar*hello__ world]");
+
+ MT("emStrongMixed",
+ "[em *foo][emstrong __bar_hello** world]");
+
+ // These characters should be escaped:
+ // \ backslash
+ // ` backtick
+ // * asterisk
+ // _ underscore
+ // {} curly braces
+ // [] square brackets
+ // () parentheses
+ // # hash mark
+ // + plus sign
+ // - minus sign (hyphen)
+ // . dot
+ // ! exclamation mark
+
+ MT("escapeBacktick",
+ "foo \\`bar\\`");
+
+ MT("doubleEscapeBacktick",
+ "foo \\\\[comment `bar\\\\`]");
+
+ MT("escapeAsterisk",
+ "foo \\*bar\\*");
+
+ MT("doubleEscapeAsterisk",
+ "foo \\\\[em *bar\\\\*]");
+
+ MT("escapeUnderscore",
+ "foo \\_bar\\_");
+
+ MT("doubleEscapeUnderscore",
+ "foo \\\\[em _bar\\\\_]");
+
+ MT("escapeHash",
+ "\\# foo");
+
+ MT("doubleEscapeHash",
+ "\\\\# foo");
+})();