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

Function link_open

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

Source from the content-addressed store, hash-verified

148 sup_close() { return "</sup>" },
149
150 link_open(token) {
151 let alt = token.attrGet("alt"), href= token.attrGet("href")
152 let maybeChapter = /^(\w+)(#.*)?$/.exec(href)
153 if (maybeChapter && chapters.includes(maybeChapter[1])) {
154 let number = ""
155 if (maybeChapter[1] != "hints") {
156 linkedChapter = chapters.indexOf(maybeChapter[1])
157 number = pad(linkedChapter) + "_"
158 }
159 href = number + maybeChapter[1] + (epub ? ".xhtml" : ".html") + (maybeChapter[2] || "")
160 }
161 return `<a href="${escape(href)}"${alt ? ` alt="${escape(alt)}"` : ""}>`
162 },
163 link_close() { linkedChapter = null; return "</a>" },
164
165 inline(token) { return renderArray(token.children) },

Callers

nothing calls this directly

Calls 2

padFunction · 0.85
escapeFunction · 0.70

Tested by

no test coverage detected