Commit 66201ff3 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

Release 4.9.0

\## edited text
* improved view
* whitespaces

\## index
* sort work items inside personal entity view
* add name of parent item (places) to list and @title on very long entity paths
* fix issue searching for work entries
* style nested entities
* fake relation to Fontane on work items in list @type='Fontane'

\## commentary
* editorial commentary on sketches

\## transcription
* new feature: present reverted overwritings
* add stamp: Deutsche Bibliothek Theodor-Fontane-Archiv
* special styling for initials
* improved tei:mod with multiple instruction in @style
* bugfix: highlighted areas

\## Bugfixes
* #114 #113 #109 #110 #119 #117 #105
parents 7d5e14e4 39447953
project.name=http://textgrid.de/ns/SADE-fontane-develop
project.version=4.8.0
project.version=4.9.0
project.title=[Fontane] SADE
project.abbrev=SADE-fontane-develop
project.processorversion=4.7.0
......
......@@ -13,6 +13,7 @@ xquery version "3.1";
module namespace etTransfo="http://fontane-nb.dariah.eu/etTransfo";
declare namespace err="http://www.w3.org/2005/xqt-errors";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xi="http://www.w3.org/2001/XInclude";
......@@ -29,14 +30,14 @@ import module namespace tidySimple ="http://fontane-nb.dariah.eu/tidysimple" at
declare variable $etTransfo:cases :=
(
(: "3qtcz.xml", (: case C :):)
"3qtqv.xml" (: case A :)
(: "3qtqw.xml" (: case B :) :)
(: "3qtqx.xml" (: case D :):)
(: "3qtqz.xml" (: case E :):)
"3qtcz.xml", (: case C :)
"3qtqv.xml", (: case A :)
"3qtqw.xml", (: case B :)
"3qtqx.xml", (: case D :)
"3qtqz.xml" (: case E :)
);
declare variable $etTransfo:dir := "/db/apps/SADE/modules/fontane/edited-text/";
declare variable $etTransfo:coll := "/db/apps/SADE/modules/fontane/edited-text/";
(:~
......@@ -47,6 +48,8 @@ declare variable $etTransfo:dir := "/db/apps/SADE/modules/fontane/edited-text/";
: @return An intermediate TEI/XML with all notebooks in it in /db/sade-projects/textgrid/data/print/xml/fontane-full.xml
:)
declare function etTransfo:complete() {
etTransfo:assure-coll-available("print"),
etTransfo:assure-coll-available("log"),
for $case in $etTransfo:cases return
(etTransfo:create-case($case),
etTransfo:create-htmls($case)),
......@@ -56,7 +59,41 @@ declare function etTransfo:complete() {
} catch * {
error(QName("error", "ETTRANSFO02"), "An error occured while creating the whole TEI base for print.")
},
etTransfo:tidy-logs()
etTransfo:tidy-logs(),
try {
etTransfo:report-errors()
} catch * {
error(QName("error", "ETTRANSFO15"), "An error occured while reporting errors.")
}
};
(:~
: A function to trigger the creation of the edited text for a single notebook.
: Mainly used for parallel creation of the notebooks.
:
: @param $uri The notebook's URI, e.g. "16b00" :)
declare function etTransfo:transform-single-nb($uri as xs:string) as xs:string* {
let $assure-dir-available := etTransfo:assure-coll-available("print")
let $assure-dir-available := etTransfo:assure-coll-available("log")
let $log := util:log-system-out("Start creating edited text for " || $uri)
let $log := etTransfo:create-log($uri)
let $tei := doc($config:data-root || "/data/" || $uri || ".xml")//tei:TEI
let $updated-notebook :=
element tei:TEI {
attribute id {$uri},
$tei/@*,
$tei/*
}
return
(try {
etTransfo:transform-tei($updated-notebook, $log)
} catch * {
etTransfo:add-log-entry($log, "ETTRANSFO08: Couldn't transform TEI. ")
},
etTransfo:tidy-logs())
};
......@@ -74,14 +111,12 @@ declare function etTransfo:create-case($showcase as xs:string) as xs:string {
} catch * {
error(QName("error", "ETTRANSFO03"), "An error occured while opening " || $showcase || ".")
}
let $log := etTransfo:create-log($doc//tei:title[1] => replace(" ", "-"))
let $log := util:log-system-out("Start creating case " || $showcase || " (" || $doc//tei:title[1] || ").")
let $new-filename := $doc//tei:title[1] => replace(" ", "-") || ".xml"
let $assure-dir-available :=
if(xmldb:collection-available($config:data-root || "/print/")) then
()
else
(xmldb:create-collection($config:data-root, "/print"),
xmldb:create-collection($config:data-root || "/print/", "xml"),
xmldb:create-collection($config:data-root || "/print/", "xhtml"))
let $assure-dir-available := etTransfo:assure-coll-available("print")
let $create-new-file := xmldb:store($config:data-root || "/print/xml/", $new-filename, $doc/*)
......@@ -93,7 +128,7 @@ declare function etTransfo:create-case($showcase as xs:string) as xs:string {
try {
doc("/db/sade-projects/textgrid/data/xml/data/" || $uri || ".xml")/tei:TEI
} catch * {
error(QName("error", "ETTRANSFO04"), "Couldn't find the node tei:TEI of " || $uri || ".")
etTransfo:add-log-entry($log, "ETTRANSFO04: Couldn't find the node tei:TEI of " || $uri || ".")
}
let $updated-notebook :=
element tei:TEI {
......@@ -115,18 +150,16 @@ declare function etTransfo:create-case($showcase as xs:string) as xs:string {
: @param $showcase The filename of a showcase, e.g. "12345.xml"
: @return All notebooks of a showcase in-memory, i.e. a sequence of tei:TEI
:)
declare function etTransfo:get-teis($showcase as xs:string) as element(tei:TEI)+ {
declare function etTransfo:get-teis($showcase as xs:string) as element(tei:TEI)* {
let $doc := doc("/db/sade-projects/textgrid/data/xml/data/" || $showcase)
let $summary-file-name := $doc//tei:title[1] => replace(" ", "-") || ".xml"
let $summary-file :=
let $log := doc($etTransfo:coll || "logs/" || $doc//tei:title[1] => replace(" ", "-") || "-log.xml")
return
try {
doc($config:data-root || "/print/xml/" || $summary-file-name)
doc($config:data-root || "/print/xml/" || $summary-file-name)//tei:TEI
} catch * {
error(QName("error", "ETTRANSFO04"), "Summary file for case " || $showcase || "couldn't be opened.")
etTransfo:add-log-entry($log, "ETTRANSFO05: Summary file for case " || $showcase || "couldn't be opened.")
}
return
$summary-file//tei:TEI
};
......@@ -137,13 +170,18 @@ declare function etTransfo:get-teis($showcase as xs:string) as element(tei:TEI)+
: @param $showcase The filename of a showcase, e.g. "12345.xml"
: @return One or more strings indicating the location where the XHTML(s) have been stored to.
:)
declare function etTransfo:create-htmls($showcase as xs:string) as xs:string+ {
declare function etTransfo:create-htmls($showcase as xs:string) as xs:string* {
let $teis := etTransfo:get-teis($showcase)
for $tei in $teis return
let $log := util:log-system-out("Start creating edited text for " || $tei//tei:idno[@type = "TextGrid"])
let $log := etTransfo:create-log(substring-after($tei//tei:idno[@type = "TextGrid"], "textgrid:"))
return
etTransfo:transform-tei($tei, $log)
try {
etTransfo:transform-tei($tei, $log)
} catch * {
etTransfo:add-log-entry($log, "ETTRANSFO08: Couldn't transform TEI. ")
}
};
......@@ -155,12 +193,53 @@ declare function etTransfo:create-htmls($showcase as xs:string) as xs:string+ {
:)
declare function etTransfo:transform-tei($tei as element(tei:TEI), $log as xs:string) {
(: macro-sort:main($tei, $tei/@id):)
(: => fsort:main():)
fsort:main($tei, $log)
=> prepCom:main($tei/@id)
=> fontaneSimple:main($tei/@id, $log)
=> tidySimple:main($tei/@id)
=> simple2xhtml:main($tei/@id)
(: let $macro-sorted :=:)
(: try {:)
(: macro-sort:main($tei, $tei/@id):)
(: } catch * {:)
(: etTransfo:add-log-entry($log, "ETTRANSFO14: Error while macro sorting this notebook. Reason: 
" ||:)
(: concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description)):)
(: }:)
let $sorted :=
try {
fsort:main($tei, $log)
(: fsort:main($macro-sorted, $log) :)
} catch * {
etTransfo:add-log-entry($log, "ETTRANSFO09: Error while sorting this notebook. Reason: 
" ||
concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description))
}
let $prepare-comment :=
try {
prepCom:main($sorted, $tei/@id)
} catch * {
etTransfo:add-log-entry($log, "ETTRANSFO10: Error while preparing commentary for this notebook. Reason: 
" ||
concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description))
}
let $transform-to-interform :=
try {
fontaneSimple:main($prepare-comment, $tei/@id, $log)
} catch * {
etTransfo:add-log-entry($log, "ETTRANSFO11: Error while transforming this notebook to an intermediate format. Reason: 
" ||
concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description))
}
let $tidy-interform :=
try {
tidySimple:main($transform-to-interform, $tei/@id)
} catch * {
etTransfo:add-log-entry($log, "ETTRANSFO12: Error while tidying up the intermediate format for this notebook. Reason: 
" ||
concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description))
}
return
try {
simple2xhtml:main($tidy-interform, $tei/@id)
} catch * {
etTransfo:add-log-entry($log, "ETTRANSFO13: Error while creating XHTML for this notebook. Reason: 
" ||
concat("[", $err:line-number, ": ", $err:column-number, "] Error ", $err:code, ": ", $err:description))
}
};
......@@ -173,19 +252,20 @@ declare function etTransfo:transform-tei($tei as element(tei:TEI), $log as xs:st
:)
declare function etTransfo:create-print-tei() as xs:string {
let $xmls := etTransfo:get-all-xmls()
let $log := etTransfo:create-log("general-print-creation")
let $complete-print-file :=
element {QName("http://www.tei-c.org/ns/1.0", "teiCorpus")} {
$xmls,
try {
etTransfo:get-literature()
} catch * {
error(QName("error", "ETTRANSFO06"), "An error occured while creating the bibliography.")
etTransfo:add-log-entry($log, "ETTRANSFO06: An error occured while creating the bibliography.")
},
try {
abbrev-index:main()
} catch * {
error(QName("error", "ETTRANSFO07"), "An error occured while creating the index of abbreviations.")
etTransfo:add-log-entry($log, "ETTRANSFO07: An error occured while creating the index of abbreviations.")
}
}
return
......@@ -313,32 +393,94 @@ declare function etTransfo:make-bib-entries($type as xs:string) as element(tei:d
};
(:~
: Creates a log file for a given notebook.
:
: @author Michelle Weidling
: @param $uri The notebook's URI, e.g. "12345.xml"
: @return The location of the stored log-file, e.g. "/db/apps/sade/modules/fontane/edited-text/logs/12345-log.xml"
:)
declare function etTransfo:create-log($uri as xs:string) as xs:string {
let $assure-dir-available := etTransfo:assure-dir-available("logs")
let $assure-dir-available := etTransfo:assure-coll-available("logs")
let $log-name := $uri || "-log.xml"
return xmldb:store($etTransfo:dir || "logs", $log-name, <log/>)
return xmldb:store($etTransfo:coll || "logs", $log-name, <log/>)
};
declare function etTransfo:assure-dir-available($dir-name as xs:string) {
if(xmldb:collection-available($etTransfo:dir || "logs")) then
$etTransfo:dir || "logs"
else
xmldb:create-collection($etTransfo:dir, "logs")
(:~
: Makes sure a requested collection is available.
:
: @author Michelle Weidling
: @param $flag a string indicating the target collection
: @return The location of the log collection, "/db/apps/sade/modules/fontane/edited-text/logs/"
:)
declare function etTransfo:assure-coll-available($flag as xs:string) {
switch ($flag)
case "logs" return
if(xmldb:collection-available($etTransfo:coll || "logs")) then
$etTransfo:coll || "logs"
else
xmldb:create-collection($etTransfo:coll, "logs")
case "print" return
if(xmldb:collection-available($config:data-root || "/print/")) then
()
else
(xmldb:create-collection($config:data-root, "/print"),
xmldb:create-collection($config:data-root || "/print/", "xml"),
xmldb:create-collection($config:data-root || "/print/", "xhtml"))
default return ()
};
(:~
: Only the logs which acutally contain info should be kept.
: Adds a log entry to a given log file.
:
: @author Michelle Weidling
: @param $log-file The path to the log file, e.g. "/db/apps/sade/modules/fontane/edited-text/logs/12345-log.xml"
: @param $message The message of the log entry
: @return The location of the log collection, "/db/apps/sade/modules/fontane/edited-text/logs/"
:)
declare function etTransfo:add-log-entry($log-file as xs:string,
$message as xs:string) as empty-sequence() {
let $entry := <LogEntry timestamp="{util:system-time()}">{$message}</LogEntry>
return update insert $entry into doc($log-file)/*
};
(:~
: Removes all log files that don't contain any information.
: @author Michelle Weidling
:)
declare function etTransfo:tidy-logs() {
for $log in collection($etTransfo:dir || "logs/") return
declare function etTransfo:tidy-logs() as item()* {
for $log in collection($etTransfo:coll || "logs/") return
if($log//LogEntry) then
()
else
let $uri := substring-after(base-uri($log), "logs/")
return
xmldb:remove($etTransfo:dir || "logs/", $uri)
xmldb:remove($etTransfo:coll || "logs/", $uri)
};
(:~
: Prints all errors found to stdout.
: @author Michelle Weidling
:)
declare function etTransfo:report-errors() as item()* {
let $log-path := $etTransfo:coll || "logs/"
return
if(normalize-space(string-join(xmldb:get-child-resources($log-path), "")) = "") then
util:log-system-out("No errors found while creating the edited text! Yay!")
else
(
util:log-system-out("Errors detected in the following notebooks:"),
for $log in collection($log-path) return
(
util:log-system-out("*&#8195;" ||
substring-after(base-uri($log), "logs/")
=> substring-before("-log")),
util:log-system-out($log)
),
util:log-system-out("Total: " || count(xmldb:get-child-resources($log-path)) || " notebook(s).")
)
};
......@@ -17,9 +17,10 @@ import module namespace config="http://textgrid.de/ns/SADE/config" at "../../con
declare function simple2xhtml:main($nodes as node()*, $uri as xs:string) {
let $xhtml := element xhtml:div {simple2xhtml:recursion($nodes//tei:text)}
let $store := xmldb:store($config:data-root || "/print/xhtml/", $uri || ".html", $xhtml)
let $tidy := element xhtml:div {simple2xhtml:tidy($xhtml)}
let $store := xmldb:store($config:data-root || "/print/xhtml/", $uri || ".html", $tidy)
return
$xhtml
$tidy
};
(:~
......@@ -56,12 +57,15 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
else
element xhtml:span {
simple2xhtml:set-hs-info($node, ()),
replace($node, "@P", "")
=> replace(" ,", ",")
replace($node, " ,", ",")
=> replace(" \?", "?")
=> replace(" \.", ".")
=> replace(" ;", ";")
=> replace("@", " ")
=> replace("@@", " ")
=> replace("@P", "")
=> replace(" &#x2003;", "&#x2003;")
=> replace(":", ": ")
=> replace(" “", "“")
}
case element(tei:body) return
......@@ -658,3 +662,25 @@ declare function simple2xhtml:make-integration($node as element(tei:seg)) {
}
}
};
declare function simple2xhtml:tidy($nodes as node()*) as node()* {
for $node in $nodes return
typeswitch ($node)
case text() return
if(string-length($node) = 1 and normalize-space($node) = ""
and matches(substring($node/following::text()[1], 1, 1), "[,\.\?]")) then
()
else
text{ replace($node, "[\s]+", " ")
=> replace(" ,", ",")
=> replace(" \.", ".")
=> replace(" :", ":") }
default return
element {QName("http://www.w3.org/1999/xhtml", $node/name())} {
$node/@*,
simple2xhtml:tidy($node/node())
}
};
......@@ -170,6 +170,13 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no
return
if(count($next-node) = 1) then
(fsort:keep-node($node, "sort", $log),
(: check if the parts are in different lines :)
if($node/ancestor::tei:line = $next-node/ancestor::tei:line) then
()
else
element tei:milestone {
attribute unit {"line"}
},
fsort:apply-all-nexts($next-node, $log))
else if(not($next-node)) then
fsort:add-log-entry($log, "No next node found for " || $node/@next)
......@@ -189,6 +196,13 @@ declare function fsort:apply-all-nexts($node as node(), $log as xs:string) as no
if(count($next-node) = 1) then
($prev-handshift,
fsort:keep-node($node, "sort", $log),
(: check if the parts are in different lines :)
if($node/ancestor::tei:line = $next-node/ancestor::tei:line) then
()
else
element tei:milestone {
attribute unit {"line"}
},
fsort:apply-all-nexts($next-node, $log))
else if(not($next-node)) then
fsort:add-log-entry($log, "No next node found for " || $node/@next)
......
......@@ -56,7 +56,8 @@ xs:string) as node()? {
</text>
</TEI>
</teiCorpus>
let $store := xmldb:store($config:data-root || "/print/xml/", $uri || "-tmp.xml", $tei)
let $store := xmldb:store($config:data-root || "/print/xml/", $uri || "-tmp.xml", $tei)
return $tei
};
......@@ -208,7 +209,10 @@ $log as xs:string) as node()* {
simpleHelpers:trim-first-char($node))
else if($node/@type = "verse") then
if(not($node/@next)) then
if($node/@prev) then
()
else if(not($node/@next)) then
(if(not($node/preceding-sibling::tei:line[@type = "verse"])) then
fontaneSimple:mark-linegroup-beginning()
else
......@@ -220,10 +224,11 @@ $log as xs:string) as node()* {
fontaneSimple:mark-linegroup-end()
else
())
(: 3.8.2.2.1.3 Vers mit anderer Beschriftung in einer Zeile :)
else
let $corresp := $node/following::tei:seg[@type = "verse"
and matches($node/@next, @xml:id)]
let $corresp := $node/following::*[@type = "verse"
and replace($node/@next, "#", "") = @xml:id]
return
(fontaneSimple:mark-linegroup-beginning(),
element tei:l {
......@@ -342,13 +347,7 @@ $log as xs:string) as node()* {
fontaneSimple:transform($node/node(), $uri, $log)
}
else if($node/@type = "integration") then
element tei:seg {
$node/@*,
fontaneSimple:transform($node/node(), $uri, $log)
}
else if($node/@type = "editorial-label") then
else if($node/@type = ("integration", "editorial-label")) then
element tei:seg {
$node/@*,
fontaneSimple:transform($node/node(), $uri, $log)
......@@ -397,16 +396,14 @@ $log as xs:string) as node()* {
}
else if($node/@type = "pocket") then
(fontaneSimple:make-pb($node),
element tei:div{
$node/(@* except (@n, @ulx, @uly, @lry, @lrx)),
fontaneSimple:transform($node/node(), $uri, $log)
})
}
else if(simpleHelpers:is-page($node)
and $node/@type = "clipping") then
(fontaneSimple:make-pb($node),
(if($node/@subtype = "Kalenderblatt"
if($node/@subtype = "Kalenderblatt"
and contains($node//tei:handShift/@new, "Friedrich_Fontane")) then
element tei:div {
$node/@n,
......@@ -422,10 +419,10 @@ $log as xs:string) as node()* {
}
else
()))
()
else if(simpleHelpers:is-page($node)) then
(fontaneSimple:make-pb($node),
(text{" "},
fontaneSimple:transform($node/node(), $uri, $log))
else if($node/@type = "label" and
......@@ -494,6 +491,9 @@ $log as xs:string) as node()* {
fontaneSimple:transform($node/node(), $uri, $log)
else
element tei:hi {
$node/@xml:id,
$node/@prev,
$node/@next,
attribute type {"vertical-mark"},
fontaneSimple:transform($node/node(), $uri, $log)
}
......@@ -669,6 +669,9 @@ $log as xs:string) as node()* {
attribute type {"short-paragraph-line"}
}
else if(matches($node/descendant::tei:ref, "horizontale einfache Abgrenzungslinie")) then
()
else if($node/ancestor::tei:zone[@type = "illustration"]) then
let $display :=
if($node/ancestor::tei:zone[@type = "illustration"]/tei:milestone[@unit = "illustration"][. << $node]) then
......@@ -676,7 +679,7 @@ $log as xs:string) as node()* {
else
"inline"
let $img-url := try {tbleapi:get-url($uri, $node/@xml:id, "png") }
catch * { fontaneSimple:add-log-entry($log, "No TBLE-file found for " || $node/@xml:id) }
catch * { fontaneSimple:add-log-entry($log, "No TBLE-file found for " || serialize($node)) }
let $img-url :=
if($display = "inline") then
replace($img-url, ",1000", ",500")
......@@ -769,7 +772,10 @@ $log as xs:string) as node()* {
(
element {QName("http://www.tei-c.org/ns/1.0", $node/name())} {
$node/@*,
fontaneSimple:make-index-infos($node, $index-type),
if($node/@prev) then
()
else
fontaneSimple:make-index-infos($node, $index-type),
fontaneSimple:transform($node/node(), $uri, $log)
},
if(not($node//tei:abbr/text()[ends-with(., ":")]
......@@ -825,6 +831,9 @@ $log as xs:string) as node()* {
case element(tei:unclear) return
fontaneSimple:copy-element($node, $uri, $log)
case element(tei:div) return
fontaneSimple:copy-element($node, $uri, $log)
default return
fontaneSimple:transform($node/node(), $uri, $log)
};
......@@ -955,13 +964,15 @@ 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
if($node/preceding::node()[1][normalize-space(.) = ""]
and string-length($node/preceding::text()[1]) = 1) then
true()
else
false()
let $whitespace-after :=
if($node/following::node()[1][normalize-space(.) = ""]
and string-length($node/following::text()[1]) = 1
and not($node/following::*[1][@type = "heading"])
and not($node/following::text()[1][matches(substring(., 1, 1), "[\.,]")])) then
true()
......@@ -972,8 +983,8 @@ as element(tei:milestone) {
element tei:milestone {
attribute unit {"handshift"},
attribute subtype {if($node/@new) then $node/@new else $prev-hand/@new},
(if($whitespace-before) then attribute ws-before {"true"} else ()),
(if($whitespace-after) then attribute ws-after {"true"} else ()),
(: (if($whitespace-before) then attribute ws-before {"true"} else ()),:)
(: (if($whitespace-after) then attribute ws-after {"true"} else ()),:)
$node/(@* except @new)
}
......
......@@ -72,33 +72,38 @@ as xs:boolean {
: @return text() the formatted text
: :)
declare function simpleHelpers:prepare-text($node as text()) as text()? {
if(not(normalize-space($node) = "")) then
if(normalize-space($node) = "" and string-length($node) gt 1) then
()
else
(: the @P serves as a flag for the removal of hyphens. this is necessary
since we sometimes have cases where a hyphen is the only content of a
string. functx:substring-before-last would therefore produce an empty
string which leads to problems while preparing the text any further. :)
let $cleared-end-hyphen :=
if((ends-with($node, "-") or ends-with($node, "⸗"))
and $node/parent::tei:add) then
$node
else if(ends-with($node, "-") and not(simpleHelpers:keep-hyphen($node))) then
(: if((ends-with($node, "-") or ends-with($node, "⸗")):)
(: and $node/parent::tei:add) then:)
(: $node:)
(: else :)
if(ends-with($node, "-") and not(simpleHelpers:keep-hyphen($node))) then
text {functx:substring-before-last($node, "-") || "@P"}
else if(ends-with($node, "⸗") and not(simpleHelpers:keep-hyphen($node))) then
text {functx:substring-before-last($node, "⸗") || "@P"}
else
replace($node, "⸗", "-")
let $cleared-hyphen := replace($cleared-end-hyphen, "⸗", "-")
let $save-whitespaces := replace($cleared-end-hyphen, " ", "@@")
let $cleared-hyphen := replace($save-whitespaces, "⸗", "-")
let $cleared-round-s := replace($cleared-hyphen, "ſ", "s")
let $cleared-Tironian := replace($cleared-round-s, "&#x204a;c.", "etc.")
(: let $normalized := normalize-space($cleared-round-s):)
(: let $last-char := substring($cleared-round-s, string-length($cleared-round-s), 1):)
(: let $add-whitespace := :)
(: if(matches($last-char, "[\w\d,\.;?!]"):)
(: and $node/parent::tei:line/child::*[last()] = . ) then:)
(: $cleared-round-s || " ":)
(: else:)
(: $cleared-round-s:)
(: return text {$add-whitespace}:)
let $cleared-big-space :=
if($node/following-sibling::*[1][self::tei:handShift]
and ends-with($node, "-&#x2003;")) then
text{replace($cleared-round-s, "-&#x2003;", "@P")}
else if($node/following-sibling::*[1][self::tei:handShift]
and ends-with($node, "&#x2003;")) then
text{replace($cleared-round-s, "&#x2003;", "")}
else