Open laurenwalker opened 6 years ago
Thanks for writing this up, @laurenwalker . I'm happy to take this one.
Fun: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p
The start tag is required. The end tag may be omitted if the
<p>
element is immediately followed by an ...<ul>
...
So the browser is just following the rules. Perhaps docBook rules are different.
I guess it depends on how you interpret "immediately followed by".
This is kinda tricky. I thought up a couple options:
Option 1 Don't use <p>
tags at all in eml-text.xsl
I think the fix might be to use <div>
s instead of <p>
s since it's valid to have block-level elements inside <div>
s but not <p>
s. We lose some ground on the semantic web battle but I think it'd work.
Convert this EML
<para>
A paragraph that is interrupted by a list
<itemizedlist>
<listitem>
<para>
Interrupting list
</para>
</listitem>
</itemizedlist>
and finished with more text
</para>
to this HTML:
<div>
A paragraph that is interrupted by a list
<ul>
<li>
<div>
Interrupting list
</div>
</li>
</ul>
and finished with more text
</div>
It would seem possible to only convert some <p>
tags to <div>
s based upon their parent element but, due to the recursive nature of DocBook, I feel like I might not get this right.
Option 2: Just change our styling so it "looks" right?
I'm not sure how if I feel all-in for Option 1 but I think it's my current favorite. What do others think?
I thought I'd check what the "official" DocBook XSLs do with the above snippet:
<p>
A paragraph that is interrupted by a list
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Interrupting list
</p>
</li>
</ul>
</div>
<p>
and finished with more text
</p>
I looked at the underlying XSLs and I'm not totally sure how they achieve this behavior but it does work. Maybe we should just do this?
Looked into how DocBook handles this: It's trickier than my current XSL chops can handle. There are two relevant XSLs, with the magic appearing to be done by the unwrap.p
template:
Would we ever consider just importing the appropriate DocBook XSL suite here?
When an
itemizedList
is inside apara
, the HTML output is<p><ul>...</ul></p>
which is rendering incorrectly by the browser.Take this example HTML:
and open it in your browser and notice that the browser attempts to render it as:
In other words, the browser closes the paragraph tag before starting the unordered list and then adds an opening tag to the second paragraph tag. The
second paragraph
text is then "orphaned" text in the HTML doc.This is only an issue because it effects the way CSS is applied to the text (note the larger font size):
The EML snippet: