Commit 1098cbcd authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

remove map for character replacement; use dokuwiki syntax highlighting

parent eea5a7e7
...@@ -134,6 +134,10 @@ return ...@@ -134,6 +134,10 @@ return
else xs:int(-1) else xs:int(-1)
}; };
declare function wiki:lastModProcessor() {
xmldb:last-modified("/db/apps/SADE/modules/wiki", "wiki.xqm")
};
declare function wiki:lock-resource($id as xs:string) { declare function wiki:lock-resource($id as xs:string) {
wiki:login(), wiki:login(),
xmldb:store('/sade-projects/textgrid/data/xml/doku/', $id || ".lock.xml", <lock/>) xmldb:store('/sade-projects/textgrid/data/xml/doku/', $id || ".lock.xml", <lock/>)
...@@ -215,6 +219,7 @@ declare function wiki:dokuwikiparser($nodes as node()*){ ...@@ -215,6 +219,7 @@ declare function wiki:dokuwikiparser($nodes as node()*){
}; };
declare function wiki:dokuwikiparser($nodes as node()*, $char as xs:boolean){ declare function wiki:dokuwikiparser($nodes as node()*, $char as xs:boolean){
let $char := false()
for $node in $nodes return for $node in $nodes return
typeswitch($node) typeswitch($node)
case element(h1) case element(h1)
...@@ -339,15 +344,16 @@ for $node in $nodes return ...@@ -339,15 +344,16 @@ for $node in $nodes return
} }
case element (pre) case element (pre)
return return
let $code := try { $node
string($node) => parse-xml() (: let $code := try {:)
} catch * { (: string($node) => parse-xml():)
try { (: } catch * {:)
("<temporary-wrap>" || string($node) || "</temporary-wrap>") => parse-xml() (: try {:)
} catch * {<temporary-wrap>{string($node)}</temporary-wrap>} (: ("<temporary-wrap>" || string($node) || "</temporary-wrap>") => parse-xml():)
} (: } catch * {<temporary-wrap>{string($node)}</temporary-wrap>}:)
return (: }:)
code:main($code) => wiki:remove-temporary-root() => functx:change-element-ns-deep("http://www.functx.com", "") (: return:)
(: code:main($code) => wiki:remove-temporary-root() => functx:change-element-ns-deep("http://www.w3.org/1999/xhtml", ""):)
case element (em) case element (em)
return return
...@@ -375,44 +381,7 @@ for $node in $nodes return ...@@ -375,44 +381,7 @@ for $node in $nodes return
attribute data-original { 'public/doku/' || $node/substring-after(@data-original, 'fontane:') }, attribute data-original { 'public/doku/' || $node/substring-after(@data-original, 'fontane:') },
attribute src {"public/img/loader.svg"} attribute src {"public/img/loader.svg"}
}, () ) }, () )
case text() return case text() return $node
(: Circa 1,2 Mio mal wird hier replace() aufgerufen. :)
let $map := map {
'ö' : 'ö',
'ä' : 'Ä',
'ü' : 'ü',
'Ãœ' : 'Ü',
'ß' : 'ß',
'„': '„',
'“': '“',
'✓': '“',
'Å¿' : 'ſ',
'↯': '↯',
'•': '',
'–': '–',
'—': '—',
'−': '−',
'…': '…',
'Ö' : 'Ö',
'⸗': '⸗',
'‘': '‘',
'‚': ',',
'é' : 'é',
'’': '’',
'â•’': '╒',
'›': '›',
'‹': '‹',
'ë' : 'ë',
'ô' : 'ô',
'ï' : 'ï',
'ḯ': 'ḯ',
'ÿ' : 'ÿ',
'½' : '½',
'°' : '°'
}
return
if($char) then $node else
wiki:asciiutf8($node, $map)
default return wiki:dokuwikiparser($node/node(), $char) default return wiki:dokuwikiparser($node/node(), $char)
(: case text() return $node:) (: case text() return $node:)
(: default return wiki:dokuwikiparser($node/node()):) (: default return wiki:dokuwikiparser($node/node()):)
...@@ -425,62 +394,10 @@ for $node in $nodes return ...@@ -425,62 +394,10 @@ for $node in $nodes return
wiki:dokuwikiTOC($node/node()) wiki:dokuwikiTOC($node/node())
case element() return case element() return
element { $node/local-name() } { $node/@*[local-name() != 'class'], wiki:dokuwikiTOC($node/node()) } element { $node/local-name() } { $node/@*[local-name() != 'class'], wiki:dokuwikiTOC($node/node()) }
case text() return case text() return $node
let $map := map {
'ö' : 'ö',
'ä' : 'Ä',
'ü' : 'ü',
'Ãœ' : 'Ü',
'ß' : 'ß',
'¶ÃŸ': 'ß',
'„': '„',
'“': '“',
'✓': '“',
'Å¿' : 'ſ',
'↯': '↯',
'•': '',
'–': '–',
'—': '—',
'−': '−',
'…': '…',
'Ö' : 'Ö',
'⸗': '⸗',
'‘': '‘',
'‚': ',',
'é' : 'é',
'’': '’',
'â•’': '╒',
'›': '›',
'‹': '‹',
'ë' : 'ë',
'ô' : 'ô',
'ï' : 'ï',
'ḯ': 'ḯ',
'ÿ' : 'ÿ',
'½' : '½',
'°' : '°',
'' : ''
}
return
wiki:asciiutf8($node, $map)
default return wiki:dokuwikiTOC($node/node()) default return wiki:dokuwikiTOC($node/node())
}; };
declare function wiki:asciiutf8($text as text(), $map as map()) as text(){
let $pattern := map:keys($map)[1]
let $replacement := map:get( $map, $pattern )
let $newText := text { replace($text, $pattern, $replacement) }
let $newMap := map:remove( $map, $pattern )
return
if(count(map:keys($newMap)) gt 0) then wiki:asciiutf8($newText, $newMap)
else $newText
};
declare function wiki:dokuwikiImageReload($id as xs:string) { declare function wiki:dokuwikiImageReload($id as xs:string) {
try { try {
let $path := system:get-exist-home() || '/tools/jetty/webapps/portal/public/doku/' let $path := system:get-exist-home() || '/tools/jetty/webapps/portal/public/doku/'
......
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