mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
33 lines
700 B
JavaScript
33 lines
700 B
JavaScript
|
'use strict';
|
||
|
|
||
|
const utils = require('./utils');
|
||
|
|
||
|
module.exports = (ast, options = {}) => {
|
||
|
let stringify = (node, parent = {}) => {
|
||
|
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
||
|
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||
|
let output = '';
|
||
|
|
||
|
if (node.value) {
|
||
|
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
|
||
|
return '\\' + node.value;
|
||
|
}
|
||
|
return node.value;
|
||
|
}
|
||
|
|
||
|
if (node.value) {
|
||
|
return node.value;
|
||
|
}
|
||
|
|
||
|
if (node.nodes) {
|
||
|
for (let child of node.nodes) {
|
||
|
output += stringify(child);
|
||
|
}
|
||
|
}
|
||
|
return output;
|
||
|
};
|
||
|
|
||
|
return stringify(ast);
|
||
|
};
|
||
|
|