diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-08 01:13:35 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-08 01:13:35 +0200 |
commit | 93a5dd7254ae8f350604201fd09e995da331fc9b (patch) | |
tree | 95a835117fe2abb978a1fa854e505c87be18ec7b /static | |
parent | Only include XCAL when in edit mode. (diff) | |
download | calp-93a5dd7254ae8f350604201fd09e995da331fc9b.tar.gz calp-93a5dd7254ae8f350604201fd09e995da331fc9b.tar.xz |
Javascript self closing XML tags.
Diffstat (limited to 'static')
-rw-r--r-- | static/script.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/static/script.js b/static/script.js index bdeca8f5..27a46ae0 100644 --- a/static/script.js +++ b/static/script.js @@ -5,6 +5,10 @@ function start_tag(str) { } function end_tag(str) { + return "<span class='html-tag'></" + str + "></span>"; +} + +function self_tag(str) { return "<span class='html-tag'><" + str + "/></span>"; } @@ -19,10 +23,14 @@ function pretty_print_xml(xml, indent=0) { if (xml.childElementCount == 0) { - return istring(indent) - + start_tag(tag) - + "<b>" + xml.textContent + "</b>" - + end_tag(tag); + if (xml.textContent) { + return istring(indent) + + start_tag(tag) + + "<b>" + xml.textContent + "</b>" + + end_tag(tag); + } else { + return istring(indent) + self_tag(tag); + } } else { let str = istring(indent) + start_tag(tag) + "<br/>"; for (let child of xml.children) { |