MCPcopy
hub / github.com/braziljs/eloquente-javascript / stripHTML

Function stripHTML

src/run_tests.mjs:93–105  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

91}
92
93function stripHTML(code) {
94 let included = "", script = ""
95 code = code.replace(/<script\b[^>]*?(?:\bsrc\s*=\s*('[^']+'|"[^"]+"|[^\s>]+)[^>]*)?>([\s\S]*?)<\/script>/, function(m, src, content) {
96 if (!src) {
97 script += content
98 } else if (doRun) {
99 if (/["']/.test(src.charAt(0))) src = src.slice(1, src.length - 1)
100 included += fs.readFileSync("html/" + src, "utf8")
101 }
102 return ""
103 })
104 return {html: code, included: included, javascript: script}
105}
106
107function represent(val) {
108 if (typeof val == "boolean") return String(val)

Callers 1

run_tests.mjsFile · 0.85

Calls 2

replaceMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected