WIP - add extractor, generate snippet_data
This commit is contained in:
22
node_modules/hast-util-to-html/LICENSE
generated
vendored
Normal file
22
node_modules/hast-util-to-html/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
2
node_modules/hast-util-to-html/index.js
generated
vendored
Normal file
2
node_modules/hast-util-to-html/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
'use strict'
|
||||
module.exports = require('./lib')
|
||||
19
node_modules/hast-util-to-html/lib/all.js
generated
vendored
Normal file
19
node_modules/hast-util-to-html/lib/all.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
var one = require('./one')
|
||||
|
||||
module.exports = all
|
||||
|
||||
/* Stringify all children of `parent`. */
|
||||
function all(ctx, parent) {
|
||||
var children = parent && parent.children
|
||||
var length = children && children.length
|
||||
var index = -1
|
||||
var results = []
|
||||
|
||||
while (++index < length) {
|
||||
results[index] = one(ctx, children[index], index, parent)
|
||||
}
|
||||
|
||||
return results.join('')
|
||||
}
|
||||
8
node_modules/hast-util-to-html/lib/comment.js
generated
vendored
Normal file
8
node_modules/hast-util-to-html/lib/comment.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = comment
|
||||
|
||||
/* Stringify a comment `node`. */
|
||||
function comment(ctx, node) {
|
||||
return '<!--' + node.value + '-->'
|
||||
}
|
||||
47
node_modules/hast-util-to-html/lib/constants.js
generated
vendored
Normal file
47
node_modules/hast-util-to-html/lib/constants.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
'use strict'
|
||||
|
||||
// Characters.
|
||||
var NULL = '\0'
|
||||
var AMP = '&'
|
||||
var SP = ' '
|
||||
var TB = '\t'
|
||||
var GR = '`'
|
||||
var DQ = '"'
|
||||
var SQ = "'"
|
||||
var EQ = '='
|
||||
var LT = '<'
|
||||
var GT = '>'
|
||||
var SO = '/'
|
||||
var LF = '\n'
|
||||
var CR = '\r'
|
||||
var FF = '\f'
|
||||
|
||||
var whitespace = [SP, TB, LF, CR, FF]
|
||||
// https://html.spec.whatwg.org/#attribute-name-state
|
||||
var name = whitespace.concat(AMP, SO, GT, EQ)
|
||||
// https://html.spec.whatwg.org/#attribute-value-(unquoted)-state
|
||||
var unquoted = whitespace.concat(AMP, GT)
|
||||
var unquotedSafe = unquoted.concat(NULL, DQ, SQ, LT, EQ, GR)
|
||||
// https://html.spec.whatwg.org/#attribute-value-(single-quoted)-state
|
||||
var singleQuoted = [AMP, SQ]
|
||||
// https://html.spec.whatwg.org/#attribute-value-(double-quoted)-state
|
||||
var doubleQuoted = [AMP, DQ]
|
||||
|
||||
// Maps of subsets. Each value is a matrix of tuples.
|
||||
// The first value causes parse errors, the second is valid.
|
||||
// Of both values, the first value is unsafe, and the second is safe.
|
||||
module.exports = {
|
||||
name: [
|
||||
[name, name.concat(DQ, SQ, GR)],
|
||||
[name.concat(NULL, DQ, SQ, LT), name.concat(NULL, DQ, SQ, LT, GR)]
|
||||
],
|
||||
unquoted: [[unquoted, unquotedSafe], [unquotedSafe, unquotedSafe]],
|
||||
single: [
|
||||
[singleQuoted, singleQuoted.concat(DQ, GR)],
|
||||
[singleQuoted.concat(NULL), singleQuoted.concat(NULL, DQ, GR)]
|
||||
],
|
||||
double: [
|
||||
[doubleQuoted, doubleQuoted.concat(SQ, GR)],
|
||||
[doubleQuoted.concat(NULL), doubleQuoted.concat(NULL, SQ, GR)]
|
||||
]
|
||||
}
|
||||
33
node_modules/hast-util-to-html/lib/doctype.js
generated
vendored
Normal file
33
node_modules/hast-util-to-html/lib/doctype.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = doctype
|
||||
|
||||
/* Stringify a doctype `node`. */
|
||||
function doctype(ctx, node) {
|
||||
var sep = ctx.tightDoctype ? '' : ' '
|
||||
var name = node.name
|
||||
var pub = node.public
|
||||
var sys = node.system
|
||||
var val = ['<!doctype']
|
||||
|
||||
if (name) {
|
||||
val.push(sep, name)
|
||||
|
||||
if (pub != null) {
|
||||
val.push(' public', sep, smart(pub))
|
||||
} else if (sys != null) {
|
||||
val.push(' system')
|
||||
}
|
||||
|
||||
if (sys != null) {
|
||||
val.push(sep, smart(sys))
|
||||
}
|
||||
}
|
||||
|
||||
return val.join('') + '>'
|
||||
}
|
||||
|
||||
function smart(value) {
|
||||
var quote = value.indexOf('"') === -1 ? '"' : "'"
|
||||
return quote + value + quote
|
||||
}
|
||||
235
node_modules/hast-util-to-html/lib/element.js
generated
vendored
Normal file
235
node_modules/hast-util-to-html/lib/element.js
generated
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
'use strict'
|
||||
|
||||
var xtend = require('xtend')
|
||||
var svg = require('property-information/svg')
|
||||
var find = require('property-information/find')
|
||||
var spaces = require('space-separated-tokens').stringify
|
||||
var commas = require('comma-separated-tokens').stringify
|
||||
var entities = require('stringify-entities')
|
||||
var ccount = require('ccount')
|
||||
var all = require('./all')
|
||||
var constants = require('./constants')
|
||||
|
||||
module.exports = element
|
||||
|
||||
/* Constants. */
|
||||
var EMPTY = ''
|
||||
|
||||
/* Characters. */
|
||||
var SPACE = ' '
|
||||
var DQ = '"'
|
||||
var SQ = "'"
|
||||
var EQ = '='
|
||||
var LT = '<'
|
||||
var GT = '>'
|
||||
var SO = '/'
|
||||
|
||||
/* Stringify an element `node`. */
|
||||
function element(ctx, node, index, parent) {
|
||||
var parentSchema = ctx.schema
|
||||
var name = node.tagName
|
||||
var value = ''
|
||||
var selfClosing
|
||||
var close
|
||||
var omit
|
||||
var root = node
|
||||
var content
|
||||
var attrs
|
||||
|
||||
if (parentSchema.space === 'html' && name === 'svg') {
|
||||
ctx.schema = svg
|
||||
}
|
||||
|
||||
attrs = attributes(ctx, node.properties)
|
||||
|
||||
if (ctx.schema.space === 'svg') {
|
||||
omit = false
|
||||
close = true
|
||||
selfClosing = ctx.closeEmpty
|
||||
} else {
|
||||
omit = ctx.omit
|
||||
close = ctx.close
|
||||
selfClosing = ctx.voids.indexOf(name.toLowerCase()) !== -1
|
||||
|
||||
if (name === 'template') {
|
||||
root = node.content
|
||||
}
|
||||
}
|
||||
|
||||
content = all(ctx, root)
|
||||
|
||||
/* If the node is categorised as void, but it has
|
||||
* children, remove the categorisation. This
|
||||
* enables for example `menuitem`s, which are
|
||||
* void in W3C HTML but not void in WHATWG HTML, to
|
||||
* be stringified properly. */
|
||||
selfClosing = content ? false : selfClosing
|
||||
|
||||
if (attrs || !omit || !omit.opening(node, index, parent)) {
|
||||
value = LT + name + (attrs ? SPACE + attrs : EMPTY)
|
||||
|
||||
if (selfClosing && close) {
|
||||
if (!ctx.tightClose || attrs.charAt(attrs.length - 1) === SO) {
|
||||
value += SPACE
|
||||
}
|
||||
|
||||
value += SO
|
||||
}
|
||||
|
||||
value += GT
|
||||
}
|
||||
|
||||
value += content
|
||||
|
||||
if (!selfClosing && (!omit || !omit.closing(node, index, parent))) {
|
||||
value += LT + SO + name + GT
|
||||
}
|
||||
|
||||
ctx.schema = parentSchema
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
/* Stringify all attributes. */
|
||||
function attributes(ctx, props) {
|
||||
var values = []
|
||||
var key
|
||||
var value
|
||||
var result
|
||||
var length
|
||||
var index
|
||||
var last
|
||||
|
||||
for (key in props) {
|
||||
value = props[key]
|
||||
|
||||
if (value == null) {
|
||||
continue
|
||||
}
|
||||
|
||||
result = attribute(ctx, key, value)
|
||||
|
||||
if (result) {
|
||||
values.push(result)
|
||||
}
|
||||
}
|
||||
|
||||
length = values.length
|
||||
index = -1
|
||||
|
||||
while (++index < length) {
|
||||
result = values[index]
|
||||
last = null
|
||||
|
||||
if (ctx.schema.space === 'html' && ctx.tight) {
|
||||
last = result.charAt(result.length - 1)
|
||||
}
|
||||
|
||||
/* In tight mode, don’t add a space after quoted attributes. */
|
||||
if (index !== length - 1 && last !== DQ && last !== SQ) {
|
||||
values[index] = result + SPACE
|
||||
}
|
||||
}
|
||||
|
||||
return values.join(EMPTY)
|
||||
}
|
||||
|
||||
/* Stringify one attribute. */
|
||||
function attribute(ctx, key, value) {
|
||||
var schema = ctx.schema
|
||||
var space = schema.space
|
||||
var info = find(schema, key)
|
||||
var name = info.attribute
|
||||
|
||||
if (info.overloadedBoolean && (value === name || value === '')) {
|
||||
value = true
|
||||
} else if (
|
||||
info.boolean ||
|
||||
(info.overloadedBoolean && typeof value !== 'string')
|
||||
) {
|
||||
value = Boolean(value)
|
||||
}
|
||||
|
||||
if (
|
||||
value == null ||
|
||||
value === false ||
|
||||
(typeof value === 'number' && isNaN(value))
|
||||
) {
|
||||
return EMPTY
|
||||
}
|
||||
|
||||
name = attributeName(ctx, name)
|
||||
|
||||
if (value === true) {
|
||||
if (space === 'html') {
|
||||
return name
|
||||
}
|
||||
|
||||
value = name
|
||||
}
|
||||
|
||||
return name + attributeValue(ctx, key, value, info)
|
||||
}
|
||||
|
||||
/* Stringify the attribute name. */
|
||||
function attributeName(ctx, name) {
|
||||
// Always encode without parse errors in non-HTML.
|
||||
var valid = ctx.schema.space === 'html' ? ctx.valid : 1
|
||||
var subset = constants.name[valid][ctx.safe]
|
||||
|
||||
return entities(name, xtend(ctx.entities, {subset: subset}))
|
||||
}
|
||||
|
||||
/* Stringify the attribute value. */
|
||||
function attributeValue(ctx, key, value, info) {
|
||||
var options = ctx.entities
|
||||
var quote = ctx.quote
|
||||
var alternative = ctx.alternative
|
||||
var space = ctx.schema.space
|
||||
var unquoted
|
||||
var subset
|
||||
|
||||
if (typeof value === 'object' && 'length' in value) {
|
||||
/* `spaces` doesn’t accept a second argument, but it’s
|
||||
* given here just to keep the code cleaner. */
|
||||
value = (info.commaSeparated ? commas : spaces)(value, {
|
||||
padLeft: !ctx.tightLists
|
||||
})
|
||||
}
|
||||
|
||||
value = String(value)
|
||||
|
||||
if (space !== 'html' || value || !ctx.collapseEmpty) {
|
||||
unquoted = value
|
||||
|
||||
/* Check unquoted value. */
|
||||
if (space === 'html' && ctx.unquoted) {
|
||||
subset = constants.unquoted[ctx.valid][ctx.safe]
|
||||
unquoted = entities(
|
||||
value,
|
||||
xtend(options, {subset: subset, attribute: true})
|
||||
)
|
||||
}
|
||||
|
||||
/* If `value` contains entities when unquoted... */
|
||||
if (space !== 'html' || !ctx.unquoted || unquoted !== value) {
|
||||
/* If the alternative is less common than `quote`, switch. */
|
||||
if (alternative && ccount(value, quote) > ccount(value, alternative)) {
|
||||
quote = alternative
|
||||
}
|
||||
|
||||
subset = quote === SQ ? constants.single : constants.double
|
||||
// Always encode without parse errors in non-HTML.
|
||||
subset = subset[space === 'html' ? ctx.valid : 1][ctx.safe]
|
||||
|
||||
value = entities(value, xtend(options, {subset: subset, attribute: true}))
|
||||
|
||||
value = quote + value + quote
|
||||
}
|
||||
|
||||
/* Don’t add a `=` for unquoted empties. */
|
||||
value = value ? EQ + value : value
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
50
node_modules/hast-util-to-html/lib/index.js
generated
vendored
Normal file
50
node_modules/hast-util-to-html/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
|
||||
var html = require('property-information/html')
|
||||
var svg = require('property-information/svg')
|
||||
var voids = require('html-void-elements')
|
||||
var omission = require('./omission')
|
||||
var one = require('./one')
|
||||
|
||||
module.exports = toHTML
|
||||
|
||||
/* Characters. */
|
||||
var DQ = '"'
|
||||
var SQ = "'"
|
||||
|
||||
/* Stringify the given HAST node. */
|
||||
function toHTML(node, options) {
|
||||
var settings = options || {}
|
||||
var quote = settings.quote || DQ
|
||||
var alternative = quote === DQ ? SQ : DQ
|
||||
var smart = settings.quoteSmart
|
||||
|
||||
if (quote !== DQ && quote !== SQ) {
|
||||
throw new Error(
|
||||
'Invalid quote `' + quote + '`, expected `' + SQ + '` or `' + DQ + '`'
|
||||
)
|
||||
}
|
||||
|
||||
return one(
|
||||
{
|
||||
valid: settings.allowParseErrors ? 0 : 1,
|
||||
safe: settings.allowDangerousCharacters ? 0 : 1,
|
||||
schema: settings.space === 'svg' ? svg : html,
|
||||
omit: settings.omitOptionalTags && omission,
|
||||
quote: quote,
|
||||
alternative: smart ? alternative : null,
|
||||
unquoted: Boolean(settings.preferUnquoted),
|
||||
tight: settings.tightAttributes,
|
||||
tightDoctype: Boolean(settings.tightDoctype),
|
||||
tightLists: settings.tightCommaSeparatedLists,
|
||||
tightClose: settings.tightSelfClosing,
|
||||
collapseEmpty: settings.collapseEmptyAttributes,
|
||||
dangerous: settings.allowDangerousHTML,
|
||||
voids: settings.voids || voids.concat(),
|
||||
entities: settings.entities || {},
|
||||
close: settings.closeSelfClosing,
|
||||
closeEmpty: settings.closeEmptyElements
|
||||
},
|
||||
node
|
||||
)
|
||||
}
|
||||
180
node_modules/hast-util-to-html/lib/omission/closing.js
generated
vendored
Normal file
180
node_modules/hast-util-to-html/lib/omission/closing.js
generated
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
'use strict'
|
||||
|
||||
var is = require('unist-util-is')
|
||||
var element = require('hast-util-is-element')
|
||||
var whiteSpaceLeft = require('./util/white-space-left')
|
||||
var after = require('./util/siblings').after
|
||||
var omission = require('./omission')
|
||||
|
||||
var optionGroup = 'optgroup'
|
||||
var options = ['option'].concat(optionGroup)
|
||||
var dataListItem = ['dt', 'dd']
|
||||
var listItem = 'li'
|
||||
var menuContent = ['menuitem', 'hr', 'menu']
|
||||
var ruby = ['rp', 'rt']
|
||||
var tableContainer = ['tbody', 'tfoot']
|
||||
var tableRow = 'tr'
|
||||
var tableCell = ['td', 'th']
|
||||
|
||||
var confusingParagraphParent = [
|
||||
'a',
|
||||
'audio',
|
||||
'del',
|
||||
'ins',
|
||||
'map',
|
||||
'noscript',
|
||||
'video'
|
||||
]
|
||||
|
||||
var clearParagraphSibling = [
|
||||
'address',
|
||||
'article',
|
||||
'aside',
|
||||
'blockquote',
|
||||
'details',
|
||||
'div',
|
||||
'dl',
|
||||
'fieldset',
|
||||
'figcaption',
|
||||
'figure',
|
||||
'footer',
|
||||
'form',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'header',
|
||||
'hgroup',
|
||||
'hr',
|
||||
'main',
|
||||
'menu',
|
||||
'nav',
|
||||
'ol',
|
||||
'p',
|
||||
'pre',
|
||||
'section',
|
||||
'table',
|
||||
'ul'
|
||||
]
|
||||
|
||||
module.exports = omission({
|
||||
html: html,
|
||||
head: headOrColgroupOrCaption,
|
||||
body: body,
|
||||
p: p,
|
||||
li: li,
|
||||
dt: dt,
|
||||
dd: dd,
|
||||
rt: rubyElement,
|
||||
rp: rubyElement,
|
||||
optgroup: optgroup,
|
||||
option: option,
|
||||
menuitem: menuitem,
|
||||
colgroup: headOrColgroupOrCaption,
|
||||
caption: headOrColgroupOrCaption,
|
||||
thead: thead,
|
||||
tbody: tbody,
|
||||
tfoot: tfoot,
|
||||
tr: tr,
|
||||
td: cells,
|
||||
th: cells
|
||||
})
|
||||
|
||||
/* Macro for `</head>`, `</colgroup>`, and `</caption>`. */
|
||||
function headOrColgroupOrCaption(node, index, parent) {
|
||||
var next = after(parent, index, true)
|
||||
return !next || (!is('comment', next) && !whiteSpaceLeft(next))
|
||||
}
|
||||
|
||||
/* Whether to omit `</html>`. */
|
||||
function html(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || !is('comment', next)
|
||||
}
|
||||
|
||||
/* Whether to omit `</body>`. */
|
||||
function body(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || !is('comment', next)
|
||||
}
|
||||
|
||||
/* Whether to omit `</p>`. */
|
||||
function p(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return next
|
||||
? element(next, clearParagraphSibling)
|
||||
: !parent || !element(parent, confusingParagraphParent)
|
||||
}
|
||||
|
||||
/* Whether to omit `</li>`. */
|
||||
function li(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, listItem)
|
||||
}
|
||||
|
||||
/* Whether to omit `</dt>`. */
|
||||
function dt(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return next && element(next, dataListItem)
|
||||
}
|
||||
|
||||
/* Whether to omit `</dd>`. */
|
||||
function dd(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, dataListItem)
|
||||
}
|
||||
|
||||
/* Whether to omit `</rt>` or `</rp>`. */
|
||||
function rubyElement(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, ruby)
|
||||
}
|
||||
|
||||
/* Whether to omit `</optgroup>`. */
|
||||
function optgroup(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, optionGroup)
|
||||
}
|
||||
|
||||
/* Whether to omit `</option>`. */
|
||||
function option(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, options)
|
||||
}
|
||||
|
||||
/* Whether to omit `</menuitem>`. */
|
||||
function menuitem(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, menuContent)
|
||||
}
|
||||
|
||||
/* Whether to omit `</thead>`. */
|
||||
function thead(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return next && element(next, tableContainer)
|
||||
}
|
||||
|
||||
/* Whether to omit `</tbody>`. */
|
||||
function tbody(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, tableContainer)
|
||||
}
|
||||
|
||||
/* Whether to omit `</tfoot>`. */
|
||||
function tfoot(node, index, parent) {
|
||||
return !after(parent, index)
|
||||
}
|
||||
|
||||
/* Whether to omit `</tr>`. */
|
||||
function tr(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, tableRow)
|
||||
}
|
||||
|
||||
/* Whether to omit `</td>` or `</th>`. */
|
||||
function cells(node, index, parent) {
|
||||
var next = after(parent, index)
|
||||
return !next || element(next, tableCell)
|
||||
}
|
||||
3
node_modules/hast-util-to-html/lib/omission/index.js
generated
vendored
Normal file
3
node_modules/hast-util-to-html/lib/omission/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
exports.opening = require('./opening')
|
||||
exports.closing = require('./closing')
|
||||
18
node_modules/hast-util-to-html/lib/omission/omission.js
generated
vendored
Normal file
18
node_modules/hast-util-to-html/lib/omission/omission.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = omission
|
||||
|
||||
var own = {}.hasOwnProperty
|
||||
|
||||
/* Factory to check if a given node can have a tag omitted. */
|
||||
function omission(handlers) {
|
||||
return omit
|
||||
|
||||
/* Check if a given node can have a tag omitted. */
|
||||
function omit(node, index, parent) {
|
||||
var name = node.tagName
|
||||
var fn = own.call(handlers, name) ? handlers[name] : false
|
||||
|
||||
return fn ? fn(node, index, parent) : false
|
||||
}
|
||||
}
|
||||
98
node_modules/hast-util-to-html/lib/omission/opening.js
generated
vendored
Normal file
98
node_modules/hast-util-to-html/lib/omission/opening.js
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
'use strict'
|
||||
|
||||
var is = require('unist-util-is')
|
||||
var element = require('hast-util-is-element')
|
||||
var before = require('./util/siblings').before
|
||||
var first = require('./util/first')
|
||||
var place = require('./util/place')
|
||||
var whiteSpaceLeft = require('./util/white-space-left')
|
||||
var closing = require('./closing')
|
||||
var omission = require('./omission')
|
||||
|
||||
var own = {}.hasOwnProperty
|
||||
|
||||
var uniqueHeadMetadata = ['title', 'base']
|
||||
var meta = ['meta', 'link', 'script', 'style', 'template']
|
||||
var tableContainers = ['thead', 'tbody']
|
||||
var tableRow = 'tr'
|
||||
|
||||
module.exports = omission({
|
||||
html: html,
|
||||
head: head,
|
||||
body: body,
|
||||
colgroup: colgroup,
|
||||
tbody: tbody
|
||||
})
|
||||
|
||||
/* Whether to omit `<html>`. */
|
||||
function html(node) {
|
||||
var head = first(node)
|
||||
return !head || !is('comment', head)
|
||||
}
|
||||
|
||||
/* Whether to omit `<head>`. */
|
||||
function head(node) {
|
||||
var children = node.children
|
||||
var length = children.length
|
||||
var map = {}
|
||||
var index = -1
|
||||
var child
|
||||
var name
|
||||
|
||||
while (++index < length) {
|
||||
child = children[index]
|
||||
name = child.tagName
|
||||
|
||||
if (element(child, uniqueHeadMetadata)) {
|
||||
if (own.call(map, name)) {
|
||||
return false
|
||||
}
|
||||
|
||||
map[name] = true
|
||||
}
|
||||
}
|
||||
|
||||
return Boolean(length)
|
||||
}
|
||||
|
||||
/* Whether to omit `<body>`. */
|
||||
function body(node) {
|
||||
var head = first(node, true)
|
||||
|
||||
return (
|
||||
!head ||
|
||||
(!is('comment', head) && !whiteSpaceLeft(head) && !element(head, meta))
|
||||
)
|
||||
}
|
||||
|
||||
/* Whether to omit `<colgroup>`.
|
||||
* The spec describes some logic for the opening tag,
|
||||
* but it’s easier to implement in the closing tag, to
|
||||
* the same effect, so we handle it there instead. */
|
||||
function colgroup(node, index, parent) {
|
||||
var prev = before(parent, index)
|
||||
var head = first(node, true)
|
||||
|
||||
/* Previous colgroup was already omitted. */
|
||||
if (element(prev, 'colgroup') && closing(prev, place(parent, prev), parent)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return head && element(head, 'col')
|
||||
}
|
||||
|
||||
/* Whether to omit `<tbody>`. */
|
||||
function tbody(node, index, parent) {
|
||||
var prev = before(parent, index)
|
||||
var head = first(node)
|
||||
|
||||
/* Previous table section was already omitted. */
|
||||
if (
|
||||
element(prev, tableContainers) &&
|
||||
closing(prev, place(parent, prev), parent)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
return head && element(head, tableRow)
|
||||
}
|
||||
10
node_modules/hast-util-to-html/lib/omission/util/first.js
generated
vendored
Normal file
10
node_modules/hast-util-to-html/lib/omission/util/first.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
var after = require('./siblings').after
|
||||
|
||||
module.exports = first
|
||||
|
||||
/* Get the first child in `parent`. */
|
||||
function first(parent, includeWhiteSpace) {
|
||||
return after(parent, -1, includeWhiteSpace)
|
||||
}
|
||||
8
node_modules/hast-util-to-html/lib/omission/util/place.js
generated
vendored
Normal file
8
node_modules/hast-util-to-html/lib/omission/util/place.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = place
|
||||
|
||||
/* Get the position of `node` in `parent`. */
|
||||
function place(parent, child) {
|
||||
return parent && parent.children && parent.children.indexOf(child)
|
||||
}
|
||||
29
node_modules/hast-util-to-html/lib/omission/util/siblings.js
generated
vendored
Normal file
29
node_modules/hast-util-to-html/lib/omission/util/siblings.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
var whiteSpace = require('hast-util-whitespace')
|
||||
|
||||
exports.before = siblings(-1)
|
||||
exports.after = siblings(1)
|
||||
|
||||
/* Factory to check siblings in a direction. */
|
||||
function siblings(increment) {
|
||||
return sibling
|
||||
|
||||
/* Find applicable siblings in a direction. */
|
||||
function sibling(parent, index, includeWhiteSpace) {
|
||||
var siblings = parent && parent.children
|
||||
var next
|
||||
|
||||
index += increment
|
||||
next = siblings && siblings[index]
|
||||
|
||||
if (!includeWhiteSpace) {
|
||||
while (next && whiteSpace(next)) {
|
||||
index += increment
|
||||
next = siblings[index]
|
||||
}
|
||||
}
|
||||
|
||||
return next
|
||||
}
|
||||
}
|
||||
11
node_modules/hast-util-to-html/lib/omission/util/white-space-left.js
generated
vendored
Normal file
11
node_modules/hast-util-to-html/lib/omission/util/white-space-left.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
var is = require('unist-util-is')
|
||||
var whiteSpace = require('hast-util-whitespace')
|
||||
|
||||
module.exports = whiteSpaceLeft
|
||||
|
||||
/* Check if `node` starts with white-space. */
|
||||
function whiteSpaceLeft(node) {
|
||||
return is('text', node) && whiteSpace(node.value.charAt(0))
|
||||
}
|
||||
29
node_modules/hast-util-to-html/lib/one.js
generated
vendored
Normal file
29
node_modules/hast-util-to-html/lib/one.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = one
|
||||
|
||||
var own = {}.hasOwnProperty
|
||||
|
||||
var handlers = {}
|
||||
|
||||
handlers.root = require('./all')
|
||||
handlers.text = require('./text')
|
||||
handlers.element = require('./element')
|
||||
handlers.doctype = require('./doctype')
|
||||
handlers.comment = require('./comment')
|
||||
handlers.raw = require('./raw')
|
||||
|
||||
/* Stringify `node`. */
|
||||
function one(ctx, node, index, parent) {
|
||||
var type = node && node.type
|
||||
|
||||
if (!type) {
|
||||
throw new Error('Expected node, not `' + node + '`')
|
||||
}
|
||||
|
||||
if (!own.call(handlers, type)) {
|
||||
throw new Error('Cannot compile unknown node `' + type + '`')
|
||||
}
|
||||
|
||||
return handlers[type](ctx, node, index, parent)
|
||||
}
|
||||
10
node_modules/hast-util-to-html/lib/raw.js
generated
vendored
Normal file
10
node_modules/hast-util-to-html/lib/raw.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
var text = require('./text')
|
||||
|
||||
module.exports = raw
|
||||
|
||||
/* Stringify `raw`. */
|
||||
function raw(ctx, node) {
|
||||
return ctx.dangerous ? node.value : text(ctx, node)
|
||||
}
|
||||
20
node_modules/hast-util-to-html/lib/text.js
generated
vendored
Normal file
20
node_modules/hast-util-to-html/lib/text.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
'use strict'
|
||||
|
||||
var xtend = require('xtend')
|
||||
var entities = require('stringify-entities')
|
||||
|
||||
module.exports = text
|
||||
|
||||
/* Stringify `text`. */
|
||||
function text(ctx, node, index, parent) {
|
||||
var value = node.value
|
||||
|
||||
return isLiteral(parent)
|
||||
? value
|
||||
: entities(value, xtend(ctx.entities, {subset: ['<', '&']}))
|
||||
}
|
||||
|
||||
/* Check if content of `node` should be escaped. */
|
||||
function isLiteral(node) {
|
||||
return node && (node.tagName === 'script' || node.tagName === 'style')
|
||||
}
|
||||
117
node_modules/hast-util-to-html/node_modules/unist-util-is/index.js
generated
vendored
Normal file
117
node_modules/hast-util-to-html/node_modules/unist-util-is/index.js
generated
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = is
|
||||
|
||||
// Assert if `test` passes for `node`. When a `parent` node is known the
|
||||
// `index` of node.
|
||||
// eslint-disable-next-line max-params
|
||||
function is(test, node, index, parent, context) {
|
||||
var hasParent = parent !== null && parent !== undefined
|
||||
var hasIndex = index !== null && index !== undefined
|
||||
var check = convert(test)
|
||||
|
||||
if (
|
||||
hasIndex &&
|
||||
(typeof index !== 'number' || index < 0 || index === Infinity)
|
||||
) {
|
||||
throw new Error('Expected positive finite index or child node')
|
||||
}
|
||||
|
||||
if (hasParent && (!is(null, parent) || !parent.children)) {
|
||||
throw new Error('Expected parent node')
|
||||
}
|
||||
|
||||
if (!node || !node.type || typeof node.type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (hasParent !== hasIndex) {
|
||||
throw new Error('Expected both parent and index')
|
||||
}
|
||||
|
||||
return Boolean(check.call(context, node, index, parent))
|
||||
}
|
||||
|
||||
function convert(test) {
|
||||
if (typeof test === 'string') {
|
||||
return typeFactory(test)
|
||||
}
|
||||
|
||||
if (test === null || test === undefined) {
|
||||
return ok
|
||||
}
|
||||
|
||||
if (typeof test === 'object') {
|
||||
return ('length' in test ? anyFactory : matchesFactory)(test)
|
||||
}
|
||||
|
||||
if (typeof test === 'function') {
|
||||
return test
|
||||
}
|
||||
|
||||
throw new Error('Expected function, string, or object as test')
|
||||
}
|
||||
|
||||
function convertAll(tests) {
|
||||
var results = []
|
||||
var length = tests.length
|
||||
var index = -1
|
||||
|
||||
while (++index < length) {
|
||||
results[index] = convert(tests[index])
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
// Utility assert each property in `test` is represented in `node`, and each
|
||||
// values are strictly equal.
|
||||
function matchesFactory(test) {
|
||||
return matches
|
||||
|
||||
function matches(node) {
|
||||
var key
|
||||
|
||||
for (key in test) {
|
||||
if (node[key] !== test[key]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
function anyFactory(tests) {
|
||||
var checks = convertAll(tests)
|
||||
var length = checks.length
|
||||
|
||||
return matches
|
||||
|
||||
function matches() {
|
||||
var index = -1
|
||||
|
||||
while (++index < length) {
|
||||
if (checks[index].apply(this, arguments)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Utility to convert a string into a function which checks a given node’s type
|
||||
// for said string.
|
||||
function typeFactory(test) {
|
||||
return type
|
||||
|
||||
function type(node) {
|
||||
return Boolean(node && node.type === test)
|
||||
}
|
||||
}
|
||||
|
||||
// Utility to return true.
|
||||
function ok() {
|
||||
return true
|
||||
}
|
||||
22
node_modules/hast-util-to-html/node_modules/unist-util-is/license
generated
vendored
Normal file
22
node_modules/hast-util-to-html/node_modules/unist-util-is/license
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT license)
|
||||
|
||||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
113
node_modules/hast-util-to-html/node_modules/unist-util-is/package.json
generated
vendored
Normal file
113
node_modules/hast-util-to-html/node_modules/unist-util-is/package.json
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
{
|
||||
"_from": "unist-util-is@^2.0.0",
|
||||
"_id": "unist-util-is@2.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-4WbQX2iwfr/+PfM4U3zd2VNXY+dWtZsN1fLnWEi2QQXA4qyDYAZcDMfXUX0Cu6XZUHHAO9q4nyxxLT4Awk1qUA==",
|
||||
"_location": "/hast-util-to-html/unist-util-is",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "unist-util-is@^2.0.0",
|
||||
"name": "unist-util-is",
|
||||
"escapedName": "unist-util-is",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/hast-util-to-html"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.3.tgz",
|
||||
"_shasum": "459182db31f4742fceaea88d429693cbf0043d20",
|
||||
"_spec": "unist-util-is@^2.0.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/hast-util-to-html",
|
||||
"author": {
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/syntax-tree/hast-util-to-html/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "https://wooorm.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Utility to check if a node passes a test",
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^14.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark-cli": "^6.0.0",
|
||||
"remark-preset-wooorm": "^5.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/syntax-tree/unist-util-is#readme",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"node",
|
||||
"is",
|
||||
"equal",
|
||||
"test",
|
||||
"type",
|
||||
"util",
|
||||
"utility"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "unist-util-is",
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/syntax-tree/unist-util-is.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"build-bundle": "browserify . -s unistUtilIs > unist-util-is.js",
|
||||
"build-mangle": "browserify . -s unistUtilIs -p tinyify > unist-util-is.min.js",
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"test": "npm run format && npm run build && npm run test-coverage",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js"
|
||||
},
|
||||
"version": "2.1.3",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"rules": {
|
||||
"unicorn/prefer-type-error": "off"
|
||||
},
|
||||
"ignore": [
|
||||
"unist-util-is.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
167
node_modules/hast-util-to-html/node_modules/unist-util-is/readme.md
generated
vendored
Normal file
167
node_modules/hast-util-to-html/node_modules/unist-util-is/readme.md
generated
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
# unist-util-is
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[**unist**][unist] utility to check if a node passes a test.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install unist-util-is
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var is = require('unist-util-is')
|
||||
|
||||
var node = {type: 'strong'}
|
||||
var parent = {type: 'paragraph', children: [node]}
|
||||
|
||||
function test(node, n) {
|
||||
return n === 5
|
||||
}
|
||||
|
||||
is() // => false
|
||||
is(null, {children: []}) // => false
|
||||
is(null, node) // => true
|
||||
is('strong', node) // => true
|
||||
is('emphasis', node) // => false
|
||||
|
||||
is(node, node) // => true
|
||||
is({type: 'paragraph'}, parent) // => true
|
||||
is({type: 'strong'}, parent) // => false
|
||||
|
||||
is(test, node) // => false
|
||||
is(test, node, 4, parent) // => false
|
||||
is(test, node, 5, parent) // => true
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `is(test, node[, index, parent[, context]])`
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `test` ([`Function`][test], `string`, `Object`, or `Array.<Test>`, optional)
|
||||
— When not given, checks if `node` is a [`Node`][node].
|
||||
When `string`, works like passing `node => node.type === test`.
|
||||
When `array`, checks if any one of the subtests pass.
|
||||
When `object`, checks that all keys in `test` are in `node`,
|
||||
and that they have strictly equal values
|
||||
* `node` ([`Node`][node]) — Node to check. `false` is returned
|
||||
* `index` (`number`, optional) — [Index][] of `node` in `parent`
|
||||
* `parent` ([`Node`][node], optional) — [Parent][] of `node`
|
||||
* `context` (`*`, optional) — Context object to invoke `test` with
|
||||
|
||||
###### Returns
|
||||
|
||||
`boolean` — Whether `test` passed *and* `node` is a [`Node`][node] (object
|
||||
with `type` set to a non-empty `string`).
|
||||
|
||||
#### `function test(node[, index, parent])`
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `node` (`Node`) — Node to test
|
||||
* `index` (`number?`) — Position of `node` in `parent`
|
||||
* `parent` (`Node?`) — Parent of `node`
|
||||
|
||||
###### Context
|
||||
|
||||
`*` — The to `is` given `context`.
|
||||
|
||||
###### Returns
|
||||
|
||||
`boolean?` — Whether `node` matches.
|
||||
|
||||
## Related
|
||||
|
||||
* [`unist-util-find-after`](https://github.com/syntax-tree/unist-util-find-after)
|
||||
— Find a node after another node
|
||||
* [`unist-util-find-before`](https://github.com/syntax-tree/unist-util-find-before)
|
||||
— Find a node before another node
|
||||
* [`unist-util-find-all-after`](https://github.com/syntax-tree/unist-util-find-all-after)
|
||||
— Find all nodes after another node
|
||||
* [`unist-util-find-all-before`](https://github.com/syntax-tree/unist-util-find-all-before)
|
||||
— Find all nodes before another node
|
||||
* [`unist-util-find-all-between`](https://github.com/mrzmmr/unist-util-find-all-between)
|
||||
— Find all nodes between two nodes
|
||||
* [`unist-util-find`](https://github.com/blahah/unist-util-find)
|
||||
— Find nodes matching a predicate
|
||||
* [`unist-util-filter`](https://github.com/eush77/unist-util-filter)
|
||||
— Create a new tree with nodes that pass a check
|
||||
* [`unist-util-remove`](https://github.com/eush77/unist-util-remove)
|
||||
— Remove nodes from tree
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
|
||||
started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [Code of Conduct][coc].
|
||||
By interacting with this repository, organisation, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-is.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/unist-util-is
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-is.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-is
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-is.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/unist-util-is
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-is.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=unist-util-is
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
|
||||
|
||||
[chat]: https://spectrum.chat/unified/syntax-tree
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
|
||||
|
||||
[unist]: https://github.com/syntax-tree/unist
|
||||
|
||||
[node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[parent]: https://github.com/syntax-tree/unist#parent-1
|
||||
|
||||
[index]: https://github.com/syntax-tree/unist#index
|
||||
|
||||
[test]: #function-testnode-index-parent
|
||||
124
node_modules/hast-util-to-html/package.json
generated
vendored
Normal file
124
node_modules/hast-util-to-html/package.json
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
{
|
||||
"_from": "hast-util-to-html@^4.0.0",
|
||||
"_id": "hast-util-to-html@4.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-2emzwyf0xEsc4TBIPmDJmBttIw8R4SXAJiJZoiRR/s47ODYWgOqNoDbf2SJAbMbfNdFWMiCSOrI3OVnX6Qq2Mg==",
|
||||
"_location": "/hast-util-to-html",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "hast-util-to-html@^4.0.0",
|
||||
"name": "hast-util-to-html",
|
||||
"escapedName": "hast-util-to-html",
|
||||
"rawSpec": "^4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gatsby-transformer-remark"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-4.0.1.tgz",
|
||||
"_shasum": "3666b05afb62bd69f8f5e6c94db04dea19438e2a",
|
||||
"_spec": "hast-util-to-html@^4.0.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby-transformer-remark",
|
||||
"author": {
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "http://wooorm.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/syntax-tree/hast-util-to-html/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Titus Wormer",
|
||||
"email": "tituswormer@gmail.com",
|
||||
"url": "http://wooorm.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"ccount": "^1.0.0",
|
||||
"comma-separated-tokens": "^1.0.1",
|
||||
"hast-util-is-element": "^1.0.0",
|
||||
"hast-util-whitespace": "^1.0.0",
|
||||
"html-void-elements": "^1.0.0",
|
||||
"property-information": "^4.0.0",
|
||||
"space-separated-tokens": "^1.0.0",
|
||||
"stringify-entities": "^1.0.1",
|
||||
"unist-util-is": "^2.0.0",
|
||||
"xtend": "^4.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Transform HAST to HTML",
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"hastscript": "^4.0.0",
|
||||
"nyc": "^12.0.0",
|
||||
"prettier": "^1.13.5",
|
||||
"remark-cli": "^5.0.0",
|
||||
"remark-preset-wooorm": "^4.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.4.3",
|
||||
"unist-builder": "^1.0.1",
|
||||
"xo": "^0.21.0"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/syntax-tree/hast-util-to-html#readme",
|
||||
"keywords": [
|
||||
"hast",
|
||||
"util",
|
||||
"html"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "hast-util-to-html",
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/syntax-tree/hast-util-to-html.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"build-bundle": "browserify index.js -s hastUtilToHTML > hast-util-to-html.js",
|
||||
"build-mangle": "browserify index.js -p tinyify -s hastUtilToHTML > hast-util-to-html.min.js",
|
||||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
|
||||
"test": "npm run format && npm run build && npm run test-coverage",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test"
|
||||
},
|
||||
"version": "4.0.1",
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"rules": {
|
||||
"guard-for-in": "off",
|
||||
"eqeqeq": "off",
|
||||
"no-eq-null": "off"
|
||||
},
|
||||
"ignores": [
|
||||
"hast-util-to-html.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
203
node_modules/hast-util-to-html/readme.md
generated
vendored
Normal file
203
node_modules/hast-util-to-html/readme.md
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
# hast-util-to-html [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
|
||||
|
||||
Transform [HAST][] to HTML.
|
||||
|
||||
## Installation
|
||||
|
||||
[npm][]:
|
||||
|
||||
```bash
|
||||
npm install hast-util-to-html
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var h = require('hastscript')
|
||||
var toHTML = require('hast-util-to-html')
|
||||
|
||||
var tree = h('.alpha', [
|
||||
'bravo ',
|
||||
h('b', 'charlie'),
|
||||
' delta ',
|
||||
h('a.echo', {download: true}, 'foxtrot')
|
||||
])
|
||||
|
||||
console.log(toHTML(tree))
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```html
|
||||
<div class="alpha">bravo <b>charlie</b> delta <a class="echo" download>foxtrot</a></div>
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `toHTML(tree[, options])`
|
||||
|
||||
Stringify the given [HAST tree][hast].
|
||||
|
||||
###### `options.space`
|
||||
|
||||
Whether the root of the given tree is in the `'html'` or `'svg'` space (enum,
|
||||
`'svg'` or `'html'`, default: `'html'`).
|
||||
|
||||
If an `svg` element is found in the HTML space, `toHTML` automatically switches
|
||||
to the SVG space when entering the element, and switches back when leaving.
|
||||
|
||||
###### `options.entities`
|
||||
|
||||
Configuration for [`stringify-entities`][stringify-entities]
|
||||
(`Object`, default: `{}`). Do not use `escapeOnly`, `attribute`, or
|
||||
`subset` (`toHTML` already passes those). However, `useNamedReferences`,
|
||||
`useShortestReferences`, and `omitOptionalSemicolons` are all fine.
|
||||
|
||||
###### `options.voids`
|
||||
|
||||
Tag-names of elements to stringify without closing tag (`Array.<string>`,
|
||||
default: [`html-void-elements`][html-void-elements]).
|
||||
|
||||
Not used in the SVG space.
|
||||
|
||||
###### `options.quote`
|
||||
|
||||
Preferred quote to use (`'"'` or `'\''`, default: `'"'`).
|
||||
|
||||
###### `options.quoteSmart`
|
||||
|
||||
Use the other quote if that results in less bytes (`boolean`, default:
|
||||
`false`).
|
||||
|
||||
###### `options.preferUnquoted`
|
||||
|
||||
Leave attributes unquoted if that results in less bytes (`boolean`,
|
||||
default: `false`).
|
||||
|
||||
Not used in the SVG space.
|
||||
|
||||
###### `options.omitOptionalTags`
|
||||
|
||||
Omit optional opening and closing tags (`boolean`, default: `false`).
|
||||
For example, in `<ol><li>one</li><li>two</li></ol>`, both `</li>`
|
||||
closing tags can be omitted. The first because it’s followed by
|
||||
another `li`, the last because it’s followed by nothing.
|
||||
|
||||
Not used in the SVG space.
|
||||
|
||||
###### `options.collapseEmptyAttributes`
|
||||
|
||||
Collapse empty attributes: `class=""` is stringified as `class` instead
|
||||
(`boolean`, default: `false`). **Note**: boolean attributes, such as
|
||||
`hidden`, are always collapsed.
|
||||
|
||||
Not used in the SVG space.
|
||||
|
||||
###### `options.closeSelfClosing`
|
||||
|
||||
Close self-closing nodes with an extra slash (`/`): `<img />` instead of
|
||||
`<img>` (`boolean`, default: `false`).
|
||||
|
||||
Not used in the SVG space.
|
||||
|
||||
###### `options.closeEmptyElements`
|
||||
|
||||
Close SVG elements without any content with slash (`/`) on the opening tag
|
||||
instead of an end tag: `<circle />` instead of `<circle></circle>` (`boolean`,
|
||||
default: `false`).
|
||||
|
||||
Not used in the HTML space.
|
||||
|
||||
###### `options.tightSelfClosing`
|
||||
|
||||
Do not use an extra space when closing self-closing elements: `<img/>`
|
||||
instead of `<img />` (`boolean`, default: `false`). **Note**: Only used
|
||||
if `closeSelfClosing: true` or `closeEmptyElements: true`.
|
||||
|
||||
###### `options.tightCommaSeparatedLists`
|
||||
|
||||
Join known comma-separated attribute values with just a comma (`,`),
|
||||
instead of padding them on the right as well (`,·`, where `·` represents a
|
||||
space) (`boolean`, default: `false`).
|
||||
|
||||
###### `options.tightAttributes`
|
||||
|
||||
Join attributes together, without white-space, if possible:
|
||||
`class="a b" title="c d"` is stringified as `class="a b"title="c d"`
|
||||
instead to save bytes (`boolean`, default: `false`). **Note**: creates
|
||||
invalid (but working) markup.
|
||||
|
||||
Not used in the SVG space.
|
||||
|
||||
###### `options.tightDoctype`
|
||||
|
||||
Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of `<!doctype html>`
|
||||
to save bytes (`boolean`, default: `false`). **Note**: creates
|
||||
invalid (but working) markup.
|
||||
|
||||
###### `options.allowParseErrors`
|
||||
|
||||
Do not encode characters which trigger parse errors (even though they
|
||||
work), to save bytes (`boolean`, default: `false`). **Note**: creates
|
||||
invalid (but working) markup.
|
||||
|
||||
Not used in the SVG space.
|
||||
|
||||
###### `options.allowDangerousCharacters`
|
||||
|
||||
Do not encode some characters which cause XSS vulnerabilities in older
|
||||
browsers (`boolean`, default: `false`). **Note**: Only set this if you
|
||||
completely trust the content.
|
||||
|
||||
###### `options.allowDangerousHTML`
|
||||
|
||||
Allow `raw` nodes and insert them as raw HTML. When falsey, encodes
|
||||
`raw` nodes (`boolean`, default: `false`). **Note**: Only set this if
|
||||
you completely trust the content.
|
||||
|
||||
## Related
|
||||
|
||||
* [`hast-util-sanitize`][hast-util-sanitize]
|
||||
— Sanitize HAST nodes
|
||||
* [`rehype-stringify`](https://github.com/wooorm/rehype/tree/master/packages/rehype-stringify)
|
||||
— Wrapper around this project for [**rehype**](https://github.com/wooorm/rehype)
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md` in `syntax-tree/hast`][contributing] for ways to get
|
||||
started.
|
||||
|
||||
This organisation has a [Code of Conduct][coc]. By interacting with this
|
||||
repository, organisation, or community you agree to abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[travis-badge]: https://img.shields.io/travis/syntax-tree/hast-util-to-html.svg
|
||||
|
||||
[travis]: https://travis-ci.org/syntax-tree/hast-util-to-html
|
||||
|
||||
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-html.svg
|
||||
|
||||
[codecov]: https://codecov.io/github/syntax-tree/hast-util-to-html
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: LICENSE
|
||||
|
||||
[author]: http://wooorm.com
|
||||
|
||||
[hast]: https://github.com/syntax-tree/hast
|
||||
|
||||
[html-void-elements]: https://github.com/wooorm/html-void-elements
|
||||
|
||||
[stringify-entities]: https://github.com/wooorm/stringify-entities
|
||||
|
||||
[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/hast/blob/master/contributing.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
|
||||
Reference in New Issue
Block a user