W3C home > Mailing lists > Public > html-tidy@w3.org > January to March 2016

Re: How can we support in-block newline break preservation

From: Jinkai Wang <jinkai.wang@oracle.com>
Date: Tue, 12 Jan 2016 10:42:17 -0800
To: "Richard A. O'Keefe" <ok@cs.otago.ac.nz>
Cc: html-tidy@w3.org
Message-ID: <56954909.6010308@oracle.com>
Thanks Richard, the introduction of tidy is actually not done by me. I 
will discuss with my colleagues to decide which way we are going.

Jinkai

On 1/11/2016 7:47 PM, Richard A. O'Keefe wrote:
> On 9/01/2016, at 8:29 am, Jinkai Wang <jinkai.wang@oracle.com> wrote:
>
>> To whom it may concern,
>> I'm an application developer from Oracle Service Cloud. Recently we have a concern about how to have the tidy  preserve line breaks in a multi-line text.
>> For example, this is the input:
>>
>> rnt_tidy (buf_in=0x933b430 "<DIV><SPAN STYLE=\"font-family:System Default;\">hello world : item 1\nitem 2\nitem 3. Finish</SPAN></DIV><DIV><SPAN STYLE=\"font-family:System Default;\">Jinkai Hello World</SPAN></DIV>", buf_out=0x9311690, bad_tag_check=1, tidy_opts_ptr=0xfff97114)
> Tidy respects (or at least tries very hard to respect)
> HTML semantics.  <div><span>...</span></div> is *not*
> a context where HTML semantics preserves white space.
>
> Since *browsers* don't preserve line breaks in this context,
> it is unclear why you want Tidy to do so.
>
> If the input is well-formed XML, you can force white space
> preservation by
> (1) adding the xml:space="preserve" attribute to the
> element(s) where you want this to happen and
> (2) telling tidy that the input is -xml
>
> This should work in a browser too.
>
> Alternatively, if there is a <span> where you want line breaks
> preserved, use a <pre> instead.  The semantics of HTML require
> line breaks preserved in <pre> elements.
>
> This will work in a browser too.
>
> For display purposes, you can use style="white-space: pre" to
> force line breaks to be preserved and white space not to be
> collapsed.  By experiment, Tidy doesn't notice that and will
> do its own white-space processing.  (This is CSS semantics,
> not HTML semantics, hence the difference.)
>
> I suspect that the fundamental problem is not with Tidy but
> with the way you are using HTML.
>
Received on Tuesday, 12 January 2016 18:42:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 12 January 2016 18:43:03 UTC