enter-link-reference.js 767 B

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. var returner = require('./returner');
  3. module.exports = enter;
  4. /* Shortcut and collapsed link references need no escaping
  5. * and encoding during the processing of child nodes (it
  6. * must be implied from identifier).
  7. *
  8. * This toggler turns encoding and escaping off for shortcut
  9. * and collapsed references.
  10. *
  11. * Implies `enterLink`.
  12. */
  13. function enter(compiler, node) {
  14. var encode = compiler.encode;
  15. var escape = compiler.escape;
  16. var exit = compiler.enterLink();
  17. if (
  18. node.referenceType !== 'shortcut' &&
  19. node.referenceType !== 'collapsed'
  20. ) {
  21. return exit;
  22. }
  23. compiler.escape = returner;
  24. compiler.encode = returner;
  25. return function () {
  26. compiler.encode = encode;
  27. compiler.escape = escape;
  28. exit();
  29. };
  30. }