linkylinky.t 3.3 KB

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