MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / heading_open

Function heading_open

src/render_latex.mjs:113–120  ·  view source on GitHub ↗
(token, _i, _t, newlines)

Source from the content-addressed store, hash-verified

111 paragraph_close() { return "" },
112
113 heading_open(token, _i, _t, newlines) {
114 let breaks = paraBreak(newlines)
115 if (token.tag == "h1") return `\\${!["hints", "intro"].includes(chapter[1]) ? "chapter" : noStarch ? "chapter*" : "addchap"}{`
116 if (token.tag == "h2") return `${breaks}${id(token)}\\section{`
117 if (token.tag == "h3") return `${breaks}${id(token)}\\subsection{`
118 if (token.tag == "h4") return `${breaks}${id(token)}\\subsubsection{`
119 throw new Error("Can't handle heading tag " + token.tag)
120 },
121 heading_close(token) {
122 if (token.tag == "h1") return `}\\label{${chapter[1]}}`
123 return `}`

Callers

nothing calls this directly

Calls 2

paraBreakFunction · 0.85
idFunction · 0.85

Tested by

no test coverage detected