Commit 38815146 authored by mrodzis's avatar mrodzis 🐸
Browse files

Merge branch 'feature/xhtml-edited-text' into 'develop'

Feature/xhtml edited text

See merge request !32
parents 4dbb87ff fc1e787d
...@@ -60,6 +60,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ...@@ -60,6 +60,8 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
=> replace(" ,", ",") => replace(" ,", ",")
=> replace(" \?", "?") => replace(" \?", "?")
=> replace(" \.", ".") => replace(" \.", ".")
=> replace(" ;", ";")
=> replace("@", " ")
} }
case element(tei:body) return case element(tei:body) return
...@@ -69,17 +71,32 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ...@@ -69,17 +71,32 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
} }
case element(tei:abbr) return case element(tei:abbr) return
(text{" "},
element xhtml:span { element xhtml:span {
simple2xhtml:set-hs-info($node, "abbr"), simple2xhtml:set-hs-info($node, "abbr"),
simple2xhtml:recursion($node/node()) simple2xhtml:recursion($node/node())
} })
case element(tei:div) return case element(tei:div) return
if($node/@type = "toc") then if($node/@type = "toc") then
element xhtml:ul { if($node/@subtype = "Friedrich_Fontane") then
simple2xhtml:set-hs-info($node, "nb-toc-list"), (element xhtml:span {
simple2xhtml:recursion($node/node()) attribute class {"handshift"},
} text{"<Schreiberhand Friedrich Fontane>"}
},
element xhtml:ul {
simple2xhtml:set-hs-info($node, "nb-toc-list"),
simple2xhtml:recursion($node/node())
},
element xhtml:span {
attribute class {"handshift"},
text{"<Schreiberhand Theodor Fontane>"}
})
else
element xhtml:ul {
simple2xhtml:set-hs-info($node, "nb-toc-list"),
simple2xhtml:recursion($node/node())
}
else else
element xhtml:div { element xhtml:div {
if($node/@type = "label") then if($node/@type = "label") then
...@@ -198,10 +215,19 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ...@@ -198,10 +215,19 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
if($node/@unit = "line") then if($node/@unit = "line") then
let $next-char := substring($node/following::text()[1], 1, 1) let $next-char := substring($node/following::text()[1], 1, 1)
return return
if(matches($next-char, "[\.\)\?,;!]")) then if(matches($next-char, "[\.\)\?,;!]")
and not(ends-with($node/preceding::text()[1], "@P"))) then
()
else if(ends-with($node/preceding::text()[1], "@P")) then
() ()
else if($node/preceding-sibling::*[1][self::tei:rs[concat('#', @xml:id) = $node/following-sibling::*[2][self::tei:rs]/@prev]]) then
()
else else
text{" "} text{" "}
else if($node/@unit = "paragraph") then else if($node/@unit = "paragraph") then
(element xhtml:br{}, (element xhtml:br{},
element xhtml:div { element xhtml:div {
...@@ -213,21 +239,25 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ...@@ -213,21 +239,25 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
case element(tei:ab) return case element(tei:ab) return
if($node/@type = "sketch" if($node/@type = "sketch"
and $node/descendant::tei:figure[@position = "block"]) then and $node/descendant::tei:figure) then
element xhtml:table { element xhtml:table {
attribute class {"nb-sketch"}, attribute class {"nb-sketch"},
element xhtml:tr { element xhtml:tr {
simple2xhtml:recursion($node/node()) simple2xhtml:recursion($node/node())
} }
} }
else if($node/@type = ("caret", "footnote-mark")) then
()
else else
simple2xhtml:recursion($node/node()) simple2xhtml:recursion($node/node())
case element(tei:figure) return case element(tei:figure) return
let $captions-before := let $captions-before :=
$node/../preceding-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab] $node/preceding-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab]
let $captions-after := let $captions-after :=
$node/../following-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab] $node/following-sibling::tei:seg[@type = "caption"][ancestor::tei:ab = $node/ancestor::tei:ab]
return return
(: make captions left of sketch:) (: make captions left of sketch:)
(if(exists($captions-before)) then (if(exists($captions-before)) then
...@@ -235,16 +265,14 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ...@@ -235,16 +265,14 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
else else
(), (),
if($node/@position = "block") then element xhtml:td {
element xhtml:td { attribute class {"nb-img"},
simple2xhtml:make-img($node, "block") if($node/@rotate) then
} attribute style {concat("width: ", $node/parent::*/@height, "; height: ", $node/parent::*/@width, ";")}
else else
(text{" "}, (),
element xhtml:span { simple2xhtml:make-img($node, "block")
attribute class {"nb-inline-img"}, },
simple2xhtml:make-img($node, "inline")
}),
(: make captions right of sketch:) (: make captions right of sketch:)
if(exists($captions-after)) then if(exists($captions-after)) then
...@@ -255,6 +283,10 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ...@@ -255,6 +283,10 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
case element(tei:seg) return case element(tei:seg) return
if($node/@type = "caption") then if($node/@type = "caption") then
() ()
else if($node/@type = "editorial-label") then
()
else else
element xhtml:span { element xhtml:span {
simple2xhtml:set-hs-info($node, "nb-seg"), simple2xhtml:set-hs-info($node, "nb-seg"),
...@@ -262,6 +294,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* { ...@@ -262,6 +294,12 @@ declare function simple2xhtml:recursion($nodes as node()*) as node()* {
simple2xhtml:recursion($node/node()) simple2xhtml:recursion($node/node())
} }
case element(tei:unclear) return
element xhtml:span {
attribute class {"unclear"},
simple2xhtml:recursion($node/node())
}
case element(tei:date) return case element(tei:date) return
(simple2xhtml:set-whitespace-before($node), (simple2xhtml:set-whitespace-before($node),
element xhtml:span { element xhtml:span {
...@@ -323,16 +361,24 @@ declare function simple2xhtml:set-classes($node as element(*)) as attribute() { ...@@ -323,16 +361,24 @@ declare function simple2xhtml:set-classes($node as element(*)) as attribute() {
:) :)
declare function simple2xhtml:make-img($node as element(tei:figure), declare function simple2xhtml:make-img($node as element(tei:figure),
$mode as xs:string) as element(xhtml:img) { $mode as xs:string) as element(xhtml:img) {
element xhtml:img { let $width := "width:" || $node/ancestor::tei:ab[@type = "sketch"]/@width || "; "
attribute src {$node/@href}, let $height := "height:" || $node/ancestor::tei:ab[@type = "sketch"]/@height || ";"
attribute alt {$node//tei:figDesc/string()}, let $rotation :=
if($mode = "block") then if($node/@rotate) then
attribute class {"nb-block-img"} "transform: rotate(" || $node/@rotate || "deg);"
else else
attribute class {"nb-inline-img"}, ""
attribute style {"width:" || $node/ancestor::tei:ab[@type = "sketch"]/@width || "; " ||
"height:" || $node/ancestor::tei:ab[@type = "sketch"]/@height} return
} element xhtml:img {
attribute src {$node/@href},
attribute alt {$node//tei:figDesc/string()},
(: if($mode = "block") then:)
(: attribute class {"nb-block-img"}:)
(: else:)
attribute class {"nb-block-img"},
attribute style {$width || $height || $rotation}
}
}; };
......
Supports Markdown
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