|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
708 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | const utils = require('./utils');
|
|---|
| 4 |
|
|---|
| 5 | module.exports = (ast, options = {}) => {
|
|---|
| 6 | const stringify = (node, parent = {}) => {
|
|---|
| 7 | const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
|---|
| 8 | const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|---|
| 9 | let output = '';
|
|---|
| 10 |
|
|---|
| 11 | if (node.value) {
|
|---|
| 12 | if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
|
|---|
| 13 | return '\\' + node.value;
|
|---|
| 14 | }
|
|---|
| 15 | return node.value;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | if (node.value) {
|
|---|
| 19 | return node.value;
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | if (node.nodes) {
|
|---|
| 23 | for (const child of node.nodes) {
|
|---|
| 24 | output += stringify(child);
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
| 27 | return output;
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | return stringify(ast);
|
|---|
| 31 | };
|
|---|
| 32 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.