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

Function parseIndexTerm

src/markdown.mjs:135–157  ·  view source on GitHub ↗
(state, silent)

Source from the content-addressed store, hash-verified

133}
134
135function parseIndexTerm(state, silent) {
136 let max = state.posMax
137 // Check for opening '(('
138 if (state.pos >= max + 4 || state.src.charCodeAt(state.pos) != 40 || state.src.charCodeAt(state.pos + 1) != 40 ||
139 state.src.charCodeAt(state.pos + 2) == 40) return false
140
141 let start = state.pos + 2, end = start
142 for (;; end++) {
143 if (end >= max - 1) return false
144 if (state.src.charCodeAt(end) == 41 && state.src.charCodeAt(end + 1)) break
145 }
146
147 let term = state.src.slice(start, end)
148
149 if (!silent) {
150 let token = state.push("meta_index", null, 0)
151 token.args = [term]
152 token.inline = true
153 }
154 state.pending += term
155 state.pos = end + 2
156 return true
157}
158
159let TERMINATOR_RE = /[\n!#$%&*+\-:<=>@\[\\\]^_`{}~]|\(\(/
160

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected