MCPcopy Create free account
hub / github.com/TruthHun/BookStack / createHtmlParser

Function createHtmlParser

static/to-markdown/lib/html-parser.js:27–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27function createHtmlParser () {
28 var Parser = function () {}
29
30 // For Node.js environments
31 if (typeof document === 'undefined') {
32 var jsdom = require('jsdom')
33 Parser.prototype.parseFromString = function (string) {
34 return jsdom.jsdom(string, {
35 features: {
36 FetchExternalResources: [],
37 ProcessExternalResources: false
38 }
39 })
40 }
41 } else {
42 if (!shouldUseActiveX()) {
43 Parser.prototype.parseFromString = function (string) {
44 var doc = document.implementation.createHTMLDocument('')
45 doc.open()
46 doc.write(string)
47 doc.close()
48 return doc
49 }
50 } else {
51 Parser.prototype.parseFromString = function (string) {
52 var doc = new window.ActiveXObject('htmlfile')
53 doc.designMode = 'on' // disable on-page scripts
54 doc.open()
55 doc.write(string)
56 doc.close()
57 return doc
58 }
59 }
60 }
61 return Parser
62}
63
64function shouldUseActiveX () {
65 var useActiveX = false

Callers 1

html-parser.jsFile · 0.85

Calls 1

shouldUseActiveXFunction · 0.70

Tested by

no test coverage detected