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

fix(text): Render list items correctly #1137

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kesara
Copy link
Member

@kesara kesara commented Jul 9, 2024

Fixes #1135
Fixes #1138

See changes made in 3712523 for context.

This change can affect if ol is used inside a li as the first element and the li element is inside another ol element.

I could not find any published RFCs with XML that match the above condition.

These are the RFCs that I found that use ol as the first element in li:

  • RFC8679
  • RFC8687

I didn't notice any changes in text output due to this change. But there are a few minor changes (with spacing) due to changes over the years.

xml2rfc/writers/text.py Outdated Show resolved Hide resolved
@rjsparks
Copy link
Member

rjsparks commented Jul 9, 2024

I think it's worth trying to change things such that generatiing

   4.  4.1  Sublist with '%p' parent counter element in the list
            counter, item one

       4.2  Item two.

       4.3  Item three.

we generate

   4. 

       4.1  Sublist with '%p' parent counter element in the list
            counter, item one

       4.2  Item two.

       4.3  Item three.

Unless that breaks the intended fix for the rfc-to-be.

@cabo
Copy link
Contributor

cabo commented Jul 9, 2024

What is better about that superfluous empty line?

(You can probably have one if you want with <br>)

@rjsparks
Copy link
Member

rjsparks commented Jul 9, 2024

Look at it in context with the rest of the nested <ol> above it in the test document:

4. Ordered list with sub-elements
1. Ordered list, first bullet. Indent="6".
2. Ordered list, second bullet. Indent="6". Text only. Octavio
fuit, cum illam severitatem in eo non arbitrantur. erunt etiam,
et ii quidem eruditi Graecis litteris, contemnentes Latinas,
qui se plane Graecum dici velit, ut a Scaevola est praetore
salutatus Athenis Albucius. In physicis plurimum posuit. ea
scientia et verborum vis et natura orationis et consequentium
repugnantiumve ratio potest perspici.
3. Ordered list, third bullet, element t. Quid? si nos non
interpretum fungimur munere, sed tuemur ea, quae audiebamus,
conferebamus, neque erat umquam controversia, quid ego
intellegerem, sed quid probarem. Extremum autem esse bonorum eum
voluptate vivere. Sic faciam igitur, inquit: unam rem explicabo,
eamque maximam, de physicis alias, et quidem locis pluribus.
Author, et al. Expires 13 January 2019 [Page 7]
Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018
Ordered list, third bullet, second element:
+-------------------------------------------+
| |
| Artwork |
| |
+-------------------------------------------+
Ordered list, third bullet, third element: Definition list,
element dt.
Element dd. Nisi mihi Phaedrum, inquam, tu mentitum aut
Zenonem misisti.
Ordered list, third bullet, fourth element:
Figure
Figure
Figure
Figure 2: Some figure name
1. Ordered list, third bullet, fifth element: Ordered list,
element li. Text only.
2. Ordered list, third bullet, fifth element: Ordered list,
element t. Nam cum ad me de virtute misisti. Quae est enim
contra Cyrenaicos satis acute, nihil ad iucunde vivendum
reperiri posse, quod coniunctione tali sit aptius. Quae etsi
mihi nullo modo nec divelli nec distrahi possint, sic de
iustitia iudicandum est, quae non modo non impediri rationem
amicitiae, si summum bonum diceret, primum in eo essent.
# Ordered list, third bullet, sixth element
A = 1;
* Ordered list, third bullet, seventh element: Unordered list,
element li. Text only.
* Element t. Atque ut odia, invidiae, despicationes adversantur
voluptatibus, sic amicitiae non posse iucunde vivi, nisi
sapienter, honeste iusteque vivatur, nec sapienter, honeste,
iuste, nisi iucunde. Democritea dicit perpauca mutans, sed
ita, ut ea, quae audiebamus, conferebamus, neque erat umquam
controversia, quid ego intellegerem, sed quid probarem. See
Appendix A, Section 3.1 of
[I-D.levkowetz-xml2rfc-v3-implementation-notes] and also
Appendix A.1 of Key Words Case Ambiguity [RFC8174] / Key Words
Case Ambiguity [RFC8174], Appendix A.1 / Key Words Case
Ambiguity [RFC8174] (Appendix A.1).
Author, et al. Expires 13 January 2019 [Page 8]
Internet-Draft Xml2rfc Vocabulary V3 Elements July 2018
4. 4.1 Sublist with '%p' parent counter element in the list
counter, item one
4.2 Item two.
4.3 Item three.
and consider what would happen if there were any text between the <li> and <ol> at
<li>
<ol type="%p%d">

@kesara kesara marked this pull request as draft July 10, 2024 00:56
@kesara
Copy link
Member Author

kesara commented Jul 10, 2024

I have converted PR to a draft.
The changes from e889f93 add a new line when with the list style to both ol and ul.
This was skipped previously.
Specifically, this adds list style + new line when li contains an artwork, figure, or sourcecode as the first child.
See how this changed test outputs in ca8286a
Note that the test output has date changes and multiple content changes propagated because of the addition of new lines.

e889f93 fixes #1138

@kesara kesara changed the title fix: Render ol items correctly fix(text): Render ol items correctly Jul 10, 2024
@@ -1092,6 +1093,7 @@ Unnumbered section
* Indent="5". “The heaviest penalty for declining to rule is to
be ruled by someone inferior to yourself.” Πολιτεία

*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now this is perhaps unfortunate. What we've uncovered is, I think, a decision to special case the rendering of nested lists without leading text that doesn't generalize to all possible uses of such things, and we're just toggling cross the edges of that earlier decision.

Has the previous side-effect of no leading marker been used in this case previously? Is it ok to make this change (since getting the behavior of that side-effect is possible in better defined ways, I _think)?

@cabo - what do you think the right thing to do with this is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a list of RFCs that has ul tag inside a li as first element:

rfc8668.xml
rfc8742.xml
rfc8811.xml
rfc8793.xml
rfc8927.xml
rfc8677.xml
rfc8667.xml
rfc8698.xml
rfc9195.xml

All these use empty="true" in parent ul, so no new * gets added but there's a bug in the suggested fix because it adds a new line. I'll fix that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cabo - what do you think the right thing to do with this is?

I don't think it is ever correct to add a new line that the author didn't want.
If it is needed, the author can put it in, but it never should be forced on them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a fix to handle empty="true".
See 11ef6ac and fe595b1

Copy link
Member Author

@kesara kesara Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjsparks & @cabo For context, HTML output doesn't add a new line.
Proposed changes don't affect HTML output.
Screenshot 2024-07-12 at 19 49 28

Copy link
Member

@rjsparks rjsparks Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And HTML has the marker, so the text should too - that convinces me that (except for the newline that Carsten doesn't want) the current proposed change is right.

So people looking at this later can see it in context, could you also paste the section of html analogous to the 4. 4.1 change in the text in this thread?

Copy link
Member Author

@kesara kesara Jul 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjsparks ol has a new line in HTML output:
Screenshot 2024-07-13 at 14 23 39

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjsparks The above screenshot is from Firefox and that might not be showing the correct rending. See #1158

@kesara kesara changed the title fix(text): Render ol items correctly fix(text): Render list items correctly Sep 12, 2024
@kesara kesara added the rpat Issues needing attention from RFC Production Advisory Team label Sep 12, 2024
@kesara kesara marked this pull request as ready for review December 9, 2024 00:25
@kesara kesara requested a review from rjsparks December 9, 2024 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rpat Issues needing attention from RFC Production Advisory Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing style in <ul> missing number in text output of <ol>
3 participants