Created
April 5, 2022 09:12
-
-
Save BruJu/cb969838c9deccd0336d288a9fcaedff to your computer and use it in GitHub Desktop.
SyntaxTreeToXML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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