Created
September 22, 2022 15:23
-
-
Save TheRolfFR/6ac2fb780682b8f55542a1cc63717e40 to your computer and use it in GitHub Desktop.
XML ie format
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
let value; | |
let spaces; | |
spaces = 0; | |
console.log(value.split('\n').filter(f => f.trim().length !== 0).map(cur => { | |
if(cur.startsWith('-')) spaces ++; | |
else if(cur.startsWith('</')) spaces --; | |
else if(cur.startsWith('<')) spaces++; | |
let sp = ''; | |
for(let i = 0; i < spaces; ++i) { | |
sp += ' '; | |
} | |
if(cur.endsWith('/>')) spaces --; | |
return sp + cur.replace('-<', '<'); | |
}).join('\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment