Sha256: 0fe2b2c2fa69118a3eefdc6fb2254199880bcbea1d5d9551331987b70c2978e2
Contents?: true
Size: 836 Bytes
Versions: 19
Compression:
Stored size: 836 Bytes
Contents
Tools = require '../_tools' module.exports = class Tools.Referencer constructor: (@environment) -> resolve: (text, replacer) -> # Make curly braces within code blocks undetectable text = text.replace /\`[^\`]*\`/mg, (match) -> match.replace(/\{/mg, "\u0091").replace(/\}/mg, "\u0092") # Search for references and replace them text = text.replace /\{([^\}]*)\}/gm, (match, link) => link = link.split(' ') href = link.shift() label = link.join(' ') replacement = @environment.reference(href) if replacement != href || /\:\/\/\w+((\:\d+)?\/\S*)?/.test(href) replacer replacement, label || href else match # Restore curly braces within code blocks text = text.replace /\`[^\`]*\`/mg, (match) -> match.replace(/\u0091/mg, '{').replace(/\u0092/mg, '}')
Version data entries
19 entries across 19 versions & 1 rubygems