Merge pull request #68 from mmarkdown/normalize-cite-idx

Normalize cite idx
This commit is contained in:
Miek Gieben 2018-08-17 15:27:40 +01:00 committed by GitHub
commit fed8f8c5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View File

@ -857,9 +857,8 @@ func (r *Renderer) citation(w io.Writer, node *ast.Citation) {
attr[0] = `class="suppressed"`
}
r.outTag(w, "<cite", attr)
r.outs(w, "[")
r.out(w, c)
r.outs(w, "]</cite>")
r.outs(w, fmt.Sprintf(`<a href="#`+"%s"+`"></a>`, c))
r.outs(w, "</cite>")
}
}

View File

@ -64,7 +64,7 @@ func maybeShortRefOrIndex(p *Parser, data []byte, offset int) (int, ast.Node) {
idx := &ast.Index{}
idx.ID = fmt.Sprintf("idx-%d", p.indexCnt)
idx.ID = fmt.Sprintf("idxref:%d", p.indexCnt)
p.indexCnt++
idx.Primary = data[start] == '!'

12
testdata/mmark.test vendored
View File

@ -56,21 +56,21 @@ Caption: Shakespeare.
+++
<h1>Test Citations</h1>
<p><cite class="informative">[RFC1034]</cite></p>
<p><cite class="informative"><a href="#RFC1034"></a></cite></p>
+++
# Test Multiple Citations
[@RFC1034; @!RFC1035]
+++
<h1>Test Multiple Citations</h1>
<p><cite class="informative">[RFC1034]</cite><cite class="normative">[RFC1035]</cite></p>
<p><cite class="informative"><a href="#RFC1034"></a></cite><cite class="normative"><a href="#RFC1035"></a></cite></p>
+++
# Test Multiple Citations with modifier
[@-RFC1034] [@?RFC1035]
+++
<h1>Test Multiple Citations with modifier</h1>
<p><cite class="suppressed">[RFC1034]</cite> <cite class="informative">[RFC1035]</cite></p>
<p><cite class="suppressed"><a href="#RFC1034"></a></cite> <cite class="informative"><a href="#RFC1035"></a></cite></p>
+++
{.myclass1 .myclass2}
~~~
@ -87,9 +87,9 @@ code
+++
<h1>Index</h1>
<p><span class="index" id="idx-0"></span>
<span class="index" id="idx-1"></span>
<span class="index" id="idx-2"></span></p>
<p><span class="index" id="idxref:0"></span>
<span class="index" id="idxref:1"></span>
<span class="index" id="idxref:2"></span></p>
+++
# Cross ref
Look at (#basics)