Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.2 KiB

  1. . tests/functions.sh
  2. title "embedded links"
  3. rc=0
  4. MARKDOWN_FLAGS=
  5. try 'url contains &' '[hehehe](u&rl)' '<p><a href="u&amp;rl">hehehe</a></p>'
  6. try 'url contains +' '[hehehe](u+rl)' '<p><a href="u+rl">hehehe</a></p>'
  7. try 'url contains "' '[hehehe](u"rl)' '<p><a href="u%22rl">hehehe</a></p>'
  8. try 'url contains <' '[hehehe](u<rl)' '<p><a href="u&lt;rl">hehehe</a></p>'
  9. try 'url contains whitespace' '[ha](r u)' '<p><a href="r%20u">ha</a></p>'
  10. try 'label contains escaped []s' '[a\[b\]c](d)' '<p><a href="d">a[b]c</a></p>'
  11. try '<label> w/o title' '[hello](<sailor>)' '<p><a href="sailor">hello</a></p>'
  12. try '<label> with title' '[hello](<sailor> "boy")' '<p><a href="sailor" title="boy">hello</a></p>'
  13. try '<label> with whitespace' '[hello]( <sailor> )' '<p><a href="sailor">hello</a></p>'
  14. try 'url contains whitespace & title' \
  15. '[hehehe](r u "there")' \
  16. '<p><a href="r%20u" title="there">hehehe</a></p>'
  17. try 'url contains escaped )' \
  18. '[hehehe](u\))' \
  19. '<p><a href="u)">hehehe</a></p>'
  20. try 'image label contains <' \
  21. '![he<he<he](url)' \
  22. '<p><img src="url" alt="he&lt;he&lt;he" /></p>'
  23. try 'image label contains >' \
  24. '![he>he>he](url)' \
  25. '<p><img src="url" alt="he&gt;he&gt;he" /></p>'
  26. try 'sloppy context link' \
  27. '[heh]( url "how about it?" )' \
  28. '<p><a href="url" title="how about it?">heh</a></p>'
  29. try 'footnote urls formed properly' \
  30. '[hehehe]: hohoho "ha ha"
  31. [hehehe][]' \
  32. '<p><a href="hohoho" title="ha ha">hehehe</a></p>'
  33. try 'linky-like []s work' \
  34. '[foo]' \
  35. '<p>[foo]</p>'
  36. try 'pseudo-protocol "id:"'\
  37. '[foo](id:bar)' \
  38. '<p><span id="bar">foo</span></p>'
  39. try 'pseudo-protocol "class:"' \
  40. '[foo](class:bar)' \
  41. '<p><span class="bar">foo</span></p>'
  42. try 'pseudo-protocol "abbr:"'\
  43. '[foo](abbr:bar)' \
  44. '<p><abbr title="bar">foo</abbr></p>'
  45. try 'nested [][]s' \
  46. '[[z](y)](x)' \
  47. '<p><a href="x">[z](y)</a></p>'
  48. try 'empty [][] tags' \
  49. '[![][1]][2]
  50. [1]: image1
  51. [2]: image2' \
  52. '<p><a href="image2"><img src="image1" alt="" /></a></p>'
  53. try 'footnote cuddled up to text' \
  54. 'foo
  55. [bar]:bar' \
  56. '<p>foo</p>'
  57. try 'mid-paragraph footnote' \
  58. 'talk talk talk talk
  59. [bar]: bar
  60. talk talk talk talk' \
  61. '<p>talk talk talk talk
  62. talk talk talk talk</p>'
  63. try 'mid-blockquote footnote' \
  64. '>blockquote!
  65. [footnote]: here!
  66. >blockquote!' \
  67. '<blockquote><p>blockquote!
  68. blockquote!</p></blockquote>'
  69. try 'end-blockquote footnote' \
  70. '>blockquote!
  71. >blockquote!
  72. [footnote]: here!' \
  73. '<blockquote><p>blockquote!
  74. blockquote!</p></blockquote>'
  75. try 'start-blockquote footnote' \
  76. '[footnote]: here!
  77. >blockquote!
  78. >blockquote!' \
  79. '<blockquote><p>blockquote!
  80. blockquote!</p></blockquote>'
  81. try '[text] (text) not a link' \
  82. '[test] (me)' \
  83. '<p>[test] (me)</p>'
  84. try '[test] [this] w/ one space between' \
  85. '[test] [this]
  86. [test]: yay!
  87. [this]: nay!' \
  88. '<p><a href="nay!">test</a></p>'
  89. try '[test] [this] w/ two spaces between' \
  90. '[test] [this]
  91. [test]: yay!
  92. [this]: nay!' \
  93. '<p><a href="yay!">test</a> <a href="nay!">this</a></p>'
  94. try -f1.0 'link with <> (-f1.0)' \
  95. '[this](<is a (test)>)' \
  96. '<p><a href="is%20a%20(test">this</a>>)</p>'
  97. try 'link with <>' \
  98. '[this](<is a (test)>)' \
  99. '<p><a href="is%20a%20(test)">this</a></p>'
  100. summary $0
  101. exit $rc