MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / anchor

Function anchor

src/render_html.mjs:77–85  ·  view source on GitHub ↗
(token)

Source from the content-addressed store, hash-verified

75
76const seenIDs = Object.create(null)
77function anchor(token) {
78 let id = token.hashID
79 if (id in seenIDs) for (let i = 1;; i++) {
80 let ext = id + "_" + i
81 if (!(ext in seenIDs)) { id = ext; break }
82 }
83 seenIDs[id] = true
84 return `<a class="${id.charAt(0)}_ident" id="${id}" href="#${id}" tabindex="-1" role="presentation"></a>`
85}
86
87function attrs(token) {
88 return token.attrs ? token.attrs.map(([name, val]) => ` ${name}="${escape(String(val))}"`).join("") : ""

Callers 3

fenceFunction · 0.85
paragraph_openFunction · 0.85
heading_openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected