From 3f0a6407dc182525a658860d4caec46915a4457b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20H=C3=A4nsel?= Date: Wed, 19 Apr 2023 17:26:15 +0200 Subject: [PATCH] fix newline padding for pre tag --- src/StippleUIParser.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/StippleUIParser.jl b/src/StippleUIParser.jl index 949d5ebb..006a79e6 100644 --- a/src/StippleUIParser.jl +++ b/src/StippleUIParser.jl @@ -165,6 +165,7 @@ end function parse_to_stipple(el::EzXML.Node, level = 1; indent = 4, pre = false) if ! iselement(el) + # content = pre ? replace(replace(el.content, r"^\r?\n" => ""), r"\r?\n$" => "") : strip(el.content) content = pre ? el.content : strip(el.content) content == "" && return "" quotes = occursin('"', content) ? "\"\"\"" : "\"" @@ -220,7 +221,10 @@ function parse_to_html(el::EzXML.Node, level = 1; indent = 4, pre = false) ("$sep1\n$indent_1", "\n$indent_2") end tag = el.name - lowercase(tag) == "pre" && no > 0 && (sep2 = "$sep1\n") + if lowercase(tag) == "pre" + no > 0 && (sep2 = "$sep1\n") + children_str = replace(replace(children_str, r"^\r?\n" => ""), r"\r?\n$" => "") + end """<$tag$sep1$attr_str>$sep2$children_str$sep3""" end