2025-12-13 00:40:57 +04:00

119 lines
2.0 KiB
Raku
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

. tests/functions.sh
rc=0
MARKDOWN_FLAGS=
# old-style; uses id= tag (and collides
# with #-style css)
title "(old) table-of-contents support"
try -fidanchor '-T -ftoc' 'table of contents' \
'#H1
hi' \
'<ul>
<li><a href="#H1">H1</a></li>
</ul>
<h1 id="H1">H1</h1>
<p>hi</p>'
try -fidanchor -fnohtml5anchor '-T -ftoc' 'toc item with link' \
'##[H2](H2) here' \
'<ul>
<li>
<ul>
<li><a href="#H2-here">H2 here</a></li>
</ul>
</li>
</ul>
<h2 id="H2-here"><a href="H2">H2</a> here</h2>'
try -fidanchor -fnohtml5anchor '-T -ftoc' 'toc item with non-alpha start' \
'#1 header' \
'<ul>
<li><a href="#L1-header">1 header</a></li>
</ul>
<h1 id="L1-header">1 header</h1>'
try -fidanchor -fhtml5anchor '-T -ftoc' 'toc item with non-alpha start (url encoded)' \
'#1 header' \
'<ul>
<li><a href="#1-header">1 header</a></li>
</ul>
<h1 id="1-header">1 header</h1>'
summary $0
# new-style; uses a (depreciated) name=
# inside a null <a> tag
title "(new) table-of-contents support"
try '-T -ftoc' 'table of contents' \
'#H1
hi' \
'<ul>
<li><a href="#H1">H1</a></li>
</ul>
<a name="H1"></a>
<h1>H1</h1>
<p>hi</p>'
try '-T -ftoc' 'toc item with link' \
'##[H2](H2) here' \
'<ul>
<li>
<ul>
<li><a href="#H2-here">H2 here</a></li>
</ul>
</li>
</ul>
<a name="H2-here"></a>
<h2><a href="H2">H2</a> here</h2>'
try '-T -ftoc' 'toc item with non-alpha start' \
'#1 header' \
'<ul>
<li><a href="#L1-header">1 header</a></li>
</ul>
<a name="L1-header"></a>
<h1>1 header</h1>'
# Be sure to save toc.t as UTF-8.
try '-T -ftoc,html5anchor' 'html5 multibyte chars' \
'#Its an apostrophe' \
'<ul>
<li><a href="#Its-an-apostrophe">Its an apostrophe</a></li>
</ul>
<a name="Its-an-apostrophe"></a>
<h1>Its an apostrophe</h1>'
summary $0
# Check that the uniquifier works
#
title "uniquifying duplicate headers"
try '-T -ftoc' 'uniquifying duplicate labels' \
'# this
# this' \
'<ul>
<li><a href="#this">this</a></li>
<li><a href="#this_0">this</a></li>
</ul>
<a name="this"></a>
<h1>this</h1>
<a name="this_0"></a>
<h1>this</h1>'
summary $0
exit $rc