html.t 2.2 KB

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