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

Function escapeChar

src/render_latex.mjs:32–41  ·  view source on GitHub ↗
(ch)

Source from the content-addressed store, hash-verified

30 .concat(['hints'])
31
32function escapeChar(ch) {
33 switch (ch) {
34 case "~": return "\\textasciitilde "
35 case "^": return "\\textasciicircum "
36 case "\\": return "\\textbackslash "
37 case "/": return "\\slash "
38 case '"': return "\\textquotedbl{}"
39 default: return "\\" + ch
40 }
41}
42function escape(str) {
43 return String(str).replace(/[&%$#_{}~^\\"]|\w(\/)\w/g, (match, group) => {
44 if (group) return match[0] + escapeChar(group) + match[2]

Callers 1

escapeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected