# encoding: UTF-8 require 'trac-wiki' require 'pp' class Bacon::Context def tc(html, wiki, options = {}) options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' }, } options[:template_handler] = self.method(:template_handler) parser = TracWiki.parser(options) html.should.equal parser.to_html(wiki) end def env(wiki, var, val,options = {}) options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' }, } options[:template_handler] = self.method(:template_handler) parser = TracWiki.parser(options) parser.to_html(wiki) parser.env.at(var).should.equal val end def used_templates(wiki, used_templates, options={}) options[:macro_commands] = { '!print' => proc { |env| env.arg(0) + '! ' }, } options[:template_handler] = self.method(:template_handler) parser = TracWiki.parser(options) parser.to_html(wiki) parser.used_templates.sort.map do |key,value| "#{key}:#{value}" end.join(',').should.equal used_templates end def template_handler(tname, env, argv) case tname when 'testmacpos2' "{{testmacpos}}" when 'testmacpos' "{{!macpos}}" when 'ifeqtest' "{{!ifeq {{$1}}|{{$2}}|TRUE|FALSE}}" when 'vartest2' "{{vartest {{$1}}|{{$dva}}|p={{$p}}|{{$3 |tridef}}}}" when 'ytest' "{{$y.ahoj}},{{$y.bhoj.1}}" when 'ytest2' "{{!set i|ahoj}}{{$y.$i}},{{$y.bhoj.1}}" when 'varnula' "nula:{{$0}},a:{{$a}}" when 'varnulanula' "nulanula:{{$00}},a:{{$a}}" when 'vartest' "jedna:{{$1}},dve:{{$2}},p:{{$p}},arg:{{$00}}" when 'testundef' "{{westundef}}" when 'test' "{{west}}" when 'west' "WEST" when 'deep' "{{deep}}" when 'nl' "line one\nline two\n" when 'nl2' "* line one\n* line two\n" when 'maclentest' "maclen:{{$maclen}}" when 'wide' "0123456789{{wide}}" * 10 when 'testoff' "off:{{$offset}}" when '/slash' "slash/slash" when 'unkmacro' #"UNKNOWN-MACRO:!{{!.{{$0}}}}." "UNKNOWN-MACRO:!{{!.{{$1}}}}." else nil #"UNK_TEMPL(#{tname})" end end def h(hash, wiki, opts = {}) parser = TracWiki.parser(opts) parser.to_html(wiki) #pp parser.headers parser.headings.should == hash end end describe TracWiki::Parser do it 'should not parse linkd' do tc "

[[ahoj]]

\n", "[ahoj]", :no_link => true tc "

[[ahoj]]

\n", "[[ahoj]]", :no_link => true tc "

[[ahoj|bhoj]]

\n", "[[ahoj|bhoj]]", :no_link => true tc "\n", "* [[ahoj|bhoj]]", :no_link => true end it 'should parse bold' do # Bold can be used inside paragraphs tc "

This is bold

\n", "This **is** bold" tc "

This is bold and boldish

\n", "This **is** bold and **bold**ish" # Bold can be used inside list items tc "\n", "* This is **bold**" # Bold can be used inside table cells tc("\n\n
This is bold
\n", "||This is **bold**||") # Links can appear inside bold text: tc("

A bold link: http://example.org/ nice!

\n", "A bold link: **http://example.org/ nice! **") # Bold will end at the end of paragraph tc "

This is bold

\n", "This **is bold" # Bold will end at the end of list items tc("\n", "* Item **bold\n* Item normal") # Bold will end at the end of table cells tc("\n\n\n
Item boldAnother bold
\n", "||Item **bold||Another **bold||") # Bold should not cross paragraphs tc("

This is

\n

bold maybe

\n", "This **is\n\nbold** maybe") # Bold should be able to cross lines tc "

This is bold

\n", "This **is\nbold**" end it 'should be toc' do tc "

{{toc}}

\n", "{{toc}}" tc "

ahoj

{{toc}}

\n

ahoj

", "==ahoj==\n{{toc}}\n\n==ahoj==\n" #tc "{{toc}}", "{{toc}}" #tc "

ahoj

{{toc}}

ahoj

", "==ahoj==\r\n{{toc}}\r\n\r\n==ahoj==\r\n" end it 'should parse bolditalic' do tc "

This is bolditallic.

\n", "This is '''''bolditallic'''''." tc "

This is bolditallic .

\n", "This is ''' ''bolditallic'' '''." tc "

This is bolditallic .

\n", "This is '' '''bolditallic''' ''." tc "

This is bold.

\n", "This is '''bold'''." #fuj tc '

This is bolditallic.

\n', "This is **''bolditallic**''." end it 'should parse monospace' do tc "

This is monospace.

\n", "This is {{{monospace}}}." tc "

This is not {{{monospace}}}.

\n", "This is not !{{{monospace}}}." tc "

This is mon**o**space.

\n", "This is {{{mon**o**space}}}." tc "

This is mon<o>space.

\n", "This is {{{monspace}}}." tc "

This is mon''o''space.

\n", "This is {{{mon''o''space}}}." tc "

This is mon''o''space.

\n", "This is `mon''o''space`." tc "

This is mon{{o}}space.

\n", "This is {{{mon{{o}}space}}}." tc "

This is mon``o''space.

\n", "This is {{{mon``o''space}}}." tc "

This is mon{{o}}space.

\n", "This is `mon{{o}}space`." end it 'should parse italic' do # Italic can be used inside paragraphs tc("

This is italic

\n", "This ''is'' italic") tc("

This is italic and italicish

\n", "This ''is'' italic and ''italic''ish") # Italic can be used inside list items tc "\n", "* This is ''italic''" # Italic can be used inside table cells tc("\n\n
This is italic
\n", "||This is ''italic''||") # Links can appear inside italic text: tc("

A italic link: http://example.org/ nice!

\n", "A italic link: ''http://example.org/ nice! ''") # Italic will end at the end of paragraph tc "

This is italic

\n", "This ''is italic" # Italic will end at the end of list items tc("\n", "* Item ''italic\n* Item normal") # Italic will end at the end of table cells tc("\n\n\n
Item italicAnother italic
\n", "||Item ''italic||Another ''italic") # Italic should not cross paragraphs tc("

This is

\n

italic maybe

\n", "This ''is\n\nitalic'' maybe") # Italic should be able to cross lines tc "

This is italic

\n", "This ''is\nitalic''" end it 'should parse bold italics' do # By example tc "

bold italics

\n", "**''bold italics''**" # By example tc "

bold italics

\n", "''**bold italics**''" # By example tc "

This is also good.

\n", "''This is **also** good.''" end it 'should parse math' do tc "

the

\n", '$the$', math: true tc "

test the west

\n", 'test $the$ west', math: true tc "

test e^{i\\pi} test

\n", 'test $e^{i\pi}$ test', math: true tc "

test $ e{i\\pi} test

\n", 'test $ e^{i\pi} test', math: true tc "

$the$

\n", '$the$', math: false tc "

ahoj

\n
e^{i\\pi}
\n

nazdar

\n", "ahoj\n$$e^{i\\pi}$$\nnazdar", math: true tc "

ahoj $$e{i\\pi}$$ nazdar

\n", "ahoj\n$$e^{i\\pi}$$\nnazdar", math: false tc "
\\\\
\n", "$$\\\\$$", math: true tc "
\n^test\n
\n", "$$\n^test\n$$", math: true tc "

$abc$

\n", "!$a^b^c$", math: true tc "

$abc$

\n", "!$a**b**c$", math: true tc "

!$a$

\n", "!!!$a$", math: true end it 'should parse headings' do # Only three differed sized levels of heading are required. tc "

Heading 1

", "= Heading 1 =" tc "

Heading 2

", "== Heading 2 ==" tc "

Heading 3

