-
Notifications
You must be signed in to change notification settings - Fork 259
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
Indent HTML lists correctly (Issue 1073) #1170
Conversation
Some debugging and polish needed.
Some variables need tweaking. Needs testing. Code reuse unsatisfactory.
Some variables need tweaking. Needs testing. Code reuse unsatisfactory.
Potentially significant issues with tests: 1. test_html_ln_outside_p - IndexError: list index out of range. 2. test_html_ol_ul_line_height - actual distance between lines differs slightly from expected. Code reuse unsatisfactory.
Need feedback for handling <dd> and <blockquote>. Potentially significant issues with tests: 1. test_html_ol_ul_line_height - actual distance between lines differs slightly from expected. Need feedback for whether or not the new indentation that contradicts old tests is satisfactory. Code reuse unsatisfactory. Need feedback.
Bug present: bullets are made one per line instead of one per paragraph. Saving progress before introducing a `Bullet` class.
Feature implemented. Testing and adjustments of tests needed.
Prevented from `Paragraph.top_margin` being added to `pdf.y` of first lines of paragraphs with bullets.
Prevented from `Paragraph.top_margin` being added to `pdf.y` of first lines of paragraphs with bullets. `<ul>` and `<ol>` tags now cause a creation of a paragraph with the string `\n` being used to generate a fragment of the height `list_pseudo_margin`. Adjusted defaults for `li_tag_indent`.
Changed `Paragraph.generate_bullet_frag()` into `generate_bullet_frag_and_tl`, and made it also generate the bullet text line. Dealing with the issue of inappropriately large distance between `<dt>` and their child `<dd>` elements when `Paragraph.top_margin` is 0.
Changed `Paragraph.generate_bullet_frag()` into `generate_bullet_frag_and_tl`, and made it also generate the bullet text line.
# Conflicts: # fpdf/html.py
Adjusted old tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work so far, but the devil is in the detail...
As I'm sure you've noticed, the interplay between the HTML parser, text regions, line wrapping, and rendering is non-trivial. I've added some pointers of how to fix the parts that don't quite add up yet.
…`list_vertical_margin`. Removed the `MultiLineBreak.indent` attribute. Added a test for long `<ol>` bullets.
# Conflicts: # CHANGELOG.md
Added `test_html_list_vertical_margin`. Fixed the non-assignment of `HTML2FPDF.list_vertical_margin` when the constructor argument `list_vertical_margin` is not None.
…agraph()`. Updated relevant docstring and `TextRegion.md` documentation. Adjusted `test_bulleted_paragraphs` to remove mentions of `rel_y_displacement`, changed instances of string `"rel_x_displacement"` to `bullet_r_margin` and introduced usage of `case["bullet_r_margin"]` in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, just two last clean-up items left, and then this will be ready to merge!
Quite an impressive list of fixes in the change log, which resulted in many intricate details to take care about.
Not sure how that happened, considering that I was accepting changes from |
I think I've merged #1198 after your last rebase. Just do another one. |
Wait, in 69c4107 you seem to have reverted all of your changes to test_html.py. You'll want to restore those, except for |
When you do a rebase and there are conflicts, you usually need to resolve those manually. The files will contain marked sections that show the differences, and you can chose the right parts for each section. |
I am aware. I opted to go for blanket-accepting changes from Trying to figure out how to re-do the merge without destroying the history. (Although, yeah, I'm aware that I can just copy the relevant stuff and paste it manually. I would still rather try to find out how to deal with situations like these.) |
Don't worry about the history. We flatten everything into a single commit anyway when merging a PR. |
# Conflicts: # test/html/html_customize_ul.pdf # test/html/test_html.py
Correctly this time.
b880e1d
to
691ad2b
Compare
Merged. Thanks for the useful contribution, @lcgeneralprojects ! 👍 |
@allcontributors please add @lcgeneralprojects for bug, code |
I've put up a pull request to add @lcgeneralprojects! 🎉 |
Congrats on successfully completing this pull request. This was no small feat! You changed some complex parts of the code and despite the numerous iterations you showed patience and dedication to push through. Thank you for your hard work and perseverance. Looking forward to more collaborations in the future! |
Fixes #1073
Implements paragraph indentation via adjustments of
pdf.x
instead of using a natural number of whitespaces.Breaks up list items into individual paragraphs.
Checklist:
The GitHub pipeline is OK (green),
meaning that both
pylint
(static code analyzer) andblack
(code formatter) are happy with the changes of this PR.A unit test is covering the code added / modified by this PR
This PR is ready to be merged
In case of a new feature, docstrings have been added, with also some documentation in the
docs/
folderA mention of the change is present in
CHANGELOG.md
Not sure how to actually name the
HTML2FPDF.list_pseudo_margin
attribute. It is used for determining the height of the\n
line created when a<ul>
or<ol>
starting tag is handled.Should the re-implementation of paragraph indentation be reflected in a doctstring, even though the
tag_indents
parameter ofwrite_html()
has not been touched? If so, where should it be placed?By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.