Commit a63d491e authored by mrodzis's avatar mrodzis 🌎
Browse files

Improve whitespace handling when changing fonts (cf print#61)

parent 5656f77f
......@@ -853,12 +853,27 @@ as element(tei:pb) {
declare function fontaneSimple:enhance-handshift($node as element(tei:handShift))
as element(tei:milestone) {
let $prev-hand := $node/preceding::tei:handShift[@new][1]
let $whitespace-before :=
if($node/preceding::node()[1][normalize-space(.) = ""]) then
true()
else
false()
let $whitespace-after :=
if($node/following::node()[1][normalize-space(.) = ""]) then
true()
else
false()
return
element {QName("http://www.tei-c.org/ns/1.0", "milestone")} {
attribute unit {"handshift"},
attribute subtype {if($node/@new) then $node/@new else $prev-hand/@new},
attribute rend {concat("script(", (if($node/@script) then $node/@script else ""), ") ",
"medium(", (if($node/@medium) then $node/@medium else ""), ")")},
(if($whitespace-before) then attribute ws-before {"true"} else ()),
(if($whitespace-after) then attribute ws-after {"true"} else ()),
$node/(@* except (@new, @medium, @script))
}
};
......
......@@ -350,7 +350,9 @@ $node as element(tei:milestone)) as xs:boolean {
if($prev-hand
and $prev-hand = $prev-valid-hand
and $node/@subtype = $prev-hand/@subtype
and $node/@rend = $prev-hand/@rend) then
and $node/@rend = $prev-hand/@rend
and $node/@ws-before = $prev/@ws-before
and $node/@ws-after = $prev/@ws-after) then
true()
else
false()
......
......@@ -61,7 +61,7 @@ as node()* {
let $prev-handshift := $node/preceding::tei:milestone[@unit = "handshift"][1]
return
if($node/@unit = "handshift" and
simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node)) then
simpleHelpers:is-hand-valid($tidySimple:valid-hands, $node)) then
tidySimple:clear-handshift($node)
else if($node/@unit = "handshift") then
......@@ -200,6 +200,8 @@ declare function tidySimple:clear-handshift($node as element(tei:milestone))
as element(tei:milestone) {
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
attribute unit {"handshift"},
$node/@ws-before,
$node/@ws-after,
if($node/@subtype = "") then
()
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment