: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
" [variable-2 1. world]");
" [quote"e-1&variable-3 > hello]");
// Code with internal indentation
MT("listCodeIndentation",
// List nesting edge cases
// Following tests directly from official Markdown documentation
// http://daringfireball.net/projects/markdown/syntax#hr
"[hr ---------------------------------------]");
"[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)]")
//Images with highlight alt text
"[image&image-marker !][image&image-alt-text&link [[][image-alt-text&em&image&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
"[image&image-marker !][image&image-alt-text&link [[][image-alt-text&strong&image&link **alt text**][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
"[image&image-marker !][image&image-alt-text&link [[][image-alt-text&image&strong&link **][image&image-alt-text&em&strong&link *alt text**][image&image-alt-text&em&link *][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
// Inline link with title
"[link [[foo]]][string&url (http://example.com/ \"bar\")] hello");
// Inline link without title
"[link [[foo]]][string&url (http://example.com/)] bar");
// Inline link with image
"[link [[][link&image&image-marker !][link&image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)][link ]]][string&url (http://example.com/)] bar");
"[link [[][link&em *foo*][link ]]][string&url (http://example.com/)] bar");
// Inline link with Strong
"[link [[][link&strong **foo**][link ]]][string&url (http://example.com/)] bar");
// Inline link with EmStrong
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url (http://example.com/)] bar");
"[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/ \"bar\")] hello");
"[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/)] bar");
"[image&image-marker !][image&image-alt-text&link [[ ][image&image-alt-text&em&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)] 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).
"[link [[foo]]][string&url [[bar]]] hello");
// Reference-style links with Em
"[link [[][link&em *foo*][link ]]][string&url [[bar]]] hello");
// Reference-style links with Strong
MT("linkReferenceStrong",
"[link [[][link&strong **foo**][link ]]][string&url [[bar]]] hello");
// Reference-style links with EmStrong
MT("linkReferenceEmStrong",
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url [[bar]]] hello");
// Reference-style links with optional space separator (per documentation)
// "You can optionally use a space to separate the sets of brackets"
"[link [[foo]]] [string&url [[bar]]] hello");
// Should only allow a single space ("...use *a* space...")
MT("linkReferenceDoubleSpace",
"[[foo]] [[bar]] hello");
// Reference-style links with implicit link name
"[link [[foo]]][string&url [[]]] 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)
"[link [[foo]]:] [string&url http://example.com/]");
" [link [[foo]]:] [string&url http://example.com/]");
"[link [[foo bar]]:] [string&url http://example.com/ \"hello\"]");
"[link [[foo bar]]:] [string&url http://example.com/ \"hello\"] \"world\"");
MT("labelTitleDoubleQuotes",
"[link [[foo]]:] [string&url http://example.com/ \"bar\"]");
MT("labelTitleSingleQuotes",
"[link [[foo]]:] [string&url http://example.com/ 'bar']");
MT("labelTitleParentheses",
"[link [[foo]]:] [string&url http://example.com/ (bar)]");
"[link [[foo]]:] [string&url http://example.com/] bar");
MT("labelLinkAngleBrackets",
"[link [[foo]]:] [string&url <http://example.com/> \"bar\"]");
MT("labelTitleNextDoubleQuotes",
"[link [[foo]]:] [string&url http://example.com/]",
"[string \"bar\"] hello");
MT("labelTitleNextSingleQuotes",
"[link [[foo]]:] [string&url http://example.com/]",
MT("labelTitleNextParentheses",
"[link [[foo]]:] [string&url http://example.com/]",
MT("labelTitleNextMixed",
"[link [[foo]]:] [string&url http://example.com/]",
"[link [[foo \\]] ]]:] [string&url http://example.com/]");
"[link [[foo \\]]: bar]]:] [string&url http://example.com/]");
"[[foo\\]]: http://example.com/");
"[link <http://example.com/>] foo");
"[link <http://example.com/>] foo [link <http://example.com/>]");
"[link <user@example.com>] foo");
"[link <user@example.com>] foo [link <user@example.com>]");
// Per documentation: "...surround an * or _ with spaces, it’ll be
// treated as a literal asterisk or underscore."
"foo [em _bar _ hello_] world");
MT("emEscapedBySpaceOut",
"foo _ bar[em _hello_]world");
"_ 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",
MT("emIncompleteUnderscore",
"[em *foo][em&strong **bar*][strong hello**] world");
"[em _foo][em&strong __bar_][strong hello__] world");
// "...same character must be used to open and close an emphasis span.""
"[em _foo][em&strong **bar*hello__ world]");
"[em *foo][em&strong __bar_hello** world]");
MT("linkWithNestedParens",
"[link [[foo]]][string&url (bar(baz))]")
// These characters should be escaped:
MT("doubleEscapeBacktick",
"foo \\\\[comment `bar\\\\`]");
MT("doubleEscapeAsterisk",
"foo \\\\[em *bar\\\\*]");
MT("doubleEscapeUnderscore",
"foo \\\\[em _bar\\\\_]");
TokenTypeOverrideTest("overrideHeader1",
"[override-header&override-header-1 # Foo]");
TokenTypeOverrideTest("overrideHeader2",
"[override-header&override-header-2 ## Foo]");
TokenTypeOverrideTest("overrideHeader3",
"[override-header&override-header-3 ### Foo]");
TokenTypeOverrideTest("overrideHeader4",
"[override-header&override-header-4 #### Foo]");
TokenTypeOverrideTest("overrideHeader5",
"[override-header&override-header-5 ##### Foo]");
TokenTypeOverrideTest("overrideHeader6",
"[override-header&override-header-6 ###### Foo]");
TokenTypeOverrideTest("overrideCode",
"[override-code `foo`]");
TokenTypeOverrideTest("overrideCodeBlock",
TokenTypeOverrideTest("overrideQuote",
"[override-quote&override-quote-1 > foo]",
"[override-quote&override-quote-1 > bar]");
TokenTypeOverrideTest("overrideQuoteNested",
"[override-quote&override-quote-1 > foo]",
"[override-quote&override-quote-1 >][override-quote&override-quote-2 > bar]",
"[override-quote&override-quote-1 >][override-quote&override-quote-2 >][override-quote&override-quote-3 > baz]");
TokenTypeOverrideTest("overrideLists",
"[override-list1 - foo]",
" [override-list2 + bar]",
" [override-list3 * baz]",
" [override-list1 1. qux]",
" [override-list2 - quux]");
TokenTypeOverrideTest("overrideHr",
TokenTypeOverrideTest("overrideImage",
"[override-image&override-image-marker !][override-image&override-image-alt-text&link [[alt text]]][override-link-href&url (http://link.to/image.jpg)]");
TokenTypeOverrideTest("overrideLinkText",
"[override-link-text [[foo]]][override-link-href&url (http://example.com)]");
TokenTypeOverrideTest("overrideLinkEmailAndInline",
"[override-link-email <][override-link-inline foo@example.com>]");
TokenTypeOverrideTest("overrideEm",
TokenTypeOverrideTest("overrideStrong",
"[override-strong **foo**]");
TokenTypeOverrideTest("overrideStrikethrough",
"[override-strikethrough ~~foo~~]");
FormatTokenTypeOverrideTest("overrideFormatting",
"[override-formatting-escape \\*]");
// Tests to make sure GFM-specific things aren't getting through
"[variable-2 * [ ]] bar]");
FencedTest("fencedCodeBlocks",
FencedTest("fencedCodeBlocksMultipleChars",
FencedTest("fencedCodeBlocksTildes",
FencedTest("fencedCodeBlocksTildesMultipleChars",
FencedTest("fencedCodeBlocksMultipleChars",
FencedTest("fencedCodeBlocksMixed",
// Tests that require XML mode
"[tag&bracket <][tag div][tag&bracket >]",
"[tag&bracket <][tag http://github.com][tag&bracket />]",
"[tag&bracket </][tag div][tag&bracket >]",
"[link <http://github.com/>]");
MT("xmlModeWithMarkdownInside",
"[tag&bracket <][tag div] [attribute markdown]=[string 1][tag&bracket >]",
"[link <http://github.com/>]",
"[link <http://github.com/>]",
"[tag&bracket <][tag div][tag&bracket >]",
"[tag&bracket </][tag div][tag&bracket >]");