UNPKG

1.72 kBJavaScriptView Raw
1/*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15'use strict';
16
17const { getAttr } = require('@accordproject/markdown-common').CommonMarkUtils;
18const NS_PREFIX_CiceroMarkModel = require('./externalModels/CiceroMarkModel').NS_PREFIX_CiceroMarkModel;
19
20// Inline rules
21const formulaRule = {
22 tag: NS_PREFIX_CiceroMarkModel + 'Formula',
23 leaf: true,
24 open: false,
25 close: false,
26 enter: (node,token,callback) => {
27 node.name = getAttr(token.attrs,'name',null);
28 node.value = token.content;
29 node.dependencies = [];
30 },
31 skipEmpty: false,
32};
33
34// Block rules
35const clauseOpenRule = {
36 tag: NS_PREFIX_CiceroMarkModel + 'Clause',
37 leaf: false,
38 open: true,
39 close: false,
40 enter: (node,token,callback) => {
41 node.name = getAttr(token.attrs,'name',null);
42 node.src = getAttr(token.attrs,'src',null);
43 },
44};
45const clauseCloseRule = {
46 tag: NS_PREFIX_CiceroMarkModel + 'Clause',
47 leaf: false,
48 open: false,
49 close: true,
50};
51
52const rules = { inlines: {}, blocks: {} };
53rules.inlines.formula = formulaRule;
54
55rules.blocks.block_clause_open = clauseOpenRule;
56rules.blocks.block_clause_close = clauseCloseRule;
57
58module.exports = rules;