PHP Classes

File: fwphp/glomodul/mkd/html2mkd/src/root-node.js

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/mkd/html2mkd/src/root-node.js   Download  
File: fwphp/glomodul/mkd/html2mkd/src/root-node.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/mkd/html2mkd/src/root-node.js
Date: 1 year ago
Size: 849 bytes
 

Contents

Class file image Download
import collapseWhitespace from './collapse-whitespace' import HTMLParser from './html-parser' import { isBlock, isVoid } from './utilities' export default function RootNode (input) { var root if (typeof input === 'string') { var doc = htmlParser().parseFromString( // DOM parsers arrange elements in the <head> and <body>. // Wrapping in a custom element ensures elements are reliably arranged in // a single element. '<x-turndown id="turndown-root">' + input + '</x-turndown>', 'text/html' ) root = doc.getElementById('turndown-root') } else { root = input.cloneNode(true) } collapseWhitespace({ element: root, isBlock: isBlock, isVoid: isVoid }) return root } var _htmlParser function htmlParser () { _htmlParser = _htmlParser || new HTMLParser() return _htmlParser }