1234567891011121314151617181920212223242526 |
- module.exports = formatLinkAsAutolink
- var toString = require('mdast-util-to-string')
- function formatLinkAsAutolink(node, context) {
- var raw = toString(node)
- return (
- !context.options.resourceLink &&
-
- node.url &&
-
- !node.title &&
-
- node.children &&
- node.children.length === 1 &&
- node.children[0].type === 'text' &&
-
- (raw === node.url || 'mailto:' + raw === node.url) &&
-
- /^[a-z][a-z+.-]+:/i.test(node.url) &&
-
-
- !/[\0- <>\u007F]/.test(node.url)
- )
- }
|