On Fri, Jul 11, 2025 at 4:30 PM Leif wrote:
This is just a boring question from me: Are you saying that the «algorithm» that I quoted above from MDN is incorrect? Or that I did read it incorrectly?

You quoted this MDN algorithm correctly and you read it correctly.

 1. All newline characters are removed.
 2. All tab characters are converted into space characters.
 3. All leading and trailing space characters are removed.
 4. All contiguous space characters are collapsed into a single space
    character.

May be it's just me who simply does not understand this algorithm. See below.



As I read the above, there would be no single character *within* a line, after the above algorithm has been run.
But note that when I said «no single character *within* a line», I had this 
example in mind:

<p>
<a>b</a>
<c>d</d>
</p>

I did not say that the above would remove any spaces in this example:

<p> <a>b</a> <c>d</d> </p>

First of all, I see no semantic difference between, for example,

---
<p>
  <b>Hello</b>
  beautiful
  <i>world!</i>
</p>
---

and

---
<p>   <b>Hello</b>    beautiful   <i>world!</i>   </p>
---

If I apply the MDN algorithm, depending on how I read this algorithm, I'll expect this:

---
<p><b>Hello</b>beautiful<i>world!</i></p>
---

or this:

---
<p><b>Hello</b> beautiful <i>world!</i></p>
---

(XXE gives you this:
<p> <b>Hello</b> beautiful <i>world!</i> </p>)

Not sure because I don't know if this algorithm applies to each character sequence contained in the <p> element taken one after the other or to the <p> element as a whole.

Anyway, we will not implement the MDN algorithm in XXE.



First reaction: Would it not also be possible to apply some kind of XSLT (or CSS) in 
order to simply set text nodes that are direct child of <body> to display:none 
in the editor?

No. Text nodes cannot be styled in XXE.




Second reaction: Thanks for this solution. I think it would make sense to 
somehow include this solution as an option in the XHTML preferences. As it is 
easy to forget such solutions. Here are some good reasons to do implement such 
a thing:

    For a structured XML editor like XXE, regardless of what the HTML5 spec permits, there is hardly ever a 
reason for XXE’s users to add text as direct children of <body>, <article> or <section>, 
<header> or<footer>.

That's right.




    It would make XXE users stop cursing the Universe (or XXE or XhtML 
rendering rules) for those empty lines that pops up.

This never happens to me as an XXE user (who exclusively uses XXE to create and modify my XML documents and HTML pages). However I feel sorry when I look at the HTML source of documents saved by XXE because they are indeed poorly indented. Fortunately for me, I very rarely do this.




    There would be one less reason to discuss XXE’s source code formatting.

Indeed.



    XXE’s current behavior has several times caused us to type text (and not just space 
characters) as direct children of the <body> elements (and other elements where such 
direct text nodes are illogical). Why? Because it is difficult to spot that you are 
actually typing a direct child text node, instead of typing inside a <p> element.

This never happens to me as an XXE user. An XHTML5 <body> found in XXE XHTML5 templates looks like this (hence no text placeholders in <body> where you could type something):
---
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
    <meta charset="UTF-8"/>
    <title></title>
  </head>
  <body><p></p></body>
</html>
---

and if you use Edit|Replace to replace an XHTML5 <body> by another <body>, you get this (hence no text placeholders in <body> where you could type something):
---
<body></body>
---




I would make the above XSD variant (with support for <section>, <article> etc) 
the default, and offer users to permit text nodes as direct children, if they explitly ask 
for it.

I'm sorry but we prefer to stick to the WHATWG spec as closely as possible (see https://html.spec.whatwg.org/multipage/). XMLmind Software is not responsible for these specs. We do not discuss them. We just do our best to implement them.

Note that almost all XML vocabularies have their quirks. This is not specific to XHTML5. For example, DocBook allows a <table> to be a direct child element of a <para>. Who would want this?


--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to