Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

tidy

marklogic

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?

like image 866
RyanS Avatar asked Nov 04 '22 15:11

RyanS


1 Answers

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!

like image 64
Dyne Avatar answered Nov 16 '22 18:11

Dyne