Merge pull request #64 from mmarkdown/index-idx
index: use idx-N for the ID
This commit is contained in:
commit
3e30f72fc0
|
@ -373,7 +373,7 @@ type Index struct {
|
|||
Primary bool
|
||||
Item []byte
|
||||
Subitem []byte
|
||||
ID int // number of the index
|
||||
ID string // ID of the index
|
||||
}
|
||||
|
||||
func removeNodeFromArray(a []Node, node Node) []Node {
|
||||
|
|
|
@ -872,7 +872,7 @@ func (r *Renderer) callout(w io.Writer, node *ast.Callout) {
|
|||
|
||||
func (r *Renderer) index(w io.Writer, node *ast.Index) {
|
||||
// there is no in-text representation.
|
||||
attr := []string{`class="index"`, fmt.Sprintf(`id="%d"`, node.ID)}
|
||||
attr := []string{`class="index"`, fmt.Sprintf(`id="%s"`, node.ID)}
|
||||
r.outTag(w, "<span", attr)
|
||||
r.outs(w, "</span>")
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package parser
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/gomarkdown/markdown/ast"
|
||||
)
|
||||
|
@ -63,7 +64,7 @@ func maybeShortRefOrIndex(p *Parser, data []byte, offset int) (int, ast.Node) {
|
|||
|
||||
idx := &ast.Index{}
|
||||
|
||||
idx.ID = p.indexCnt
|
||||
idx.ID = fmt.Sprintf("idx-%d", p.indexCnt)
|
||||
p.indexCnt++
|
||||
|
||||
idx.Primary = data[start] == '!'
|
||||
|
|
|
@ -87,9 +87,9 @@ code
|
|||
---
|
||||
<h1>Index</h1>
|
||||
|
||||
<p><span class="index" id="0"></span>
|
||||
<span class="index" id="1"></span>
|
||||
<span class="index" id="2"></span></p>
|
||||
<p><span class="index" id="idx-0"></span>
|
||||
<span class="index" id="idx-1"></span>
|
||||
<span class="index" id="idx-2"></span></p>
|
||||
---
|
||||
# Cross ref
|
||||
Look at (#basics)
|
||||
|
|
Loading…
Reference in New Issue