UNPKG

802 BJavaScriptView Raw
1'use strict';
2
3module.exports = function () {
4 var state = {};
5
6 return {
7 definitionVisitor: function definitionVisitor() {
8 return function (node, index, parent) {
9 var identifier = node.identifier;
10 while (Object.keys(state).includes(identifier)) {
11 identifier += '-1';
12 }
13
14 state[identifier] = node.url;
15 node.identifier = identifier; // force to remove twice so that latex compiles
16
17 if (node.referenceType === 'shortcut') {
18 // remark for abbr
19 parent.children.splice(index, 1);
20 }
21 };
22 },
23 imageReferenceVisitor: function imageReferenceVisitor() {
24 return function (node) {
25 node.type = 'image';
26 node.title = '';
27 node.url = state[node.identifier];
28 };
29 }
30 };
31};
\No newline at end of file