19 lines
No EOL
491 B
JavaScript
19 lines
No EOL
491 B
JavaScript
import { openers } from "./parser.mjs";
|
|
|
|
function unparser(data) {
|
|
if (data.str) return data.str;
|
|
let output = data.args.map(x => unparser(x, false)).join('\n');
|
|
|
|
let ctx = data.context;
|
|
|
|
if (data.op != '[') output = output.replaceAll(/^/gm,' ');
|
|
|
|
let context = (ctx) ? `${ctx.trim()} ` : '';
|
|
|
|
if (data.op == '[') return `${context}${data.op}${output}${openers[data.op]}`;
|
|
return `${context}${data.op}\n${output}\n${openers[data.op]}`;
|
|
}
|
|
|
|
export {
|
|
unparser
|
|
}; |