(node, path = '')
| 237 | } |
| 238 | |
| 239 | function buildPath(node, path = '') { |
| 240 | const tag = node.nodeName |
| 241 | let attributes = '' |
| 242 | |
| 243 | if (node.attrs) { |
| 244 | attributes = node.attrs.map(attr => `${attr.name}="${attr.value}"`).join(' ') |
| 245 | } |
| 246 | |
| 247 | if (!tag.startsWith('#') && tag !== 'body' && tag !== 'html') { |
| 248 | path += `<${node.nodeName}${node.attrs ? ` ${attributes}` : ''}>` |
| 249 | } |
| 250 | |
| 251 | if (!node.childNodes) return path |
| 252 | |
| 253 | const children = node.childNodes.filter(child => !child.nodeName.startsWith('#')) |
| 254 | |
| 255 | if (children.length) { |
| 256 | return buildPath(children[children.length - 1], path) |
| 257 | } |
| 258 | return path |
| 259 | } |
| 260 | |
| 261 | function splitByChunks(text, chunkSize) { |
| 262 | chunkSize -= 20 |
no test coverage detected
searching dependent graphs…