", "=== Heading 3 ===" #tc "

Heading 3\u00a0B

", "=== Heading 3~B ===" tc "

Heading 3 B

", "=== Heading 3~B ===" tc "

Heading 3

", "=== Heading 3 === #HE3" tc "

Heading 3

", "=== Heading 3 === #Heading-3" tc "

Heading 3

", "=== Heading 3 === #Heading/3" tc "

Heading 3

", "=== Heading 3 === #Heading/3 " tc "

Heading 3

Heading 3

", "=== Heading 3 === #Heading/3\n=== Heading 3 === #Heading/3\n " tc "

Heading 3

", "=== Heading 3 === #Heading<3>" tc "

Heading 3

", "=== Heading 3 === #Heading'\"3\"'" # WARNING: Optional feature, not specified in tc "

Heading 4

", "==== Heading 4 ====" tc "
Heading 5
", "===== Heading 5 =====" tc "
Heading 6
", "====== Heading 6 ======" # Closing (right-side) equal signs are optional tc "

Heading 1

", "=Heading 1" tc "

Heading 2

", "== Heading 2" tc "

Heading 3

", " === Heading 3" # Closing (right-side) equal signs don't need to be balanced and don't impact the kind of heading generated tc "

Heading 1

", "=Heading 1 ===" tc "

Heading 2

", "== Heading 2 =" tc "

Heading 3

", " === Heading 3 ===========" # Whitespace is allowed before the left-side equal signs. tc "

Heading 1

", " \t= Heading 1 =" tc "

Heading 2

", " \t== Heading 2 ==" # Only white-space characters are permitted after the closing equal signs. tc "

Heading 1

", " = Heading 1 = " tc "

Heading 2

", " == Heading 2 == \t " # WARNING: !! XXX doesn't specify if text after closing equal signs # !!becomes part of the heading or invalidates the entire heading. # tc "

== Heading 2 == foo

\n", " == Heading 2 == foo" tc "

Heading 2 == foo

", " == Heading 2 == foo" # Line must start with equal sign tc "

foo = Heading 1 =

\n", "foo = Heading 1 =" end it 'should parse links' do # Links tc "

link

\n", "[[link]]" tc "

Flink

\n", "[[link|Flink]]" # FIXME: http://trac.edgewall.org/wiki/TracLinks: this is wrong #tc "

Flink

\n", "[link Flink]" tc "

link

\n", "[[link]]", base: 'BASE' tc "

link

\n", "[[link]]", base: 'BASE/' tc "

link#link

