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

Function parseInlineMeta

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

Source from the content-addressed store, hash-verified

95}
96
97function parseInlineMeta(state, silent) {
98 if (state.src.charCodeAt(state.pos) != 91) return false // '['
99
100 let max = state.posMax
101 let end = state.md.helpers.parseLinkLabel(state, state.pos, false)
102 if (end < 0) return false
103
104 let pos = end + 1
105 if (pos >= max || state.src.charCodeAt(pos) != 123) return false // '{'
106
107 let metaEnd = pos + 1, depth = 0
108 for (;; metaEnd++) {
109 if (metaEnd == max) return false
110 let code = state.src.charCodeAt(metaEnd)
111 if (code == 125) { // '}'
112 if (depth) depth--
113 else break
114 } else if (code == 123) {
115 depth++
116 }
117 }
118
119 let data = parseData(state.src.slice(pos + 1, metaEnd))
120 if (!data) return false
121
122 state.pos++
123 state.posMax = end
124 if (!silent) {
125 state.push("meta_" + data.tag + "_open", null, 1).args = data.args
126 state.md.inline.tokenize(state)
127 state.push("meta_" + data.tag + "_close", null, -1).args = data.args
128 }
129 state.pos = metaEnd + 1
130 state.posMax = max
131
132 return true
133}
134
135function parseIndexTerm(state, silent) {
136 let max = state.posMax

Callers

nothing calls this directly

Calls 1

parseDataFunction · 0.85

Tested by

no test coverage detected