Reputation: 51
With the new doctype and elements that are part of HTML5, how do you get xdmp:tidy()
to recognize those in HTML5?
If I have an html page that contains something like:
<!DOCTYPE html>
<html>
<header>blah</header>
<section>blah</section>
and then try something like:
xdmp:tidy(xdmp:document-get("home.html"))
I get errors like:
<section> is not recognized! discarding unexpected <section>
<header> is not recognized! discarding unexpected <header>
Are there some options I can send to xdmp:tidy()
to get it to handle it?
Upvotes: 5
Views: 1510
Reputation: 2961
The rest of this discussion moved over to the marklogic mailing list at http://markmail.org/thread/emwua43mg63wxbno
This does produce warnings but seems to work nonetheless:
xquery version "1.0-ml";
let $htmlstring :=
'<html>
<header>blah</header>
<section>blah</section>
<p>hello</p>
</html>'
return
xdmp:tidy($htmlstring,
<options xmlns="xdmp:tidy">
<new-inline-tags>header section</new-inline-tags>
<new-blocklevel-tags>header section</new-blocklevel-tags>
</options>)
Upvotes: 1
Reputation: 21
Try using the new-blocklevel-tags option that specifies the new HTML5 tags. You can include multiple elements by separating them with a comma or space. You should get the expected output with no errors, but there will still be warnings.
Try this in cq:
xdmp:tidy(xdmp:document-get("home.html"), <options xmlns="xdmp:tidy"><new-blocklevel-tags>header section</new-blocklevel-tags></options>)
Click here for a good reference about adding various tags (block level, inline, empty) that should work as options in xdmp:tidy. The same information is here, but it's a bit harder to get to, there's so many options!
Upvotes: 1