# This document specifies valid MFNF wiki syntax. # It serves as documentation and is used to generate tests for the parser. # The whole document is structured as an array of tests cases: # # - case: descriptive name of a test here. # in: | # Here goes the input ''wikitext'' to parse. # out: # type: document # offset: 0 # content: # - type: paragraph # ... # # If the position of an element is not important for the test, # you may ommit its position info: # # ... # type: paragraph # position: {} # content: [] # An empty document should parse fine. - case: empty document input: "" out: type: document position: start: offset: 0 line: 1 col: 1 end: offset: 0 line: 1 col: 1 content: [] # A single paragraph without newlines should be parsed as a document # with a single paragraph. - case: single unicode paragraph input: this is a äüöß == test. "" ʕ•ᴥ•ʔ out: type: document content: - type: paragraph content: - type: text text: this is a äüöß == test. "" ʕ•ᴥ•ʔ # A single paragraph with some special characters. - case: special chars in inline context input: hey!!! this is a test! <3 |x| out: type: document content: - type: paragraph content: - type: text text: "hey!!! this is a test! <3 |x|" # A multiline paragraph. - case: multiline paragraph input: | This should be a single paragraph. This is the next one. out: type: document content: - type: paragraph content: - type: text text: This should be a single paragraph. - type: paragraph content: - type: text text: This is the next one. # some simple headings. - case: some simple headings input: | == Heading 1 == === Heading 2 === Heading 3 ==== Heading 4 = Heading 5 = = Heading 7 == Heading 8 == Heading 9 out: type: document content: - type: heading depth: 2 caption: - type: text text: "Heading 1 " content: - type: heading depth: 3 caption: - type: text text: Heading 2 content: [] - type: heading depth: 3 caption: - type: text text: Heading 3 content: - type: heading depth: 4 caption: - type: text text: Heading 4 content: [] - type: heading depth: 1 caption: - type: text text: "Heading 5 " content: [] - type: heading depth: 1 caption: - type: text text: Heading 7 content: - type: heading depth: 2 caption: - type: text text: Heading 8 content: [] - type: heading depth: 2 caption: - type: text text: Heading 9 content: [] # heading with an ancor - case: heading with ancor input: | == Heading {{Anker|foo}} == out: type: document content: - type: heading depth: 2 caption: - type: text text: "Heading " - type: template name: - type: text text: Anker content: - type: templateargument name: "1" value: - type: text text: foo - type: text text: " " content: [] # heading with equal sign - case: heading with equal sign input: | == Heading == Structure == out: type: document content: - type: heading depth: 2 caption: - type: text text: "Heading == Structure " content: [] # A paragraph with bold words contains a plain formatted element # wrapped by ''italic'' formatting. - case: single italic text input: "''this is italic''" out: type: document content: - type: paragraph content: - type: formatted markup: italic content: - type: text text: this is italic # A paragraph with bold words contains a plain formatted element # wrapped by '''bold''' formatting. - case: single bold text input: "'''this is bold'''" out: type: document content: - type: paragraph content: - type: formatted markup: bold content: - type: text text: this is bold # Multiline bold markup - case: multiline bold markup input: | ''' bla ''italic'' bla2 ''' out: type: document content: - type: paragraph content: - type: formatted markup: bold content: - type: paragraph content: - type: text text: "bla " - type: formatted markup: italic content: - type: text text: italic - type: text text: " bla2" # A paragraph with nested markup. - case: nested markup italic input: "prelude ''italic paragraph with '''''nested'' bold and italic''''' and normal text." out: type: document position: {} content: - type: paragraph content: - type: text text: "prelude " - type: formatted markup: italic content: - type: text text: "italic paragraph with " - type: formatted markup: bold content: - type: formatted position: {} markup: italic content: - type: text text: nested - type: text position: {} text: " bold and italic" - type: text text: " and normal text." # An apostrophe after markup - case: markup and apostrophe input: "The '''''dog''''''s bone" out: type: document position: {} content: - type: paragraph content: - type: text text: "The " - type: formatted markup: bold content: - type: formatted markup: italic content: - type: text position: {} text: "dog" - type: text text: "\'s bone" # A simple inline math tag. - case: simple inline math input: "x^2" out: type: document content: - type: paragraph content: - type: formatted markup: math content: - type: text text: x^2 # Math tag with special characters - case: special inline math input: "$\\{{bla}} x'=c" out: type: document content: - type: paragraph content: - type: formatted markup: math content: - type: text text: "$\\{{bla}} x'=c" # An empty math tag. - case: empty math input: "" out: type: document content: - type: paragraph content: - type: formatted markup: math content: [] # Simple hyperlink without a caption. - case: hyperlink without caption input: "[https://www.example.com/]" out: type: document content: - type: paragraph content: - type: externalreference target: https://www.example.com/ caption: [] # Normal text with angle brackets - case: text with brackets input: "see reference [1]!" out: type: document content: - type: paragraph content: - type: text text: "see reference [1]!" # Simple hyperlink with a caption. - case: hyperlink with caption input: "[https://www.example.com/ Example dot com]" out: type: document content: - type: paragraph content: - type: externalreference target: https://www.example.com/ caption: - type: text text: "Example dot com" # Simple hyperlink without a caption. - case: hyperlink with formatted caption input: "[https://www.example.com/ Example '''dot com''']" out: type: document content: - type: paragraph content: - type: externalreference target: https://www.example.com/ caption: - type: text text: "Example " - type: formatted markup: bold content: - type: text text: dot com # An arbitrary html tag - case: nested html tag input: | Fréttinga is a small municipality in MungoLand.< / translate> out: type: document content: - type: paragraph content: - type: htmltag name: translate attributes: - key: language value: test - key: attr2 value: bla - key: attröbüte value: "this is a \"test\"" content: - type: htmltag name: translate attributes: [] content: - type: text text: "Fréttinga is a small municipality in MungoLand." # An empty nowiki tag - case: empty nowiki input: "" out: type: document content: - type: paragraph content: - type: formatted markup: nowiki content: [] # A self-closing tag - case: self closing tag input: "
" out: type: document content: - type: paragraph content: - type: htmltag name: section attributes: [] content: [] - type: htmltag name: section attributes: [] content: [] # A HTML comment - case: html comment input: "bla " out: type: document content: - type: paragraph content: - type: text text: "bla " - type: comment text: " comment ³½}³¹ðđ æđ||đð@³¼¶²{{}} content " # The nowiki tag should ignore everything. - case: nowiki input: | abc {{bla}} ''' [ out: type: document content: - type: paragraph content: - type: formatted markup: nowiki content: - type: text text: "abc {{bla}} ''' \n [" # Strikethrough text. - case: strikethrough input: | strikethrough text strikethrough text out: type: document content: - type: paragraph content: - type: formatted markup: strikethrough content: - type: text text: strikethrough text - type: text text: " " - type: formatted markup: strikethrough content: - type: text text: strikethrough text # Definition markup - case: definition markup input: Riemannsumme out: type: document content: - type: paragraph content: - type: htmltag name: dfn attributes: - key: title value: Riemannsumme content: - type: text text: Riemannsumme # Underline text - case: underline markup input: Inserted out: type: document content: - type: paragraph content: - type: formatted markup: underline content: - type: text text: Inserted # Fixed-width text - case: fixed width markup input: Fixed width text out: type: document content: - type: paragraph content: - type: formatted markup: code content: - type: text text: Fixed width text # Blockquote - case: blockquote markup input:
Blockquote
out: type: document content: - type: paragraph content: - type: formatted markup: blockquote content: - type: text text: Blockquote # Pre-formatted Text - case: pre formatted text input: |
Text is '''preformatted''' and 
      ''markups'' '''''cannot''''' be done
out: type: document content: - type: paragraph content: - type: formatted markup: preformatted content: - type: text text: "Text is '''preformatted''' and \n''markups'' '''''cannot''''' be done" # A simple list of one item. - case: list one item input: "* item" out: type: document content: - type: list content: - type: listitem kind: unordered depth: 1 content: - type: text text: item # A ordered list and a unordered list of one item - case: two simple lists input: | * item 1 ## item 2 out: type: document content: - type: list content: - type: listitem kind: unordered depth: 1 content: - type: text text: item 1 - type: list content: - type: listitem kind: ordered depth: 2 content: - type: text text: item 2 # Star, Fence, Semicolon should be considered as text in an inline context. - case: list symbols inline context input: | * item 1 #;* bla abc # def * out: type: document content: - type: list content: - type: listitem kind: unordered depth: 1 content: - type: text text: "item 1 #;* bla" - type: paragraph content: - type: text text: "abc # def *" # A list with multiple different item types and a paragraph - case: list diverse items input: | : item 1 ; item 11 *** item 2 ## item 3 paragraph out: type: document content: - type: list content: - type: listitem kind: definition depth: 1 content: - type: text text: item 1 - type: listitem kind: definitionterm depth: 1 content: - type: text text: item 11 - type: list content: - type: listitem depth: 2 kind: unordered content: - type: list content: - type: listitem depth: 3 kind: unordered content: - type: text text: item 2 - type: listitem depth: 2 kind: ordered content: - type: text text: item 3 - type: paragraph content: - type: text text: paragraph # Even inside of templates, lists must start on a new line - case: list in template input: | {{test| * item 1 * item 2}} out: type: document content: - type: template name: - type: text text: test content: - type: templateargument name: "1" value: - type: list content: - type: listitem kind: unordered depth: 1 content: - type: text text: item 1 - type: listitem kind: unordered depth: 1 content: - type: text text: item 2 # Lists cannot be started mid-line. - case: list mod line input: | {{test| this * is * a test}} [[this ** '' * as'' * as well]] out: type: document content: - type: template name: - type: text text: test content: - type: templateargument name: "1" value: - type: text text: "this * is " - type: htmltag name: a attributes: [] content: - type: text text: " * a " - type: text text: " test" - type: internalreference target: - type: text text: "this ** " - type: formatted markup: italic content: - type: text text: " * as" - type: formatted markup: underline content: - type: text text: " * as" - type: text text: " well" options: [] caption: [] # A very simple template - case: simple template input: "{{name}}" out: type: document content: - type: template name: - type: text text: name content: [] # A sequence of block templates - case: block template sequence input: | {{name}} {{name}} out: type: document content: - type: template name: - type: text text: name content: [] - type: template name: - type: text text: name content: [] # A sequence of inline templates - case: inline template sequence input: | bla {{name}} and a {{name}} out: type: document content: - type: paragraph content: - type: text text: "bla " - type: template name: - type: text text: name content: [] - type: text text: " and a " - type: template name: - type: text text: name content: [] # A template with list-like name - case: template listlike name input: | {{:name }} out: type: document content: - type: template name: - type: text text: ":name" content: [] # A sequence of unnamed template arguments - case: anonymous attribute sequence input: | {{templatename |attribute2 |atträöüß3 |attribute4 }} out: type: document content: - type: template name: - type: text text: templatename content: - type: templateargument name: "1" value: - type: paragraph content: - type: text text: attribute2 - type: templateargument name: "2" value: - type: paragraph content: - type: text text: atträöüß3 - type: templateargument name: "3" value: - type: paragraph content: - type: text text: attribute4 # A named argument - case: named argument input: "{{name|caption=üäö test}}" out: type: document content: - type: template name: - type: text text: name content: - type: templateargument name: caption value: - type: text text: üäö test # Multiple named template arguments - case: multiple named template arguments input: "{{templatename|äöütem=2|item3=3|item4=4}}" out: type: document content: - type: template name: - type: text text: templatename content: - type: templateargument name: äöütem value: - type: text text: "2" - type: templateargument name: item3 value: - type: text text: "3" - type: templateargument name: item4 value: - type: text text: "4" # Mixed named and unnamed arguments - case: mixed template arguments input: "{{template1|item2=2|item3=3|item4}}" out: type: document content: - type: template name: - type: text text: template1 content: - type: templateargument name: item2 value: - type: text text: "2" - type: templateargument name: item3 value: - type: text text: "3" - type: templateargument name: "1" value: - type: text text: "item4" # Nested templates - case: nested templates input: "{{Thankyou in {{preferred language}}|signature=Me}}" out: type: document content: - type: template name: - type: text text: "Thankyou in " - type: template name: - type: text text: "preferred language" content: [] content: - type: templateargument name: signature value: - type: text text: Me # A simple internal reference - case: simple internal ref input: "[[File:Abc]]" out: type: document content: - type: internalreference target: - type: text text: File:Abc options: [] caption: [] # An empty internal reference - case: empty internal ref input: "[[]]" out: type: document content: - type: internalreference target: [] options: [] caption: [] # A simple internal reference with caption - case: internal ref with caption input: "[[File:Abc|this is a caption]]" out: type: document content: - type: internalreference target: - type: text text: File:Abc options: [] caption: - type: text text: this is a caption # A simple internal reference with options - case: internal ref with options input: "[[File:Abc|opt1=value1|opt2=123|this is a caption with '''bold and |special|''' markup]]" out: type: document content: - type: internalreference target: - type: text text: "File:Abc" options: - - type: text text: "opt1=value1" - - type: text text: "opt2=123" caption: - type: text text: "this is a caption with " - type: formatted markup: bold content: - type: text text: "bold and |special|" - type: text text: " markup" # Simple table with one cell - case: single cell table input: | {| | attributevalue = "test" | test |} out: type: document content: - type: table attributes: [] caption_attributes: [] caption: [] rows: - type: tablerow attributes: [] cells: - type: tablecell attributes: - key: attributevalue value: test header: false content: - type: paragraph content: - type: text text: test # Simple table with caption - case: table caption input: | {| |+ caption_attribute=value | this is a ''caption'' | attributevalue = "test" | test |} out: type: document content: - type: table attributes: [] caption_attributes: - key: caption_attribute value: value caption: - type: paragraph content: - type: text text: "this is a " - type: formatted markup: italic content: - type: text text: "caption" rows: - type: tablerow attributes: [] cells: - type: tablecell attributes: - key: attributevalue value: test header: false content: - type: paragraph content: - type: text text: test # simple heading in template (mediawiki can't do this) - case: table in template input: | {{test|bla= {| |+ caption_attribute=value | this is a ''caption'' | attributevalue = "test" | test |} }} out: type: document content: - type: template name: - type: text text: test content: - type: templateargument name: bla value: - type: table attributes: [] caption_attributes: - key: caption_attribute value: value caption: - type: paragraph content: - type: text text: "this is a " - type: formatted markup: italic content: - type: text text: "caption" rows: - type: tablerow attributes: [] cells: - type: tablecell attributes: - key: attributevalue value: test header: false content: - type: paragraph content: - type: text text: test # simple heading in template (with hack used in real mediawiki) - case: table in template mediawiki hack input: | {{test|bla= {{(!}} {{!+}} caption_attribute=value {{!}} this is a ''caption'' {{!}} attributevalue = "test" {{!}} test {{!)}} }} out: type: document content: - type: template name: - type: text text: test content: - type: templateargument name: bla value: - type: table attributes: [] caption_attributes: - key: caption_attribute value: value caption: - type: paragraph content: - type: text text: "this is a " - type: formatted markup: italic content: - type: text text: "caption" rows: - type: tablerow attributes: [] cells: - type: tablecell attributes: - key: attributevalue value: test header: false content: - type: paragraph content: - type: text text: test # Table with multiple rows - case: multi row table input: | {| class="wikitable" |+ caption |- | attributevalue = "test" | test |- | test ''2'' |-style="font-style: italic; color: green;" | test3 | attr4=val | test4 |} out: type: document content: - type: table attributes: - key: class value: wikitable caption_attributes: [] caption: - type: paragraph content: - type: text text: caption rows: - type: tablerow attributes: [] cells: - type: tablecell attributes: - key: attributevalue value: test header: false content: - type: paragraph content: - type: text text: test - type: tablerow attributes: [] cells: - type: tablecell attributes: [] header: false content: - type: paragraph content: - type: text text: "test " - type: formatted markup: italic content: - type: text text: "2" - type: tablerow attributes: - key: style value: "font-style: italic; color: green;" cells: - type: tablecell attributes: [] header: false content: - type: paragraph content: - type: text text: "test3" - type: tablecell attributes: - key: attr4 value: val header: false content: - type: paragraph content: - type: text text: "test4" # Table with multiple cells on one line - case: table inline cells input: | {| | attributevalue = "test" | test || cell 2 || || attribute=3 | cell 3 |} out: type: document content: - type: table attributes: [] caption_attributes: [] caption: [] rows: - type: tablerow attributes: [] cells: - type: tablecell attributes: - key: attributevalue value: test header: false content: - type: text text: "test " - type: tablecell attributes: [] header: false content: - type: text text: "cell 2 " - type: tablecell attributes: [] header: false content: [] - type: tablecell attributes: - key: attribute value: "3" header: false content: - type: paragraph content: - type: text text: cell 3 # Table with header cells - case: table header cells input: | {| ! Orange !! attribute="test" | Apple |- | Bread || Pie !! ''hey!!'' ! footer |} out: type: document content: - type: table attributes: [] caption_attributes: [] caption: [] rows: - type: tablerow attributes: [] cells: - type: tablecell header: true attributes: [] content: - type: text text: "Orange " - type: tablecell header: true attributes: - key: attribute value: test content: - type: paragraph content: - type: text text: Apple - type: tablerow attributes: [] cells: - type: tablecell header: false attributes: [] content: - type: text text: "Bread " - type: tablecell header: false attributes: [] content: - type: text text: "Pie " - type: tablecell header: true attributes: [] content: - type: paragraph content: - type: formatted markup: italic content: - type: text text: "hey!!" - type: tablecell header: true attributes: [] content: - type: paragraph content: - type: text text: footer # a simple gallery tag - case: simple gallery input: | File:Abc out: type: document content: - type: gallery attributes: [] content: - type: internalreference target: - type: text text: File:Abc options: [] caption: [] # an empty gallery - case: empty gallery input: | out: type: document content: - type: gallery attributes: [] content: [] # empty gallery with whitespace - case: empty whitespace gallery input: " \n \n\n\n \n\t\n " out: type: document content: - type: gallery attributes: [] content: [] # simple gallery with whitespace - case: simple whitespace gallery input: " \n \nFile:ABC \n\n \n\t\n " out: type: document content: - type: gallery attributes: [] content: - type: internalreference target: - type: text text: "File:ABC " caption: [] options: [] # a gallery with figure captions - case: caption gallery input: | File:Abc|this is a figure [[caption]] File:This is a new file out: type: document content: - type: gallery attributes: [] content: - type: internalreference target: - type: text text: File:Abc options: [] caption: - type: text text: "this is a figure " - type: internalreference target: - type: text text: caption caption: [] options: [] - type: internalreference target: - type: text text: File:This is a new file caption: [] options: [] # template with a heading as content - case: template with heading content input: | {{noprint| == caption content }} out: type: document content: - type: template name: - type: text text: noprint content: - type: templateargument name: "1" value: - type: heading depth: 2 caption: - type: text text: caption content: - type: paragraph content: - type: text text: content