Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SADE
SADE
Commits
5257b92e
Commit
5257b92e
authored
Jan 21, 2019
by
mrodzis
💪
Committed by
Mathias Goebel
Jan 21, 2019
Browse files
Add a fix for Markdown parser error (closes
#48
)
parent
c352a193
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/multiviewer.xqm
View file @
5257b92e
...
...
@@ -116,10 +116,11 @@ declare function multiviewer:markdown($docpath as xs:string) as item()* {
let $inputDoc := util:binary-doc( $docpath )
let $input := util:binary-to-string($inputDoc)
let $markdown := markdown:parse($input)
let $fixed-markdown := multiviewer:fix-markdown($markdown)
return
<xhtml:div class="markdown">
{local:markdownTransform($markdown)}
{local:markdownTransform($
fixed-
markdown)}
</xhtml:div>
};
...
...
@@ -137,7 +138,7 @@ declare function local:markdownTransform($nodes) {
for $node in $nodes
return
if( $node/local-name() = "h1" ) then
(: the typesw
t
ich did not cast h1. :)
(: the typeswi
t
ch did not cast h1. :)
<xhtml:h2 class="block-header">
<xhtml:span class="title">{ $node/node() }</xhtml:span>
</xhtml:h2>
...
...
@@ -198,3 +199,36 @@ declare function multiviewer:LEGACY-choose-xsl-and-transform($doc, $model as map
return $html
};
(:~
: This fix is necessary due to some bug in eXist's Markdown parser which doesn't
: display nested XML elements.
:
: Apart from that the parser also seems to have problems with XML elements that
: only include a text node.
: This function doesn't solve the second problem, but at least nested elements
: are displayed.
:
: @see https://gitlab.gwdg.de/SADE/SADE/issues/48
: :)
declare function multiviewer:fix-markdown($nodes as node()*) {
for $node in $nodes return
typeswitch ($node)
case text() return
$node
case element(pre) return
element {node-name($node)} {
$node/@*,
serialize($node/node())
=> replace("&lt;", "<")
=> replace("&gt;", ">")
=> replace("<(/){0,1}OBJECT>", "")
}
default return
element {node-name($node)} {
$node/@*,
multiviewer:fix-markdown($node/node())
}
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment