Files
coopgo/node_modules/mdast-util-to-string/index.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

31 lines
637 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict'
module.exports = toString
// Get the text content of a node.
// Prefer the nodes 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('')
}