\n", "[[link#link]]" tc "

#link

\n", "[[#link]]" tc "

link

\n", "[[link]]", base: 'BASE', root: 'ROOT', no_escape: true tc "

/link

\n", "[[/link]]", base: 'BASE', root: 'ROOT', no_escape: true tc "

/link

\n", "[[/link]]", base: 'BASE', no_escape: true tc "

bla

\n", "[[link | bla ]]", base: 'BASE', root: 'ROOT', no_escape: true tc "

bla

\n", "[[/link | bla ]]", base: 'BASE', root: 'ROOT', no_escape: true tc "

bla

\n", "[[/link | bla]]", base: 'BASE', no_escape: true # Links can appear in paragraphs (i.e. inline item) tc "

Hello, world

\n", "Hello, [[world]]" # Named links tc "

Go to my page

\n", "[[MyBigPage|Go to my page]]" # URLs tc "

http://www.example.org/

\n", "[[http://www.example.org/]]" tc "

http://www.example.org/#anch

\n", "[[http://www.example.org/#anch]]" # Single punctuation characters at the end of URLs # should not be considered a part of the URL. [',','.','?','!',':',';','\'','"'].each do |punct| esc_punct = TracWiki::Parser.escapeHTML(punct) tc "

http://www.example.org/#{esc_punct}

\n", "http://www.example.org/#{punct}" end # Nameds URLs (by example) tc("

Visit the Example website

\n", "[[http://www.example.org/|Visit the Example website]]") # WRNING: Parsing markup within a link is optional tc "

Weird Stuff

\n", "[[Weird Stuff|**Weird** ''Stuff'']]" #tc("

\n", "[[http://example.org/|{{image.jpg}}]]") # Inside bold tc "

link

\n", "**[[link]]**" # Whitespace inside [[ ]] should be ignored tc("

link

\n", "[[ link ]]") tc("

link me

\n", "[[ link me ]]") tc("

dot.com

\n", "[[ http://dot.com/ \t| \t dot.com ]]") tc("

dot.com

\n", "[[ http://dot.com/ | dot.com ]]") end it 'should parse freestanding urls' do # Free-standing URL's should be turned into links tc "

http://www.example.org/

\n", "http://www.example.org/" # URL ending in . tc "

Text http://example.org. other text

\n", "Text http://example.org. other text" # URL ending in ), tc "

Text (http://example.org), other text

\n", "Text (http://example.org), other text" # URL ending in ). tc "

Text (http://example.org). other text

\n", "Text (http://example.org). other text" # URL ending in ). tc "

Text (http://example.org).

\n", "Text (http://example.org)." # URL ending in ) tc "

Text (http://example.org)

\n", "Text (http://example.org)" end it 'should parse paragraphs' do # One or more blank lines end paragraphs. tc "

This is my text.

\n

This is more text.

\n", "This is\nmy text.\n\nThis is\nmore text." tc "

This is my text.

\n

This is more text.

\n", "This is \nmy text.\n\nThis is\nmore text." tc "

This is my text.

\n

This is more text.

\n", "This is\nmy text.\n\n\nThis is\nmore text." tc "

This is my text.

\n

This is more text.

\n", "This is\nmy text.\n\n\n\nThis is\nmore text." # A list end paragraphs too. tc "

Hello

\n\n", "Hello\n* Item\n" # A table end paragraphs too. tc "

Hello

\n\n\n
Cell
\n", "Hello\n||Cell||" # A nowiki end paragraphs too. tc "

Hello

\n
nowiki
", "Hello\n{{{\nnowiki\n}}}\n" # WARNING: A heading ends a paragraph (not specced) tc "

Hello

\n

Heading

", "Hello\n= Heading =\n" end it 'should parse linebreaks' do # \\ (wiki-style) for line breaks. tc "

This is the first line,
and this is the second.

\n", "This is the first line,\\\\and this is the second." tc "

This is the first line,
and this is the second.

\n", "This is the first line,[[br]]and this is the second." tc "

This is the first line,
and this is the second.

\n", "This is the first line,[[Br]]and this is the second." end it 'should parse blockquote' do tc "

Monty Python

\n", "> Monty Python\n" tc "

Monty Python q2

\n", "> Monty Python\n> q2\n" tc "

Monty Python q2

\n", "> Monty Python\n>q2\n" tc "

Monty Python q2

\n", "> Monty Python\n>**q2**\n" tc "

Monty Python
q2

\n", "> Monty Python\n> > q2\n" tc "

Monty Python
q2 q3

\n", "> Monty Python\n> > q2\n>>q3\n" tc "

Monty Python
q2
q1

\n", ">Monty Python\n> > ''q2''\n>q1" tc "

Monty Python rules

\n", " Monty Python\n rules\n" end it 'should parse definition list' do # FIXME: trailing space tc "
Monty Python
definition
\n", "Monty Python:: \n definition\n" tc "
Monty Python
definition
\n", "Monty Python::\ndefinition\n" tc "
Monty Python
definition
\n", "Monty Python::\r\ndefinition\n" tc "
Monty Python
definition
\n", "Monty Python::\r\n definition\n" tc "
Monty Python
definition
\n", "Monty Python:: \r\n definition\n" tc "
Monty Python
definition
\n", "Monty Python:: definition\n" tc "
Monty Python
definition
\n", "Monty Python:: definition\n" tc "
Monty::Python
definition
\n", "Monty::Python:: definition\n" tc "
::Python
definition
\n", "::Python:: definition\n" end it 'should parse definition list with dia' do tc "
Monty Pýthón
definition
\n", "Monty Pýthón:: \n definition\n" end it 'should not parse definition list' do # FIXME: trailing space tc "

Monty::Python::definition

\n", "Monty::Python::definition\n" tc "

bla Monty::Python bla

\n", "bla Monty::Python bla\n" tc "

bla Monty::Python

\n", "bla Monty::Python\n" tc "

Monty::Python bla

\n", "Monty::Python bla\n" tc "

::Python bla

\n", "::Python bla\n" tc "

:: Python bla

\n", ":: Python bla\n" end it 'should parse unordered_lists' do # List items begin with a * at the beginning of a line. # An item ends at the next * tc "\n", "* Item 1\n next\n" # Whitespace is optional before and after the *. tc("\n", " * Item 1\n * Item 2\n *\t\tItem 3\n") # A space is required if if the list element starts with bold text. tc("\n", "* **Item 1") # An item ends at blank line tc("\n

Par

\n", "* Item\n\nPar\n") # An item ends at a heading tc("\n

Heading

", "* Item\n= Heading =\n") # An item ends at a table tc("\n\n\n
Cell
\n", "* Item\n||Cell||\n") # An item ends at a nowiki block tc("\n
Code
", "* Item\n{{{\nCode\n}}}\n") # An item can span multiple lines tc("\n", "* The quick\nbrown fox\n\tjumps over\nlazy dog.\n* Humpty Dumpty\nsat\t\non a wall.") # An item can contain line breaks tc("\n", "* The quick brown\\\\fox jumps over lazy dog.") # Nested tc "\n", "* Item 1\n * Item 2\n*\t\tItem 3\n" # Nested up to 5 levels tc("\n", "* Item 1\n * Item 2\n * Item 3\n * Item 4\n * Item 5\n") tc("\n", "* Item 1\n * Item 2\n * Item 3\n * Item 4\n* Item 5\n") # ** immediatly following a list element will be treated as a nested unordered element. tc("\n", "* Hello,\n World!\n * Not bold\n") # ** immediatly following a list element will be treated as a nested unordered element. tc("
  1. Hello, World!
    • Not bold
    • \n
    \n
  2. \n
\n", "1. Hello,\n World!\n * Not bold\n") # [...] otherwise it will be treated as the beginning of bold text. tc("\n

Not bold

\n", "* Hello,\nWorld!\n\n**Not bold\n") end it 'should parse ordered lists' do # List items begin with a * at the beginning of a line. # An item ends at the next * tc "
  1. Item 1
  2. \n
  3. Item 2
  4. \n
  5. Item 3
  6. \n
\n", "1. Item 1\n2. Item 2\n3. \t\tItem 3\n" # Whitespace is optional before and after the #. tc("
  1. Item 1
  2. \n
  3. Item 2
  4. \n
  5. Item 3
  6. \n
\n", "1. Item 1\n1. Item 2\n4.\t\tItem 3\n") # A space is required if if the list element starts with bold text. # tc("
      1. Item 1
      \n
    1. \n
    \n
  1. \n
\n", "###Item 1") tc("
  1. Item 1
  2. \n
\n", "1. **Item 1") # An item ends at blank line tc("
  1. Item
  2. \n
\n

Par

\n", "1. Item\n\nPar\n") # An item ends at a heading tc("
  1. Item
  2. \n
\n

Heading

", "1. Item\n= Heading =\n") # An item ends at a table tc("
  1. Item
  2. \n
\n\n\n
Cell
\n", "1. Item\n||Cell||\n") # An item ends at a nowiki block tc("
  1. Item
  2. \n
\n
Code
", "1. Item\n{{{\nCode\n}}}\n") # An item can span multiple lines tc("
  1. The quick brown fox jumps over lazy dog.
  2. \n
  3. Humpty Dumpty sat on a wall.
  4. \n
\n", "1. The quick\nbrown fox\n\tjumps over\nlazy dog.\n2. Humpty Dumpty\nsat\t\non a wall.") # An item can contain line breaks tc("
  1. The quick brown
    fox jumps over lazy dog.
  2. \n
\n", "1. The quick brown\\\\fox jumps over lazy dog.") # Nested tc "
  1. Item 1
    1. Item 2
    2. \n
    \n
  2. \n
  3. Item 3
  4. \n
\n", "1. Item 1\n 1. Item 2\n2.\t\tItem 3\n" # Nested up to 5 levels tc("
  1. Item 1
    1. Item 2
      1. Item 3
        1. Item 4
          1. Item 5
          2. \n
          \n
        2. \n
        \n
      2. \n
      \n
    2. \n
    \n
  2. \n
\n", "1. Item 1\n 1. Item 2\n 1. Item 3\n 1. Item 4\n 1. Item 5\n") # The two-bullet rule only applies to **. # tc("
    1. Item
    2. \n
    \n
  1. \n
\n", "##Item") end it 'should parse ordered lists #2' do tc "
  1. Item 1
  2. \n
  3. Item 2
  4. \n
  5. Item 3
  6. \n
\n", "1. Item 1\n1. Item 2\n1.\t\tItem 3\n" # Nested tc "
  1. Item 1
    1. Item 2
    2. \n
    \n
  2. \n
  3. Item 3
  4. \n
\n", "1. Item 1\n 1. Item 2\n1.\t\tItem 3\n" # Multiline tc "
  1. Item 1 on multiple lines
  2. \n
\n", "1. Item 1\non multiple lines" end it 'should parse ambiguious mixed lists' do # ol following ul tc("\n
  1. oitem
  2. \n
\n", "* uitem\n1. oitem\n") # ul following ol tc("
  1. uitem
  2. \n
\n\n", "1. uitem\n* oitem\n") # 2ol following ul tc("\n", "* uitem\n 1. oitem\n") # 2ul following ol tc("
  1. uitem
    • oitem
    • \n
    \n
  2. \n
\n", "1. uitem\n * oitem\n") # 3ol following 3ul # tc("\n", "***uitem\n###oitem\n") # 2ul following 2ol # tc("
    1. uitem
    2. \n
    \n
    • oitem
    • \n
    \n
  1. \n
\n", "##uitem\n**oitem\n") # ol following 2ol # tc("
    1. oitem1
    2. \n
    \n
  1. \n
  2. oitem2
  3. \n
\n", "##oitem1\n#oitem2\n") # ul following 2ol # tc("
    1. oitem1
    2. \n
    \n
  1. \n
\n\n", "##oitem1\n*oitem2\n") end it 'should parse ambiguious italics and url' do # Uncommon URL schemes should not be parsed as URLs tc("

This is what can go wrong:this should be an italic text.

\n", "This is what can go wrong:''this should be an italic text''.") # A link inside italic text tc("

How about a link, like http://example.org, in italic text?

\n", "How about ''a link, like http://example.org, in italic'' text?") tc("

How about a link, like http://example.org, in italic text?

\n", "How about ''a link, like [http://example.org], in italic'' text?") # Another test tc("

Formatted fruits, for example:apples, oranges, pears ...

\n", "Formatted fruits, for example:''apples'', oranges, **pears** ...") end it 'should parse ambiguious bold and lists' do tc "

bold text

\n", "** bold text **" tc "

bold text

\n", " ** bold text **" tc "

bold text

\n", " ** bold\ntext **" end it 'should parse nowiki' do # ... works as block tc "
Hello
", "{{{\nHello\n}}}\n" tc "

{{{-}}}

\n", "`{{{-}}}`\n" # ... works inline tc "

Hello world.

\n", "Hello {{{world}}}." tc "

Hello world.

\n", "{{{Hello}}} {{{world}}}." # No wiki markup is interpreted inbetween tc "
**Hello**
", "{{{\n**Hello**\n}}}\n" # Leading whitespaces are not permitted # tc("

{{{ Hello }}}

\n", " {{{\nHello\n}}}") tc("

{{{ Hello

}}}

\n", "{{{\nHello\n }}}") # Assumed: Should preserve whitespace tc("
 \t Hello, \t \n \t World \t 
", "{{{\n \t Hello, \t \n \t World \t \n}}}\n") # In preformatted blocks ... one leading space is removed tc("
nowikiblock\n}}}
", "{{{\nnowikiblock\n }}}\n}}}\n") # In inline nowiki, any trailing closing brace is included in the span tc("

this is nowiki}

\n", "this is {{{nowiki}}}}") tc("

this is nowiki}}

\n", "this is {{{nowiki}}}}}") tc("

this is nowiki}}}

\n", "this is {{{nowiki}}}}}}") tc("

this is nowiki}}}}

\n", "this is {{{nowiki}}}}}}}") end it 'should escape html' do # Special HTML chars should be escaped tc("

