Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created April 5, 2022 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruJu/cb969838c9deccd0336d288a9fcaedff to your computer and use it in GitHub Desktop.
Save BruJu/cb969838c9deccd0336d288a9fcaedff to your computer and use it in GitHub Desktop.
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