Page 1 of 1

XHTML5 Pretty Print

Posted: Fri Mar 22, 2013 11:20 pm
by jbzech
Hi,

I'm trying out some XHTML5 workflows, coming from DocBook. When I work in DocBook, the pretty print (Format and Indent) feature is incredibly helpful for navigating my documents. However, I'm struggling with the output of this same feature in XHTML5. Many block elements are being running together, rather than breaking to a new line as I'd expect from DocBook.

In my current document, XHTML elements such as <section>, <p>, etc all get run together.

EX: <section><p>Blah blah</p> <p>Blah so more.</p></section>

I've been searching for a way to customize this behavior to get the pretty print I'm used to, but I'm not having any luck. Is there a way to customize this?

Re: XHTML5 Pretty Print

Posted: Mon Mar 25, 2013 1:18 pm
by adrian
Hello,

I'm guessing you expect <section><p>Blah blah</p> <p>Blah so more.</p></section> to be broken into multiple lines, like this:

Code: Select all

<section>
    <p>Blah blah</p>
    <p>Blah so more.</p>
</section>

Currently this is not working because section is a mixed content element (allows both tags an text) in the XHTML5 schema used by Oxygen. This prevents Oxygen's format and indent (pretty print) feature from inserting whitespaces/line breaks (because they are considered significant) between two consecutive tags (<section><p> and </p></section>). This is determined by the option Schema aware format and indent is enabled (Options > Preferences, Editor / Format / XML).
Disabling this option will cause the format and indent to ignore this and break the lines as you expect. However, I would recommend setting this option back on afterwards, because it affects all types of XML documents, not just XHTML5.

I've submitted an issue to treat this differently for XHTML5. This will be analyzed and implemented in a future version of Oxygen.

Regards,
Adrian

Re: XHTML5 Pretty Print

Posted: Mon Mar 25, 2013 5:02 pm
by jbzech
Thanks, Adrian. I guess I didn't realize <section> is mixed. Seems strange to make it so (but out of our hands). Your suggestion works perfectly, though.

I could set this particular project to use Project Options and turn off Schema Aware Indent for just XHTML5-based projects, right? I'll give that a try.

Re: XHTML5 Pretty Print

Posted: Mon Mar 25, 2013 5:27 pm
by adrian
Hi,

Yes, if you're using separate projects for XHTML5, you can disable that option only for those projects (select Project Options).

Do note that disabling that option makes the formatting engine blind to mixed and text only elements specified in the schema, so it's possible it will add whitespaces/line breaks in inappropriate places. I recommend to always check if it breaks the lines correctly.

Regards,
Adrian