<b>not bold</b>

\n", "not bold") # Image tags should be escape tc("

\n", "[[Image(image.jpg)]]") tc("

\n", "[[Image(bla/image.jpg)]]", :base => "/ahoj/bhoj", :no_escape => true) tc("

\n", "[[Image(image.jpg)]]", :no_link=>true) tc("

\"a%22tag%22\"

\n", "[[Image(image.jpg,alt=a\"tag\")]]") tc("

\"a%22tag%22\"

\n", "[[Image(image.jpg,alt=a\"tag\")]]", :no_link=>true) # Malicious links should not be converted. tc("

Click

\n", "[[javascript:alert(\"Boo!\")|Click]]") end it 'should support character escape' do tc "

** Not Bold **

\n", "!** Not Bold !**" tc "

// Not Italic //

\n", "!// Not Italic !//" tc "

* Not Bullet

\n", "!* Not Bullet" # Following char is not a blank (space or line feed) #tc "

Hello \u00a0 world

\n", "Hello ~ world\n" tc "

Hello   world

\n", "Hello ~ world\n" tc "

Hello ! world

\n", "Hello ! world\n" tc "

Hello ! world

\n", "Hello ! world\n" tc "

Hello ! world

\n", "Hello !\nworld\n" # Not escaping inside URLs tc "

http://example.org/~user/

\n", "http://example.org/~user/" tc "

http://example.org/~user/

\n", "[http://example.org/~user/]" tc "

http://example.org/~user/

\n", "[http://example.org/~user/]", :no_link=>true tc "

http://example.org/~user/

\n", "[[http://example.org/~user/]]", :no_link=>true tc "

http://example.org/~user/

\n", "[[http://example.org/~user/]]" # Escaping links tc "

http://www.example.org/

\n", "!http://www.example.org/" tc "

[http://www.example.org/]

\n", "![!http://www.example.org/]" tc "

[http://www.example.org/]

\n", "![http://www.example.org/]" end it 'should parse horizontal rule' do # Four hyphens make a horizontal rule tc "
", "----" # Whitespace around them is allowed tc "
", " ----" tc "
", "---- " tc "
", " ---- " tc "
", " \t ---- \t " # Nothing else than hyphens and whitespace is "allowed" tc "

foo ----

\n", "foo ----\n" tc "

---- foo

\n", "---- foo\n" # [...] no whitespace is allowed between them tc "

-- --

\n", "-- -- " tc "

-- --

\n", "--\t-- " end it 'should parse table' do tc "\n\n\n
HelloWorld!
\n", "||Hello||World!||" tc "\n\n\n\n\n\n
HelloWorld!
HelloWorld!
\n", "||Hello||World!||\n||Hello||World!||\n\n" tc "\n\n\n\n\n\n
HelloWorld!
HelloWorld!
\n", "||Hello||World!||\r\n||Hello||World!||\r\n\n" tc "\n\n\n
HelloWorld!
\n", "||Hello||\\\n||World!||" tc "\n\n\n\n
HelloWorld!
\n", "||He||llo||\\\n||World!||" tc "\n\n\n
HelloWorld!
\n", "||Hello||||World!||" tc "\n\n\n\n
HellokukWorld!
\n", "||Hello||||kuk||\\\n||World!||" tc "\n\n\n\n\n\n\n\n\n\n\n\n
123
1-23
12-3
1-2-3
\n", "|| 1 || 2 || 3 ||\n|||| 1-2 || 3 ||\n|| 1 |||| 2-3 ||\n|||||| 1-2-3 ||\n" tc "\n\n\n
tablecenter
\n", "||table|| center ||" tc "\n\n\n
tableright
\n", "||table|| right||" tc "\n\n\n\n
tablecenterright
\n", "||table|| center || right||" tc "\n\n
Hello, World!
\n", "||Hello, World!||" tc "\n\n
Hello, Right World!
\n", "|| Hello, Right World!||" tc "\n\n
Hello, Right World!
\n", "||= Hello, Right World!=||" tc "\n\n
Hello, Centered World!
\n", "|| Hello, Centered World! ||" tc "\n\n
Hello, Centered World!
\n", "||= Hello, Centered World! =||" # Multiple columns tc "\n\n\n\n
c1c2c3
\n", "||c1||c2||c3||" # Multiple rows tc "\n\n\n\n\n\n
c11c12
c21c22
\n", "||c11||c12||\n||c21||c22||\n" # End pipe is optional tc "\n\n\n\n
c1c2c3
\n", "||c1||c2||c3" # Empty cells tc "\n\n\n\n
c1c2
\n", "||c1|| ||c2" # Escaping cell separator tc "\n\n\n
c1|c2c3
\n", "||c1!|c2||c3" # Escape in last cell + empty cell tc "\n\n\n
c1c2|
\n", "||c1||c2!|" tc "\n\n\n
c1c2|
\n", "||c1||c2!|" tc "\n\n\n\n
c1c2|
\n", "||c1||c2| || ||" # Equal sign after pipe make a header tc "\n\n
Header
\n", "||=Header=||" tc "\n\n\n\n
c1Link text
\n", "||c1||[[Link|Link text]]||[[Image(Image)]]||" tc "\n\n\n\n
c1Link text
\n", "||c1||[Link|Link text]||[[Image(Image)]]||" end it 'should parse following table' do # table followed by heading tc("\n\n
table
\n

heading

", "||table||\n=heading=\n") tc("\n\n
table
\n

heading

", "||table||\n\n=heading=\n") # table followed by paragraph tc("\n\n
table
\n

par

\n", "||table||\npar\n") tc("\n\n
table
\n

par

\n", "||table||\n\npar\n") # table followed by unordered list tc("\n\n
table
\n\n", "||table||\n* item\n") tc("\n\n
table
\n\n", "||table||\n\n* item\n") # table followed by ordered list tc("\n\n
table
\n
  1. item
  2. \n
\n", "||table||\n1. item\n") tc("\n\n
table
\n
  1. item
  2. \n
\n", "||table||\n\n1. item\n") # table followed by horizontal rule tc("\n\n
table
\n
", "||table||\n----\n") tc("\n\n
table
\n
", "||table||\n\n----\n") # table followed by nowiki block tc("\n\n
table
\n
pre
", "||table||\n{{{\npre\n}}}\n") tc("\n\n
table
\n
pre
", "||table||\n\n{{{\npre\n}}}\n") # table followed by table tc("\n\n\n\n
table
table
\n", "||table||\n||table||\n") tc("\n\n
table
\n\n\n
table
\n", "||table||\n\n||table||\n") end it 'should parse following heading' do # heading tc("

heading1

heading2

", "=heading1=\n=heading2\n") tc("

heading1

heading2

", "=heading1=\n\n=heading2\n") # paragraph tc("

heading

par

\n", "=heading=\npar\n") tc("

heading

par

\n", "=heading=\n\npar\n") # unordered list tc("

heading

\n", "=heading=\n* item\n") tc("

heading

\n", "=heading=\n\n* item\n") # ordered list tc("

heading

  1. item
  2. \n
\n", "=heading=\n1. item\n") tc("

heading

  1. item
  2. \n
\n", "=heading=\n\n1. item\n") # horizontal rule tc("

heading


", "=heading=\n----\n") tc("

heading


", "=heading=\n\n----\n") # nowiki block tc("

heading

nowiki
", "=heading=\n{{{\nnowiki\n}}}\n") tc("

heading

nowiki
", "=heading=\n\n{{{\nnowiki\n}}}\n") # table tc("

heading

\n\n
table
\n", "=heading=\n||table||\n") tc("

heading

\n\n
table
\n", "=heading=\n\n||table||\n") end it 'should parse following paragraph' do # heading tc("

par

\n

heading

", "par\n=heading=") tc("

par

\n

heading

", "par\n\n=heading=") # paragraph tc("

par par

\n", "par\npar\n") tc("

par

\n

par

\n", "par\n\npar\n") # unordered tc("

par

\n\n", "par\n* item") tc("

par

\n\n", "par\n\n* item") # ordered tc("

par

\n
  1. item
  2. \n
\n", "par\n1. item\n") tc("

par

\n
  1. item
  2. \n
\n", "par\n\n1. item\n") # horizontal tc("

par

\n
", "par\n----\n") tc("

par

\n
", "par\n\n----\n") # nowiki tc("

par

\n
nowiki
", "par\n{{{\nnowiki\n}}}\n") tc("

par

\n
nowiki
", "par\n\n{{{\nnowiki\n}}}\n") # table tc("

par

\n\n\n
table
\n", "par\n||table||\n") tc("

par

\n\n\n
table
\n", "par\n\n||table||\n") end it 'should parse following unordered list' do # heading tc("\n

heading

", "* item\n=heading=") tc("\n

heading

", "* item\n\n=heading=") # paragraph tc("\n", "* item\npar\n") # items may span multiple lines tc("\n

par

\n", "* item\n\npar\n") # unordered tc("\n", "* item\n* item\n") tc("\n\n", "* item\n\n* item\n") # ordered tc("\n
  1. item
  2. \n
\n", "* item\n1. item\n") tc("\n
  1. item
  2. \n
\n", "* item\n\n1. item\n") # horizontal rule tc("\n
", "* item\n----\n") tc("\n
", "* item\n\n----\n") # nowiki tc("\n
nowiki
", "* item\n{{{\nnowiki\n}}}\n") tc("\n
nowiki
", "* item\n\n{{{\nnowiki\n}}}\n") # table tc("\n\n\n
table
\n", "* item\n||table||\n") tc("\n\n\n
table
\n", "* item\n\n||table||\n") end it 'should parse following ordered list' do # heading tc("
  1. item
  2. \n
\n

heading

", "1. item\n=heading=") tc("
  1. item
  2. \n
\n

heading

", "1. item\n\n=heading=") # paragraph tc("
  1. item par
  2. \n
\n", "1. item\npar\n") # items may span multiple lines tc("
  1. item
  2. \n
\n

par

\n", "1. item\n\npar\n") # unordered tc("
  1. item
  2. \n
\n\n", "1. item\n* item\n") tc("
  1. item
  2. \n
\n\n", "1. item\n\n* item\n") # ordered tc("
  1. item
  2. \n
  3. item
  4. \n
\n", "1. item\n2. item\n") tc("
  1. item
  2. \n
\n
  1. item
  2. \n
\n", "1. item\n\n1. item\n") # horizontal role tc("
  1. item
  2. \n
\n
", "1. item\n----\n") tc("
  1. item
  2. \n
\n
", "1. item\n\n----\n") # nowiki tc("
  1. item
  2. \n
\n
nowiki
", "1. item\n{{{\nnowiki\n}}}\n") tc("
  1. item
  2. \n
\n
nowiki
", "1. item\n\n{{{\nnowiki\n}}}\n") # table tc("
  1. item
  2. \n
\n\n\n
table
\n", "1. item\n||table||\n") tc("
  1. item
  2. \n
\n\n\n
table
\n", "1. item\n\n||table||\n") end it 'should parse following horizontal rule' do # heading tc("

heading

", "----\n=heading=") tc("

heading

", "----\n\n=heading=") # paragraph tc("

par

\n", "----\npar\n") tc("

par

\n", "----\n\npar\n") # unordered tc("
\n", "----\n* item") tc("
\n", "----\n* item") tc("
\n", "----\n- item") tc("
\n", "----\n- item") tc("
\n", "----\n - item") # ordered tc("
  1. item
  2. \n
\n", "----\n1. item") tc("
  1. item
  2. \n
\n", "----\n1. item") # horizontal tc("

", "----\n----\n") tc("

", "----\n\n----\n") # nowiki tc("
nowiki
", "----\n{{{\nnowiki\n}}}\n") tc("
nowiki
", "----\n\n{{{\nnowiki\n}}}\n") # table tc("
\n\n
table
\n", "----\n||table||\n") tc("
\n\n
table
\n", "----\n\n||table||\n") end it 'should parse following nowiki block' do # heading tc("
nowiki

heading

", "{{{\nnowiki\n}}}\n=heading=") tc("
nowiki

heading

", "{{{\nnowiki\n}}}\n\n=heading=") # paragraph tc("
nowiki

par

\n", "{{{\nnowiki\n}}}\npar") tc("
nowiki

par

\n", "{{{\nnowiki\n}}}\n\npar") # unordered tc("
nowiki
\n", "{{{\nnowiki\n}}}\n* item\n") tc("
nowiki
\n", "{{{\nnowiki\n}}}\n\n* item\n") # ordered tc("
nowiki
  1. item
  2. \n
\n", "{{{\nnowiki\n}}}\n1. item\n") tc("
nowiki
  1. item
  2. \n
\n", "{{{\nnowiki\n}}}\n\n1. item\n") # horizontal tc("
nowiki

", "{{{\nnowiki\n}}}\n----\n") tc("
nowiki

", "{{{\nnowiki\n}}}\n\n----\n") # nowiki tc("
nowiki
nowiki
", "{{{\nnowiki\n}}}\n{{{\nnowiki\n}}}\n") tc("
nowiki
nowiki
", "{{{\nnowiki\n}}}\n\n{{{\nnowiki\n}}}\n") # table tc("
nowiki
\n\n
table
\n", "{{{\nnowiki\n}}}\n||table||\n") tc("
nowiki
\n\n
table
\n", "{{{\nnowiki\n}}}\n\n||table||\n") end it 'should parse image' do tc("

\n", "[[Image(image.jpg)]]") tc("

\"tag\"

\n", "[[Image(javascript:image.jpg,alt=tag)]]") tc("

\"tag\"

\n", "[[Image(image.jpg,alt=tag)]]") tc("

\n", "[[Image(image.jpg, 120px )]]") tc("

\n", "[[Image(image.jpg, \t120px )]]") tc("

\n", "[[Image(image.jpg, right)]]") tc("

\n", "[[Image(image.jpg, right,top)]]") tc("

\n", "[[Image(image.jpg, top,right)]]") tc("

\n", "[[Image(image.jpg, top)]]") tc("

\n", "[[Image(image.jpg, valign=top)]]") tc("

\n", "[[Image(image.jpg, center)]]") tc("

\n", "[[Image(image.jpg, middle)]]") tc("

\n", "[[Image(image.jpg, title=houhouhou)]]") tc("

\n", "[[Image(image.jpg,width=120px)]]") tc("

\n", "[[Image(image.jpg, width=120%)]]") tc("

\n", "[[Image(image.jpg,margin=5)]]") tc("

\n", "[[Image(http://example.org/image.jpg)]]") end it 'should parse bold combo' do tc("

bold and

\n\n\n
table
\n

end

\n", "**bold and\n||table||\nend**") end it 'should support font styles below' do tc("

This is underlined

\n", "This is __underlined__") tc("

This is deleted

\n", "This is ~~deleted~~") tc("

This is super

\n", "This is ^super^") tc("

This is sub

\n", "This is ,,sub,,") end it 'should not support signs' do TracWiki.render("(R)").should.not.equal "

®

\n" TracWiki.render("(r)").should.not.equal "

®

\n" TracWiki.render("(C)").should.not.equal "

©

\n" TracWiki.render("(c)").should.not.equal "

©

\n" end it 'should support no_escape' do tc("

a/b/c

\n", "[[a/b/c]]") tc("

a/b/c

\n", "[a/b/c]") tc("

a/b/c

\n", "[[a/b/c]]", :no_escape => true) end it 'should support merge' do tc "
orig
\n", "||||||| orig", :merge => true tc "
mine
\n", "<<<<<<< mine", :merge => true tc "
your
\n", ">>>>>>> your", :merge => true tc "

bhoj

\n
your
\n

ahoj

\n", "bhoj\n>>>>>>> your\nahoj", :merge => true tc "
\n

ahoj

\n", "=======\nahoj\n", :merge => true tc "
split
\n", "======= split", :merge => true tc "

ahoj

\n", "=======\nahoj\n", :merge => false end it 'should compute headers' do h( [ {:level=>0, :sline=>1, :eline=>2}, {:title=>"ahoj", :sline=>3, :eline=> 5, :aname=>nil, :level=>2}, ], "\nahoj\n== ahoj ==\nbhoj\nchoj\n") h( [ {:level=>0, :sline=>1, :eline=>2}, {:title=>"ahoj", :sline=>3, :eline => 5, :aname=>nil, :level=>2}, {:title=>"dhoj", :sline=>6, :eline => 7, :aname=>nil, :level=>3}, ], "\nahoj\n== ahoj ==\nbhoj\nchoj\n===dhoj===\nkuk\n") h( [ {:level=>0, :sline=>1, :eline=>2}, {:title=>"ahoj", :sline=>3, :eline => 7, :aname=>nil, :level=>2}, {:title=>"dhoj", :sline=>8, :eline => 9, :aname=>nil, :level=>3}, ], "\nahoj\n== ahoj ==\nbhoj\nchoj\n\n\n===dhoj===\nkuk\n") h( [ {:level=>0, :sline=>1, :eline=>2}, {:title=>"ah o ~'j", :sline=>3, :eline => 5, :aname=>nil, :level=>2}, {:title=>"*dhoj", :sline=>6, :eline => 7, :aname=>'ble', :level=>3}, ], "\nahoj\n== ah o ~'j ==\nbhoj\nchoj\n===*dhoj ===#ble\nkuk\n") h( [ {:level=>0, :sline=>1, :eline=>2}, {:title=>"ah o ~'j", :sline=>3, :eline => 8, :aname=>nil, :level=>2}, {:title=>"*dhoj", :sline=>9, :eline => 11, :aname=>'ble', :level=>3}, ], <ahoj

\n" , "{{#echo \nahoj\n}}" tc "

H2

" , "{{#echo == H2 ==}}" tc "

H2

" , "{{#echo =={{#echo H2}}==}}" tc "

H3

" , "{{#echo =={{#echo =H3=}}=={{#echo #test}}}}" tc "

This is correct

\n" , "This is {{# NOT}} correct" tc "

h1

" , "{{# comment }}\n= h1 =\n" tc "

h1

" , "{{# comment }}\n\n\n= h1 =\n" tc "

h1

" , "{{# comment }}\n\n\n= h1 =\n{{# Comment2}}\n" tc "

h1

" , "{{# co{{HUU}}mment }}\n\n\n= h1 =\n{{# Comment2}}\n" tc "

UNKNOWN-MACRO:{{macr}}.

\n" , "{{macr\nahoj\n}}" tc "

ahoj UNKNOWN-MACRO:{{macr}}.

\n" , "ahoj {{macr{{o}}}}" tc "

ahoj UNKNOWN-MACRO:{{macro}}.

\n" , "ahoj {{macro}}" tc "

ahoj {{%macrUNKNOWN-MACRO:{{o}}.}}

\n" , "ahoj {{%macr{{o}}}}" tc "

ahoj UNKNOWN-MACRO:{{macr}}.

\n" , "ahoj {{macr{{mac **o**}}}}" tc "

ahoj ahoj

\n" , "ahoj {{$mac|ahoj}}" end it 'should do temlate' do tc "

1WEST

\n", "1{{west}}" tc "

2WEST

\n", "2{{test}}" # macro errors: tc "

TOO_DEEP_RECURSION({{deep}})3

\n", "{{deep}}3" tc "

TOO_LONG_EXPANSION_OF_MACRO(wide)QUIT

\n", "{{wide}}3" tc "

UNKNOWN-MACRO:{{unknown}}.4

\n", "{{unknown u1|u2}}4" tc "

UNKNOWN-MACRO:{{unknown}}.3

\n", "{{unknown}}3" end it 'should do temlate with args' do tc "

jedna::VARTESTPARAM,dve:,p:DVE,arg::VARTESTPARAM|p=DVE

\n", "{{vartest::VARTESTPARAM|p=DVE}}" tc "

jedna::VARTESTPARAM,dve:,p:DVE,arg::VARTESTPARAM|p=DVE

\n", "{{vartest|:VARTESTPARAM|p=DVE}}" tc "

jedna:VARTESTPARAM,dve:,p:DVE,arg:VARTESTPARAM|p=DVE

\n", "{{vartest VARTESTPARAM|p=DVE}}" tc "

jedna:VARTESTPARAM,dve:,p:DVE,arg:VARTESTPARAM|p=DVE

\n", "{{vartest:VARTESTPARAM|p=DVE}}" tc "

jedna:VARTESTPARAM,dve:,p:DVE,arg:VARTESTPARAM|p=DVE

\n", "{{vartest :VARTESTPARAM|p=DVE}}" tc "

jedna:VARTESTPARAM,dve:,p:DVE,arg:VARTESTPARAM|p=DVE

\n", "{{vartest |VARTESTPARAM|p=DVE}}" tc "

jedna:VARTESTPARAM,dve:TRI,p:DVE,arg:VARTESTPARAM|p=DVE|TRI

\n", "{{vartest VARTESTPARAM|p=DVE|TRI}}" tc "

jedna:VARTESTPARAM,dve:TRI,p:DVE,arg:VARTESTPARAM|TRI|p=DVE|tridef

\n", "{{vartest2 VARTESTPARAM|p=DVE|dva=TRI}}" tc "

ahoj |

\n", "ahoj {{!}}" tc "

jedna:be||not to be,dve:,p:,arg:be||not to be

\n", "{{vartest be{{!}}{{!}}not to be}}" end it 'should support options' do tc "

h1edit

", "=== h1 ==", edit_heading: true end it 'should not html' do tc "

<b></b>

\n", "\n" tc "

<div><script>alert(666)</script></div>

\n", "
\n" end it 'should entity' do #tc "

\u00a0

\n", " " #tc "

„text“

\n", "„text“" tc "

 

\n", " " tc "

„text“

\n", "„text“" end it 'should plugin' do tc "

AHOJTE!

\n", "{{!print AHOJTE}}" tc "

test:AHOJTE! AHOJTE!

\n", "test:{{!print AHOJTE}}{{!print AHOJTE}}" tc "

FALSE

\n", "{{ifeqtest JEDNA|DVE}}" tc "

TRUE

\n", "{{ifeqtest JEDNA|JEDNA}}" tc "

AHOJ

\n", "{{!set ahoj|AHOJ}}{{$ahoj}}" tc "

BHOJ

\n", "{{!ifeq a|b|{{!set ahoj|AHOJ}}|{{!set ahoj|BHOJ}}}}{{$ahoj}}" tc "

AHOJ

\n", "{{!ifeq a|a|{{!set ahoj|AHOJ}}|{{!set ahoj|BHOJ}}}}{{$ahoj}}" tc "

TRUE

\n", "{{!set a|a}}{{!ifeq {{$a}}|a|TRUE|FALSE}}" tc "

FALSE

\n", "{{!set a|a}}{{!ifeq {{$a}}|b|TRUE|FALSE}}" tc "

,AHOJ! ,FALSE

\n", "{{!set a|a}},{{!print AHOJ}},{{!ifeq {{$a}}|b|TRUE|FALSE}}" tc "", "{{!ifeq a|b|TRUE}}" tc "

AHOJ,dve

\n", "{{ytest \nahoj: AHOJ\nbhoj: [ jedna, dve ]\n}}" tc "

,malo

\n", "{{!yset ahoj|data: [1,2]\ndesc: malo}},{{$ahoj.desc}}" tc "

,BETA

\n", "{{!yset ahoj|data: [ALFA,BETA]\ndesc: malo}},{{$ahoj.data.1}}" tc "

,GAMA

\n", "{{!yset ahoj|data: [ALFA,BETA]\ndesc: malo}},{{!set ahoj.data.3|GAMA}}{{$ahoj.data.3}}" tc "

,2

\n", "{{!yset ahoj|data: [1,2]\ndesc: malo}},{{$ahoj.data.1}}" tc "

AHOJ,dve

\n", "{{ytest2 \nahoj: AHOJ\nbhoj: [ jedna, dve ]\n}}" tc "

,,BHOJ

\n", "{{!set ahoj|AHOJ}},{{!set AHOJ|BHOJ}},{{$$ahoj}}" tc "

(0),(1),(2),

\n", "{{!for i|3|({{$i}}),}}", allow_html: true tc "

(0),(1),(2),(3),

\n", "{{!for i|4|({{$i}}),}}", allow_html: true tc "

,(ALFA),(BETA),

\n", "{{!yset data|[ALFA,BETA]}},{{!for i|data|({{$data.$i}}),}}" tc "

,(1),(2),

\n", "{{!yset data|[1,2]}},{{!for i|data|({{$data.$i}}),}}" tc "

,(alfa:ALFA),(beta:BETA),

\n", "{{!yset data|beta: BETA\nalfa: ALFA\n}},{{!for i|data|({{$i}}:{{$data.$i}}),}}" tc "

,(0:1),(1:2),

\n", "{{!yset data|[ 1,2 ]\n}},{{!for i|data|({{$i}}:{{$data.$i}}),}}" tc "

,

\n", "{{!yset data|[ ]\n}},{{!for i|data|({{$i}}:{{$data.$i}}),}}" tc "

,FALSE

\n", "{{!yset data|[1,2]}},{{!ifdef data.55|TRUE|FALSE}}" tc "

,TRUE

\n", "{{!yset data|[1,2]}},{{!ifdef data.1|TRUE|FALSE}}" tc "

,TRUE

\n", "{{!yset data|{a: 1, b: 2} }},{{!ifdef data.a|TRUE|FALSE}}" tc "

,FALSE

\n", "{{!yset data|{a: 1, b: 2} }},{{!ifdef data.q|TRUE|FALSE}}" end it 'should parse html' do tc "

alert(666)

\n", "", allow_html: true tc "

TE

\n", "

TE

", allow_html: true tc "

Span

\n", "Span\n", allow_html: true tc "

Span

\n", "**Span**\n", allow_html: true tc "
Div
\n", "
Div
\n", allow_html: true tc "

ahoj

\n
Div
\n", "**ahoj
Div
\n", allow_html: true tc "

SpanSpan

\n", "SpanSpan\n", allow_html: true tc "

boldoitalicE

\n", "

''boldoitali''cE

", allow_html: true tc "

blabla

\n

endE

\n", "

blabla

endE

", allow_html: true tc "

baf

\n", "\n\n\nbaf\n\n\n", allow_html: true tc "
Div
\n

baf

\n", "
Div
\nbaf\n", allow_html: true tc "

BOLD

\n", "BOLD\n", allow_html: true tc "


\n", "
\n", allow_html: true tc "


\n", "

\n", allow_html: true tc "

BOLD

\n", "BOLD\n", allow_html: true tc "

BOLD

\n", "BOLD\n", allow_html: true tc "

BOLD

\n", "BOLD\n", allow_html: true end it 'should parse link' do tc "

Here

\n", "[[#here|Here]]" tc "

Here

\n", "[[#here i m|Here]]" tc "

There

\n", "[[there#i m|There]]" tc "

There

\n", "[[there#i m|There]]", base: 'http://example.com/' tc "

Here

\n", "[[#here i m|Here]]", base: 'http://example.com/' tc "

Here

\n", "[[#here i m|He**r**e]]" end it 'should parse dnl inside macro' do tc "

d

e

\n", "{{!ifeq a|b|c|d\n e}}" tc "

de

\n", "{{!ifeq a|b|c|d\\\n e}}" tc "

de

\n", "{{!ifeq a|b|c|d**\\\ne**}}" tc "

de

\n", "{{!ifeq a|b|c|d*\\\n*e**}}" tc "

de

\n", "{{!ifeq a|b|c|d*\\\r\n*e**}}" tc "

e

\n", "{{!ifeq a|b|c|\\\r\ne}}" tc "

a0a1a2

\n", "{{!for i|3|a\\\n{{$i}}}}" tc "

a0a1a2

\n", "{{!for i|3|a\\\n {{$i}}}}" end it 'should parse offset' do tc "

0

\n", "{{$offset}}" tc "

12345-6

\n", "12345-{{$offset}}" tc "

žížala-7

\n", "žížala-{{$offset}}" tc "

B-6

\n", "**B**-{{$offset}}" tc "

L-6

\n", "[[L]]-{{$offset}}" tc "

4

\n", "[[L|{{$offset}}]]" tc "

3

\n", "[L|{{$offset}}]" tc "

B9

\n", "**B**[[L|{{$offset}}]]" tc "\n", "* {{$offset}}" tc "

2

", "= {{$offset}} =" tc "

B 8

", "= **B** {{$offset}} =" tc "

bla

\n

B 8

", "bla\n= **B** {{$offset}} =" tc "

2

\n", " {{$offset}}" tc "\n\n\n
ahoj11
\n", "|| ahoj || {{$offset}} ||" tc "\n\n\n
ahoj13
\n", "|| ahoj || {{$offset}} ||" tc "\n\n\n
320
\n", "|| {{$offset}} || {{$offset}} ||" tc "\n\n\n\n\n\n
320
320
\n", "|| {{$offset}} || {{$offset}} ||\n|| {{$offset}} || {{$offset}} ||" tc "\n\n
3
\n", "|| {{$offset}} ||" tc "\n\n
3
\n", "||={{$offset}}=||" tc "\n\n
4
\n", "||= {{$offset}} =||" tc "\n\n
3
\n", "|| {{$offset}}||" tc "\n\n
4
\n", "|| {{$offset}} ||" tc "

2

\n", "> {{$offset}}" tc "

2
6

\n", "> {{$offset}}\n> > {{$offset}}" tc "

test:5,17

\n", "test:{{$offset}},{{$offset}}" tc "

test:5,17,31

\n", "test:{{$offset}},{{$offset}},**{{$offset}}**" tc "

off:0

\n", "{{testoff}}" tc "

A:off:2

\n", "A:{{testoff}}" tc "

A:off:2

\n", "A:{{#echo {{testoff}}}}" end it 'should parse offset and template' do tc "

ahoj ahoj,19

\n" , "ahoj {{$mac|ahoj}},{{$offset}}" tc "

ahoj ahoj,19

\n" , "ahoj {{$mac:ahoj}},{{$offset}}" tc "

ahoj line one line two ,12

\n" , "ahoj {{nl}},{{$offset}}" tc "\n" , "{{nl2}},{{$offset}}" tc "\n" , "{{nl2}} {{$offset}}" # in the future: #tc "

ble * line one

\n\n" , "ble {{nl2}} {{$offset}}" end it 'should parse macro slash' do tc "

slash/slash

\n" , "{{/slash}}" end it 'should parse lineno' do tc "

1

\n" , "{{$lineno}}" tc "

3

\n" , "\n\n{{$lineno}}" tc "

ahoj

\n

4

\n" , "**ahoj**\n\n\n{{$lineno}}" tc "
ahoj

4

\n" , "{{{\nahoj\n}}}\n{{$lineno}}" tc "
\nahoj\n
\n

4

\n" , "$$\nahoj\n$$\n{{$lineno}}", math: true tc "

WEST WEST 3

\n" , "{{test}}\n{{test}}\n{{$lineno}}" tc "

WEST 2

\n" , "{{test}}\n{{$lineno}}" tc "

line one line two 1

\n" , "{{nl}} {{$lineno}}" tc "\n" , "{{nl2}} {{$lineno}}" tc "\n" , "{{nl2}}\n{{$lineno}}" tc "\n" , "\n{{nl2}}{{nl}}\n{{$lineno}}" tc "

ahoj

2

\n

ahoj

5

\n", "==ahoj==\n{{$lineno}}\n\n==ahoj==\n{{$lineno}}" tc "\n\n
This is bold
\n

2

\n", "||This is **bold**||\n{{$lineno}}" tc "\n

3

\n", "* [[ahoj|bhoj]]\n\n{{$lineno}}", :no_link => true tc "\n", "* [[ahoj|bhoj]]\n{{$lineno}}", :no_link => true end it 'should parse nula' do tc "

nula:TEXT,a:

\n" , "{{varnula TEXT}}" tc "

nula:TEXT,a:AHOJ

\n" , "{{varnula a=AHOJ|TEXT}}" tc "

nula:TEXT,a:AHOJ

\n" , "{{varnula TEXT|a=AHOJ}}" tc "

nula:TEXT,a:

\n" , "{{varnula TEXT|b=AHOJ}}" tc "

nula:TE|XT,a:AHOJ

\n" , "{{varnula TE|XT|a=AHOJ}}" tc "

nula:TE|XT,a:AHOJ

\n" , "{{varnula TE|a=AHOJ|XT}}" tc "

nula:TE|XT,a:AHOJ

\n" , "{{varnula TE|a=AHOJ|XT}}" tc "

nulanula:TE|a=AHOJ|XT,a:AHOJ

\n" , "{{varnulanula TE|a=AHOJ|XT}}" end it 'should parse env' do env '{{!set b|ahoj}}', 'b', 'ahoj' env '{{!set *|ahoj}}', '*', 'ahoj' env '{{!set *|{}|}}', '*', '{}' tc "

a

\n" , "{{!set qq|a}}{{$qq}}" end it 'should know used templates' do used_templates "{{varnula}}", "varnula:true" used_templates "{{test}}", "test:true,west:true" used_templates "{{testundef}}", "testundef:true,westundef:false" end it 'should parse macro len' do tc "

11

\n" , "{{$maclen}}" tc "

17

\n" , "{{$maclen|12345}}" tc "

18

\n" , "{{$maclen| 12345}}" tc "

19

\n" , "{{$maclen | 12345}}" tc "

18

\n" , "{{$maclen |12345}}" tc "

18

\n" , "{{$maclen |12345}}" tc "

15

\n" , "{{$maclen|kuk}}" tc "

15

\n" , "{{$maclen|123}}" tc "

18

\n" , "{{$maclen|žížala}}" tc "

37

\n" , "{{$maclen|{{$maclen}}{{!echo ahoj}}}}" tc "

37

\n" , "**{{$maclen|{{$maclen}}{{!echo ahoj}}}}**" tc "

28

\n" , "{{$maclen|a=e|b=c|d={{$e}}}}" tc "

maclen:14

\n" , "{{maclentest}}" end it 'should parse macro eoffset' do tc "

16

\n" , "{{$eoffset 123}}" tc "

12

\n" , "{{$eoffset}}" tc "

ABC15

\n" , "ABC{{$eoffset}}" tc "

A B C13

\n" , "A\nB\nC{{$eoffset}}" tc "

A B C18

\n" , "A\nB\nC{{$eoffset ahoj}}" tc "

A B C18

\n" , "A\nB\nC{{$eoffset ahoj}}\n" tc "

A B 17

\n" , "A\nB\n{{$eoffset ahoj}}\n" tc "

A B 6

\n" , "A\nB\n{{$eoffset|\nahoj}}\n" tc "

A B 6

\n" , "A\nB\n{{$eoffset \nahoj}}\n" tc "

A B 6

\n" , "A\nB\n{{$eoffset \n tak to teda\nahoj}}\n" tc "

A B 6BBB

\n" , "A\nB\n{{$eoffset \n tak to teda\nahoj}}BBB\n" tc "

A B 7

\n" , "A\nB\n{{$eoffset \t\t\n\t\n\r\f \n\tahoj}}\n" tc "

A B 6

\n" , "A\nB\n{{$elineno \t\t\n\t\n\r\f \n\tahoj}}\n" tc "

A B 6

\n" , "A\nB\n{{$elineno \t\t\n\t\n\r\r\r\f \n\tahoj}}\n" tc "

A B 7

\n" , "A\nB\n{{$elineno \t\t\n\t\n\r\r\r\f\n \n\tahoj}}\n" tc "

A B 3

\n" , "A\nB\n{{$elineno}}\n" tc "

A B 4

\n" , "A\nB\n{{$elineno\nbla}}\n" end it 'should parse {{!macpos}}' do tc "

1.0-1.14

\n", "{{testmacpos}}" tc "

2.0-2.14

\n", "\n{{testmacpos}}\n" tc "

1.0-1.30

\n", "{{testmacpos alsdkfjlsadjfk }}" tc "

1.0-2.10

\n", "{{testmacpos\n12345678}}" tc "

Ahoj 2.0-3.10

\n", "Ahoj\n{{testmacpos\n12345678}}" tc "

1.0-1.15

\n", "{{testmacpos2}}" tc "

2.0-2.15

\n", "\n{{testmacpos2}}\n" tc "

1.0-1.31

\n", "{{testmacpos2 alsdkfjlsadjfk }}" tc "

1.0-2.10

\n", "{{testmacpos2\n12345678}}" tc "

Ahoj 2.0-3.10

\n", "Ahoj\n{{testmacpos2\n12345678}}" end it 'should expand html attrs' do tc "
TEST
\n", "
TEST

\n", allow_html: true tc "
TEST
\n", "
TEST

\n", allow_html: true tc "
TEST
\n", "{{!set ahoj|AHOJ}}
TEST

\n", allow_html: true tc "
TEST
\n", "{{!set ahoj|AHOJ}}
TEST

\n", allow_html: true end it 'should parse data-* ' do tc "
TEST
\n", "
TEST
\n", allow_html: true tc "
TEST
\n", "
TEST
\n", allow_html: true tc "
TEST
\n", "
TEST
\n", allow_html: true tc "

<div data-coffie-break="tea">TEST</div>

\n", "
TEST
\n", allow_html: false end end # vim: tw=0