cabo/kramdown-rfc

Using same text as section name in a link causes it to be removed

CxRes opened this issue · 2 comments

CxRes commented

Using same text as section name in a link causes the text to be removed in the XML. It then gets replaced by "Section X" in the HTML.

Input

# Foo {#foo}

[Hi](#foo) There!

[foo](#foo)bar?  // I want the section name in lowercase, hence not using {{<<foo}}.

Output

<section anchor="foo"><name>Foo</name>

<t><xref target="foo">Hi</xref> There!</t>

<t><xref target="foo"></xref>bar?</t>

Output HTML

<section id="section-1">
      <h2 id="name-foo">
<a href="#section-1" class="section-number selfRef">1. </a><a href="#name-foo" class="section-name selfRef">Foo</a>
      </h2>
<p id="section-1-1"><span><a href="#foo" class="internal xref">Hi</a> (<a href="#foo" class="auto internal xref">Section 1</a>)</span> There!<a href="#section-1-1" class="pilcrow">¶</a></p>
<p id="section-1-2"><a href="#foo" class="auto internal xref">Section 1</a>bar?<a href="#section-1-2" class="pilcrow">¶</a></p>
</section>
cabo commented

This is actually a feature. It is too late in the day for me to remember why this feature exists.
(In any case, we couldn't change this as tons of documents rely on this feature.)
Workaround: Cheat with a zero width space...

CxRes commented

Thanks for clarifying! I'll cheat ;)