Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SyntaxTreeToXML
/** Convert a CodeMirror Syntax Tree to an XML-like string */
function treeToXML(tree: Tree): string {
let t = "";
tree.iterate({
enter(type) { t += "<" + type.name + ">"; },
leave(type) { t += "</" + type.name + ">"; }
});
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment