mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-06 02:30:46 -08:00
Fix/serialize close html tag (#9437)
* fix: should use tree.isSelfClosing || isVoidElement * docs: about html * fix: Void element without self-closing slash (e.g., <br> instead of <br/>) * Update editions/test/tiddlers/tests/data/serialize/VoidElements.tid Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
cc348fee96
commit
3e1078eff1
3 changed files with 18 additions and 1 deletions
|
|
@ -16,9 +16,13 @@ exports.serialize = function(tree,serialize) {
|
|||
// Children
|
||||
var children = tree.children ? serialize(tree.children) : "";
|
||||
var result = "";
|
||||
var isVoidElement = $tw.config.htmlVoidElements.indexOf(tag) !== -1;
|
||||
// Self-closing tag
|
||||
if(tree.isSelfClosing) {
|
||||
result += "<" + tag + (attributes ? " " + attributes : "") + "/>";
|
||||
result += "<" + tag + (attributes ? " " + attributes : "") + "/>";
|
||||
} else if(isVoidElement) {
|
||||
// Void element without self-closing slash (e.g., <br> instead of <br/>)
|
||||
result += "<" + tag + (attributes ? " " + attributes : "") + ">";
|
||||
} else {
|
||||
// Opening and closing tags
|
||||
result += "<" + tag + (attributes ? " " + attributes : "") + ">" + children + "</" + tag + ">";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue