: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
var mode = CodeMirror.getMode({tabSize: 4}, "markdown");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "markdown", highlightFormatting: true});
function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
var modeAtxNoSpace = CodeMirror.getMode({tabSize: 4}, {name: "markdown", allowAtxHeaderWithoutSpace: true});
function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); }
var modeFenced = CodeMirror.getMode({tabSize: 4}, {name: "markdown", fencedCodeBlocks: true});
function FencedTest(name) { test.mode(name, modeFenced, Array.prototype.slice.call(arguments, 1)); }
var modeOverrideClasses = CodeMirror.getMode({tabsize: 4}, {
"header" : "override-header",
"code" : "override-code",
"quote" : "override-quote",
"list1" : "override-list1",
"list2" : "override-list2",
"list3" : "override-list3",
"image" : "override-image",
"imageAltText": "override-image-alt-text",
"imageMarker": "override-image-marker",
"linkInline" : "override-link-inline",
"linkEmail" : "override-link-email",
"linkText" : "override-link-text",
"linkHref" : "override-link-href",
"strong" : "override-strong",
"strikethrough" : "override-strikethrough"
function TokenTypeOverrideTest(name) { test.mode(name, modeOverrideClasses, Array.prototype.slice.call(arguments, 1)); }
var modeFormattingOverride = CodeMirror.getMode({tabsize: 4}, {
highlightFormatting: true,
"formatting" : "override-formatting"
function FormatTokenTypeOverrideTest(name) { test.mode(name, modeFormattingOverride, Array.prototype.slice.call(arguments, 1)); }
FT("formatting_emAsterisk",
"[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]");
FT("formatting_emUnderscore",
"[em&formatting&formatting-em _][em foo][em&formatting&formatting-em _]");
FT("formatting_strongAsterisk",
"[strong&formatting&formatting-strong **][strong foo][strong&formatting&formatting-strong **]");
FT("formatting_strongUnderscore",
"[strong&formatting&formatting-strong __][strong foo][strong&formatting&formatting-strong __]");
FT("formatting_codeBackticks",
"[comment&formatting&formatting-code `][comment foo][comment&formatting&formatting-code `]");
FT("formatting_doubleBackticks",
"[comment&formatting&formatting-code ``][comment foo ` bar][comment&formatting&formatting-code ``]");
FT("formatting_atxHeader",
"[header&header-1&formatting&formatting-header&formatting-header-1 # ][header&header-1 foo # bar ][header&header-1&formatting&formatting-header&formatting-header-1 #]");
FT("formatting_setextHeader",
"[header&header-1&formatting&formatting-header&formatting-header-1 =]");
FT("formatting_blockquote",
"[quote"e-1&formatting&formatting-quote&formatting-quote-1 > ][quote"e-1 foo]");
"[variable-2&formatting&formatting-list&formatting-list-ul - ][variable-2 foo]");
"[variable-2&formatting&formatting-list&formatting-list-ol 1. ][variable-2 foo]");
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url (][string&url http://example.com/][string&formatting&formatting-link-string&url )]");
FT("formatting_linkReference",
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url [][string&url bar][string&formatting&formatting-link-string&url ]]]",
"[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string&url http://example.com/]");
"[link&formatting&formatting-link <][link http://example.com/][link&formatting&formatting-link >]");
FT("formatting_linkEmail",
"[link&formatting&formatting-link <][link user@example.com][link&formatting&formatting-link >]");
"[formatting-escape \\*]");
"[formatting&formatting-image&image&image-marker !][formatting&formatting-image&image&image-alt-text&link [[][image&image-alt-text&link alt text][formatting&formatting-image&image&image-alt-text&link ]]][formatting&formatting-link-string&string&url (][url&string http://link.to/image.jpg][formatting&formatting-link-string&string&url )]");
// Don't style single trailing space
// Two or more trailing spaces should be styled with line break character
"foo[trailing-space-a ][trailing-space-new-line ]");
"foo[trailing-space-a ][trailing-space-b ][trailing-space-new-line ]");
"foo[trailing-space-a ][trailing-space-b ][trailing-space-a ][trailing-space-new-line ]");
// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
MT("codeBlocksUsing4Spaces",
// Code blocks using 4 spaces with internal indentation
MT("codeBlocksUsing4SpacesIndentation",
// Code blocks should end even after extra indented lines
MT("codeBlocksWithTrailingIndentedLine",
// Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
MT("codeBlocksUsing1Tab",
// No code blocks directly after paragraph
// http://spec.commonmark.org/0.19/#example-65
MT("noCodeBlocksAfterParagraph",
// Inline code using backticks
MT("inlineCodeUsingBackticks",
// Block code using single backtick (shouldn't work)
MT("blockCodeSingleBacktick",
// Instead of simply marking as CODE, it would be nice to have an
// incomplete flag for CODE, that is styled slightly different.
// Per documentation: "To include a literal backtick character within a
// code span, you can use multiple backticks as the opening and closing
"[comment ``foo ` bar``]");
// http://daringfireball.net/projects/markdown/dingus
// Multiple backticks within an inline code block
MT("consecutiveBackticks",
"[comment `foo```bar`]");
// Multiple backticks within an inline code block with a second code block
MT("consecutiveBackticks",
"[comment `foo```bar`] hello [comment `world`]");
// Unclosed with several different groups of backticks
"[comment ``foo ``` bar` hello]");
// Closed with several different groups of backticks
"[comment ``foo ``` bar` hello``] world");
// http://daringfireball.net/projects/markdown/syntax#header
"[header&header-1 # foo]");
"[header&header-2 ## foo]");
"[header&header-3 ### foo]");
"[header&header-4 #### foo]");
"[header&header-5 ##### foo]");
"[header&header-6 ###### foo]");
// http://spec.commonmark.org/0.19/#example-24
// http://spec.commonmark.org/0.19/#example-25
MT("noAtxH1WithoutSpace",
// CommonMark requires a space after # but most parsers don't
AtxNoSpaceTest("atxNoSpaceAllowed_H1NoSpace",
"[header&header-1 #foo]");
AtxNoSpaceTest("atxNoSpaceAllowed_H4NoSpace",
"[header&header-4 ####foo]");
AtxNoSpaceTest("atxNoSpaceAllowed_H1Space",
"[header&header-1 # foo]");
// Inline styles should be parsed inside headers
"[header&header-1 # foo ][header&header-1&em *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
"[header&header-1 ===]");
// Check if single underlining - works
"[header&header-2 ---]");
// http://spec.commonmark.org/0.19/#example-45
MT("setextH2AllowSpaces",
" [header&header-2 ---- ]");
// http://spec.commonmark.org/0.19/#example-44
MT("noSetextAfterIndentedCodeBlock",
// http://spec.commonmark.org/0.19/#example-51
// Single-line blockquote with trailing space
"[quote"e-1 > foo]");
// Single-line blockquote
// No blank line before blockquote
MT("blockquoteNoBlankLine",
"[quote"e-1 > bar]");
"[quote"e-1 >][quote"e-2 > foo]",
"[quote"e-1 >][quote"e-2 >][quote"e-3 > foo]");
// Single-line blockquote followed by normal paragraph
MT("blockquoteThenParagraph",
// Multi-line blockquote (lazy mode)
MT("multiBlockquoteLazy",
// Multi-line blockquote followed by normal paragraph (lazy mode)
MT("multiBlockquoteLazyThenParagraph",
// Multi-line blockquote (non-lazy mode)
// Multi-line blockquote followed by normal paragraph (non-lazy mode)
MT("multiBlockquoteThenParagraph",
// Header with leading space after continued blockquote (#3287, negative indentation)
MT("headerAfterContinuedBlockquote",
" [header&header-1 # hello]");
// Lists require a preceding blank line (per Dingus)
"[header&header-1 # foo]",
// Formatting in lists (*)
MT("listAsteriskFormatting",
"[variable-2 * ][variable-2&em *foo*][variable-2 bar]",
"[variable-2 * ][variable-2&strong **foo**][variable-2 bar]",
"[variable-2 * ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
"[variable-2 * ][variable-2&comment `foo`][variable-2 bar]");
// Formatting in lists (+)
"[variable-2 + ][variable-2&em *foo*][variable-2 bar]",
"[variable-2 + ][variable-2&strong **foo**][variable-2 bar]",
"[variable-2 + ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
"[variable-2 + ][variable-2&comment `foo`][variable-2 bar]");
// Formatting in lists (-)
"[variable-2 - ][variable-2&em *foo*][variable-2 bar]",
"[variable-2 - ][variable-2&strong **foo**][variable-2 bar]",
"[variable-2 - ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
"[variable-2 - ][variable-2&comment `foo`][variable-2 bar]");
// Formatting in lists (1.)
MT("listNumberFormatting",
"[variable-2 1. ][variable-2&em *foo*][variable-2 bar]",
"[variable-2 2. ][variable-2&strong **foo**][variable-2 bar]",
"[variable-2 3. ][variable-2&strong **][variable-2&em&strong *foo**][variable-2&em *][variable-2 bar]",
"[variable-2 4. ][variable-2&comment `foo`][variable-2 bar]");
// 4 spaces, extra blank lines (should still be list, per Dingus)
MT("listMultiParagraphExtra",
// 4 spaces, plus 1 space (should still be list, per Dingus)
MT("listMultiParagraphExtraSpace",
MT("listCommonMarkIndentationCode",
"[variable-2 * Code blocks also affect]",
" [variable-3 * The next level starts where the contents start.]",
" [variable-3 * Anything less than that will keep the item on the same level.]",
" [variable-3 * Each list item can indent the first level further and further.]",
" [variable-3 * For the most part, this makes sense while writing a list.]",
" [keyword * This means two items with same indentation can be different levels.]",
" [keyword * Each level has an indent requirement that can change between items.]",
" [keyword * A list item that meets this will be part of the next level.]",
" [variable-3 * Otherwise, it will be part of the level where it does meet this.]",
" [variable-2 * World]");
" [variable-2"e"e-1 > hello]");
// Code block followed by text