Commit f88c448b authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

prepare tei:add with caret

parent a26bc120
xquery version "3.1";
(:~
: This module provides function corresponding to @tei:rend describing carets.
:
: Types currently used are:
: [x] "caret:bow"
: [x] "caret:curved_V"
: [x] "caret:slash"
: [ ] "caret:backslash"
: [x] "caret:half-bow"
: [x] "caret:V"
: [ ] "caret:semicircle"
: [ ] "caret:quartercircle"
: [ ] "caret:looped_arc"
: [ ] "caret:funnel"
: [ ] "caret:3/4-circle"
: [ ] "caret:retraced_half-bow"
:)
module namespace caret="http://fontane-nb.dariah.eu/Transfo/caret";
......@@ -26,12 +40,7 @@ let
$r := number($parameter[2]) * 100,
$height := '100',
$viewbox := '0 0 ' || string($l+ $r) || ' ' || $height,
$style :=
(: Sofern in @style kein margin-left angegeben, muss bei einem V der margin-left wert
gleich dem 1. Wert aus der Funktion sein. :)
if(contains($node/string(@style), "margin-left:"))
then $node/string(@style)
else $node/string(@style) || ';margin-left:-' || $parameter[1] || 'cm;'
$style := string-join(($node/tokenize(@style)[not(contains(., "margin-left"))], 'margin-left:-' || $parameter[1] || 'cm'), ";")
return
<svg xmlns="http://www.w3.org/2000/svg"
......@@ -62,11 +71,12 @@ return
switch($pos)
case 'pos-right' return
<svg xmlns="http://www.w3.org/2000/svg"
class="caret_half-bow_pos-right"
width="{$width}"
height="{$lineHeight - 0.2}cm"
viewBox="0 0 {$viewW} 100"
preserveAspectRatio="none"
style="left:{string(if($mlnum lt -0.19) then -0.2 else $mlnum)}cm;top: 3px;">
style="left:{string(if($mlnum lt -0.19) then -0.2 else $mlnum)}cm;">
<path
d="M30,95 C30,95 5,100 5,60 M 5,60 C 5,20 {$viewW div 2},10 {$viewW - 5},5"
fill="none"
......@@ -74,12 +84,12 @@ return
</svg>
case 'pos-left' return
<svg xmlns="http://www.w3.org/2000/svg"
width="{$width}" height="{$lineHeight - 0.2}cm"
viewBox="0 0 100 100"
preserveAspectRatio="none"
style="left:{$mlnum}cm;top: 7px;">
class="caret_half-bow_pos-left"
width="{$width}" height="{$lineHeight - 0.2}cm"
viewBox="0 0 100 100"
preserveAspectRatio="none"
style="left:{$mlnum}cm;">
<path
class="c-halfbow-posleft"
fill="none"
stroke-width="2"
d="M 78.36,37.00 C 96.91,33.55 108.45,20.36 86.00,10.45 86.18,10.55 72.27,2.73 4.55,9.09" />
......@@ -234,10 +244,12 @@ return
default return <xhtml:div>unknown parameter in function 'caret'</xhtml:div>
};
declare function caret:funnel() {
declare function caret:funnel($node) {
let $params := tokenize(substring-before(substring-after($node/replace(@rend, "cm", ""), '('), ')'), ',')
return
<svg xmlns="http://www.w3.org/2000/svg"
style="margin-left: -1cm;margin-bottom: 0.2cm;"
width="1.5cm"
width="{$params[1] + $params[2]}cm"
viewBox="0 0 350 231"
height="0.5cm">
<path
......@@ -250,7 +262,7 @@ declare function caret:funnel() {
id="left"
fill="none"
stroke="darkslategrey"
d="M 33.00,12.50 C 33.00,12.50 172.25,205.75 172.25,205.75 .75,167.50 -68.00,46.25 33.00,12.50"
d="M 33.00,12.50 C 33.00,12.50 172.25,205.75 172.25,205.75 .75,167.50 -68.00,46.25"
stroke-width="5"></path>
</svg>
};
......
......@@ -1706,7 +1706,7 @@ return
caret:quartercircle($node, $lineHeight)
case 'caret:3/4-circle' return '' (: class will be added in transfo:add :)
case 'caret:funnel' return
caret:funnel()
caret:funnel($node)
case 'caret:looped_arc' return ''
default return ()
};
......
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