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.

132 lines
2.1 KiB

  1. . tests/functions.sh
  2. title "html blocks"
  3. rc=0
  4. MARKDOWN_FLAGS=
  5. try 'self-closing block tags (hr)' \
  6. '<hr>
  7. text' \
  8. '<hr>
  9. <p>text</p>'
  10. try 'self-closing block tags (hr/)' \
  11. '<hr/>
  12. text' \
  13. '<hr/>
  14. <p>text</p>'
  15. try 'html comments' \
  16. '<!--
  17. **hi**
  18. -->' \
  19. '<!--
  20. **hi**
  21. -->'
  22. try 'no smartypants inside tags (#1)' \
  23. '<img src="linky">' \
  24. '<p><img src="linky"></p>'
  25. try 'no smartypants inside tags (#2)' \
  26. '<img src="linky" alt=":)" />' \
  27. '<p><img src="linky" alt=":)" /></p>'
  28. try -fnohtml 'block html with -fnohtml' '<b>hi!</b>' '<p>&lt;b>hi!&lt;/b></p>'
  29. try -fnohtml 'malformed tag injection' '<x <script>' '<p>&lt;x &lt;script></p>'
  30. try -fhtml 'allow html with -fhtml' '<b>hi!</b>' '<p><b>hi!</b></p>'
  31. # check that nested raw html blocks terminate properly.
  32. #
  33. BLOCK1SRC='Markdown works fine *here*.
  34. *And* here.
  35. <div><pre>
  36. </pre></div>
  37. Markdown here is *not* parsed by RDiscount.
  38. Nor in *this* paragraph, and there are no paragraph breaks.'
  39. BLOCK1OUT='<p>Markdown works fine <em>here</em>.</p>
  40. <p><em>And</em> here.</p>
  41. <div><pre>
  42. </pre></div>
  43. <p>Markdown here is <em>not</em> parsed by RDiscount.</p>
  44. <p>Nor in <em>this</em> paragraph, and there are no paragraph breaks.</p>'
  45. try 'nested html blocks (1)' "$BLOCK1SRC" "$BLOCK1OUT"
  46. try 'nested html blocks (2)' \
  47. '<div>This is inside a html block
  48. <div>This is, too</div>and
  49. so is this</div>' \
  50. '<div>This is inside a html block
  51. <div>This is, too</div>and
  52. so is this</div>'
  53. try 'unfinished tags' '<foo bar' '<p>&lt;foo bar</p>'
  54. try 'comment with trailing text' '<!-- this is -->a test' \
  55. '<!-- this is -->
  56. <p>a test</p>'
  57. try 'block with trailing text' '<p>this is</p>a test' \
  58. '<p>this is</p>
  59. <p>a test</p>'
  60. COMMENTS='<!-- 1. -->line 1
  61. <!-- 2. -->line 2'
  62. try 'two comments' "$COMMENTS" \
  63. '<!-- 1. -->
  64. <p>line 1</p>
  65. <!-- 2. -->
  66. <p>line 2</p>'
  67. COMMENTS='<!-- 1. -->line 1
  68. <!-- 2. -->line 2'
  69. try 'two adjacent comments' "$COMMENTS" \
  70. '<!-- 1. -->
  71. <p>line 1</p>
  72. <!-- 2. -->
  73. <p>line 2</p>'
  74. try 'comment, no white space' '<!--foo-->' '<!--foo-->'
  75. try 'unclosed block' '<p>here we go!' '<p><p>here we go!</p>'
  76. summary $0
  77. exit $rc