Rework the TOC code so that it uses an a name= anchor

instead of `hx id=` (because the id= may pick up css unexpectedly.)
This commit is contained in:
david parsons
2011-01-24 17:05:44 -08:00
parent 6cad766ca7
commit 27bb2061f7
2 changed files with 9 additions and 7 deletions
+3 -4
View File
@@ -1312,13 +1312,12 @@ text(MMIOT *f)
static void
printheader(Paragraph *pp, MMIOT *f)
{
Qprintf(f, "<h%d", pp->hnumber);
if ( f->flags & MKD_TOC ) {
Qprintf(f, " id=\"", pp->hnumber);
Qstring("<a name=\"", f);
mkd_string_to_anchor(T(pp->text->text), S(pp->text->text), Qchar, f, 1);
Qchar('"', f);
Qstring("\"></a>\n", f);
}
Qchar('>', f);
Qprintf(f, "<h%d>", pp->hnumber);
push(T(pp->text->text), S(pp->text->text), f);
text(f);
Qprintf(f, "</h%d>", pp->hnumber);
+6 -3
View File
@@ -11,7 +11,8 @@ hi' \
'<ul>
<li><a href="#H1">H1</a></li>
</ul>
<h1 id="H1">H1</h1>
<a name="H1"></a>
<h1>H1</h1>
<p>hi</p>'
@@ -22,14 +23,16 @@ try '-T -ftoc' 'toc item with link' \
<li><a href="#H2.here">H2 here</a></li>
</ul></li>
</ul>
<h2 id="H2.here"><a href="H2">H2</a> here</h2>'
<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>
<h1 id="L1.header">1 header</h1>'
<a name="L1.header"></a>
<h1>1 header</h1>'
summary $0
exit $rc