How to get xdmp: tidy () to remove HTML5?

With the new doctype and elements that are part of HTML5, how do you get xdmp:tidy()to recognize in HTML5?

If I have an html page containing 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 any options that I can send to xdmp:tidy()to process it?

+5
source share
2 answers

Try using the new-blocklevel-tags parameter, which specifies the new HTML5 tags. You can include multiple elements by separating them with a comma or space. You should get the expected result without 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>)

( , , ), xdmp: tidy. , , !

+1

marklogic http://markmail.org/thread/emwua43mg63wxbno


, , , :

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>)
+1

All Articles