toc.t 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. . tests/functions.sh
  2. rc=0
  3. MARKDOWN_FLAGS=
  4. # old-style; uses id= tag (and collides
  5. # with #-style css)
  6. title "(old) table-of-contents support"
  7. try -fidanchor '-T -ftoc' 'table of contents' \
  8. '#H1
  9. hi' \
  10. '<ul>
  11. <li><a href="#H1">H1</a></li>
  12. </ul>
  13. <h1 id="H1">H1</h1>
  14. <p>hi</p>'
  15. try -fidanchor -fnourlencodedanchor '-T -ftoc' 'toc item with link' \
  16. '##[H2](H2) here' \
  17. '<ul>
  18. <li>
  19. <ul>
  20. <li><a href="#H2.here">H2 here</a></li>
  21. </ul>
  22. </li>
  23. </ul>
  24. <h2 id="H2.here"><a href="H2">H2</a> here</h2>'
  25. try -fidanchor -fnourlencodedanchor '-T -ftoc' 'toc item with non-alpha start' \
  26. '#1 header' \
  27. '<ul>
  28. <li><a href="#L1.header">1 header</a></li>
  29. </ul>
  30. <h1 id="L1.header">1 header</h1>'
  31. try -fidanchor -furlencodedanchor '-T -ftoc' 'toc item with non-alpha start (url encoded)' \
  32. '#1 header' \
  33. '<ul>
  34. <li><a href="#1%20header">1 header</a></li>
  35. </ul>
  36. <h1 id="1%20header">1 header</h1>'
  37. summary $0
  38. # new-style; uses a (depreciated) name=
  39. # inside a null <a> tag
  40. title "(new) table-of-contents support"
  41. try '-T -ftoc' 'table of contents' \
  42. '#H1
  43. hi' \
  44. '<ul>
  45. <li><a href="#H1">H1</a></li>
  46. </ul>
  47. <a name="H1"></a>
  48. <h1>H1</h1>
  49. <p>hi</p>'
  50. try '-T -ftoc' 'toc item with link' \
  51. '##[H2](H2) here' \
  52. '<ul>
  53. <li>
  54. <ul>
  55. <li><a href="#H2.here">H2 here</a></li>
  56. </ul>
  57. </li>
  58. </ul>
  59. <a name="H2.here"></a>
  60. <h2><a href="H2">H2</a> here</h2>'
  61. try '-T -ftoc' 'toc item with non-alpha start' \
  62. '#1 header' \
  63. '<ul>
  64. <li><a href="#L1.header">1 header</a></li>
  65. </ul>
  66. <a name="L1.header"></a>
  67. <h1>1 header</h1>'
  68. # Be sure to save toc.t as UTF-8.
  69. try '-T -ftoc,urlencodedanchor' 'urlencoded multibyte chars' \
  70. '#It’s an apostrophe' \
  71. '<ul>
  72. <li><a href="#It%e2%80%99s%20an%20apostrophe">It’s an apostrophe</a></li>
  73. </ul>
  74. <a name="It%e2%80%99s%20an%20apostrophe"></a>
  75. <h1>It’s an apostrophe</h1>'
  76. summary $0
  77. exit $rc