This commit is contained in:
30
node_modules/mdast-util-to-string/index.js
generated
vendored
Normal file
30
node_modules/mdast-util-to-string/index.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = toString
|
||||
|
||||
// Get the text content of a node.
|
||||
// Prefer the node’s plain-text fields, otherwise serialize its children,
|
||||
// and if the given value is an array, serialize the nodes in it.
|
||||
function toString(node) {
|
||||
return (
|
||||
(node &&
|
||||
(node.value ||
|
||||
node.alt ||
|
||||
node.title ||
|
||||
('children' in node && all(node.children)) ||
|
||||
('length' in node && all(node)))) ||
|
||||
''
|
||||
)
|
||||
}
|
||||
|
||||
function all(values) {
|
||||
var result = []
|
||||
var length = values.length
|
||||
var index = -1
|
||||
|
||||
while (++index < length) {
|
||||
result[index] = toString(values[index])
|
||||
}
|
||||
|
||||
return result.join('')
|
||||
}
|
||||
Reference in New Issue
Block a user