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

Feature/xhtml edited text

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