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.

106 lines
2.1 KiB

  1. . tests/functions.sh
  2. title "code blocks"
  3. rc=0
  4. MARKDOWN_FLAGS=
  5. try 'format for code block html' \
  6. ' this is
  7. code' \
  8. '<pre><code>this is
  9. code
  10. </code></pre>'
  11. try 'mismatched backticks' '```tick``' '<p><code>`tick</code></p>'
  12. try 'mismatched backticks(2)' '``tick```' '<p>``tick```</p>'
  13. try 'unclosed single backtick' '`hi there' '<p>`hi there</p>'
  14. try 'unclosed double backtick' '``hi there' '<p>``hi there</p>'
  15. try 'triple backticks' '```hi there```' '<p><code>hi there</code></p>'
  16. try 'quadruple backticks' '````hi there````' '<p><code>hi there</code></p>'
  17. try 'remove space around code' '`` hi there ``' '<p><code>hi there</code></p>'
  18. try 'code containing backticks' '`` a```b ``' '<p><code>a```b</code></p>'
  19. try 'backslash before backtick' '`a\`' '<p><code>a\</code></p>'
  20. try '`>`' '`>`' '<p><code>&gt;</code></p>'
  21. try '`` ` ``' '`` ` ``' '<p><code>`</code></p>'
  22. try '````` ``` `' '````` ``` `' '<p><code>``</code> `</p>'
  23. try '````` ` ```' '````` ` ```' '<p><code>`` `</code></p>'
  24. try 'backslashes in code(1)' ' printf "%s: \n", $1;' \
  25. '<pre><code>printf "%s: \n", $1;
  26. </code></pre>'
  27. try 'backslashes in code(2)' '`printf "%s: \n", $1;`' \
  28. '<p><code>printf "%s: \n", $1;</code></p>'
  29. if ./markdown -V | grep FENCED-CODE >/dev/null; then
  30. try 'fenced code block' \
  31. '~~~
  32. code!
  33. ~~~' \
  34. '<pre><code>code!
  35. </code></pre>'
  36. try 'fenced code block in list' \
  37. '1. ~~~
  38. code block
  39. ~~~' \
  40. '<ol>
  41. <li><pre><code>code block
  42. </code></pre></li>
  43. </ol>'
  44. try 'fenced code block in blockquote' \
  45. '>~~~
  46. code
  47. ~~~' \
  48. '<blockquote><pre><code>code
  49. </code></pre></blockquote>'
  50. try 'unterminated fenced code block' \
  51. '~~~
  52. code' \
  53. '<p>~~~
  54. code</p>'
  55. try 'fenced code block with tildes' \
  56. '~~~~~
  57. ~~~
  58. code with tildes
  59. ~~~
  60. ~~~~~' \
  61. '<pre><code>~~~
  62. code with tildes
  63. ~~~
  64. </code></pre>'
  65. try 'paragraph with trailing fenced block' \
  66. 'text text text
  67. text text text
  68. ~~~
  69. code code code?
  70. ~~~' \
  71. '<p>text text text
  72. text text text
  73. ~~~
  74. code code code?
  75. ~~~</p>'
  76. try 'fenced code blocks with backtick delimiters' \
  77. '```
  78. code
  79. ```' \
  80. '<pre><code>code
  81. </code></pre>'
  82. try 'fenced code block with mismatched delimters' \
  83. '```
  84. code
  85. ~~~' \
  86. '<p>```
  87. code
  88. ~~~</p>'
  89. fi
  90. summary $0
  91. exit $rc