Files
30-seconds-of-code/node_modules/remark-stringify/lib/util/enter-link-reference.js
2019-08-20 15:52:05 +02:00

37 lines
767 B
JavaScript

'use strict';
var returner = require('./returner');
module.exports = enter;
/* Shortcut and collapsed link references need no escaping
* and encoding during the processing of child nodes (it
* must be implied from identifier).
*
* This toggler turns encoding and escaping off for shortcut
* and collapsed references.
*
* Implies `enterLink`.
*/
function enter(compiler, node) {
var encode = compiler.encode;
var escape = compiler.escape;
var exit = compiler.enterLink();
if (
node.referenceType !== 'shortcut' &&
node.referenceType !== 'collapsed'
) {
return exit;
}
compiler.escape = returner;
compiler.encode = returner;
return function () {
compiler.encode = encode;
compiler.escape = escape;
exit();
};
}