Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty title change rendering of siblings #181

Open
alfsb opened this issue Dec 20, 2024 · 6 comments
Open

Empty title change rendering of siblings #181

alfsb opened this issue Dec 20, 2024 · 6 comments

Comments

@alfsb
Copy link
Member

alfsb commented Dec 20, 2024

I'm about to merge an fixup that may start including empty <title>s in manual, in an effort to translations can be build able for more time, particully at times that doc-en is being heavy updated.

The fixup <title></title><simpara>%failed xi:xinclude%</simpara> (empty title) is saved on .manual.xml as:

<refsect1 role="parameters">
 <title/>
 <simpara>%failed xi:xinclude%</simpara>
</refsect1

and is rendered by php phd/render.php --format bigxhtml as:

<div class="refsect1 parameters" id="refsect1-function.bcdivmod-parameters">
  <h3 class="title"><p class="simpara">%failed xi:xinclude%</p></h3>
</div>

Instead of:

<div class="refsect1 parameters" id="refsect1-function.bcdivmod-parameters">
  <h3 class="title"></h3>
  <p class="simpara">%failed xi:xinclude%</p>
</div>

In other words, empty <title> causes their siblings to be rendered inside the title, instead of around it. I'm worried that this can swallows entire sections inside titles. In the meanwhile, and to workaround this, I'm placing some placeholder texts in fixup titles, but these ends rendered in manual.

@haszi
Copy link
Contributor

haszi commented Dec 22, 2024

@alfsb I wrote a test for this in PhD (see here) but could not recreate the output you've got.

I've tried php phd/render.php --format bigxhtml, php phd/render.php --Generic --format bigxhtml and php phd/render.php --PHP --format bigxhtml but neither produced that output. Could you share the xml markup somehow so I can try rendering that?

@alfsb
Copy link
Member Author

alfsb commented Dec 30, 2024

Could you share the xml markup somehow so I can try rendering that?

It's possible to generate it locally. Replace this line with:

$fixup = "<title></title><simpara>FAILEDXINCLUDE</simpara>";

Then clone doc-it as it, and configure.php -q --with-lang=it. After configure:

$ grep -B 2 -A 2 FAILEDXINCLUDE doc-base/.manual.xml 

 <refsect1 role="parameters">
  <title/><simpara>FAILEDXINCLUDE</simpara>
 </refsect1>

In the source, it does not get included inside title:

$ grep -B 2 -A 2 FAILEDXINCLUDE output/big-xhtml.html 

 <div class="refsect1 parameters" id="refsect1-function.bcdivmod-parameters">
  <h3 class="title"/><p class="simpara">FAILEDXINCLUDE</p>
 </div>

But it get rendered as the same as title:
image

In DOM:
image

Probably because HTML <H3> are not expected to be autoclosed?

@alfsb
Copy link
Member Author

alfsb commented Dec 30, 2024

Without changing configure.php, it would DOM and render ok:

image

image

@haszi
Copy link
Contributor

haszi commented Dec 30, 2024

If I understand this correctly, the issue is that a valid self-closing XML/XHTML tag is not a valid HTML tag and as browsers render the PhD-generated pages as HTML, the browsers decide where to close these invalid HTML tags (probably before closing the self-closing tags' parent tags).

If that is so, the easiest fix for PhD would be to render the non-HTML self-closing tags as pairs of opening-closing tags.

@alfsb
Copy link
Member Author

alfsb commented Jan 2, 2025

The fix may resides on saving the final HTML files with LIBXML_NOEMPTYTAG, or possibly better, saving HTML files with DOMDocument saveHTML()/saveHTMLFile()

@alfsb
Copy link
Member Author

alfsb commented Jan 6, 2025

Also, this error is not detected by the test. As you said, this is basically a rendering issue on browsers, so it does not shows in saved files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants