Skip to content

Conversation

@gmischler
Copy link

@gmischler gmischler commented Jul 6, 2024

Fixes:

  • paragraph top_margin was ignored in the presence of a bullet (see discussion in write_html(): homogenization in handling of tag_styles + new optional arg font_family #1217)
  • indented paragraphs weren't made narrower, but the whole paragraph just shifted to the right.
  • Converting legacy _ln() for <li> to top_margin value in html.py. Some HTML tests need a t_margin value added to their TextStyle to avoid automatic empty lines in _new_paragraph().
  • While testing the previous item, it became obvious that the ln() of the text regions didn't always do what it is supposed to do with an explicit height given. This resulted in the "2mm" specification to simply be ignored, so that the layout of lists will now include a slightly wider gap, as was initially intended.

Checklist:

  • The GitHub pipeline is OK (green),
    meaning that both pylint (static code analyzer) and black (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
  • [NA] In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder
  • A mention of the change is present in CHANGELOG.md

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

Copy link
Member

@Lucas-C Lucas-C left a comment

Choose a reason for hiding this comment

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

You mentioned a change in fpdf/html.py in your PR description, but I do not see it in the PR diff 🙂

self.balance = balance
total_w = self.extents.right - self.extents.left
col_width = (total_w - (ncols - 1) * gutter) / ncols
self.h_margins = (pdf.c_margin, pdf.c_margin)
Copy link
Member

Choose a reason for hiding this comment

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

Given the current usage of this attribute, I wonder if having 2 distincts attributes .l_margin & .r_margin would not make the code & intent clearer there? 🙂

Comment on lines +333 to +335
"""Ensure that the top/bottom margins work with indented/bulleted
paragraphs.
Ensure that indented paragraphs have a reduced total width.
Copy link
Member

Choose a reason for hiding this comment

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

Nice test 👍

self.pdf.c_margin + (self.indent - fragments_width - bullet_r_margin),
self.pdf.c_margin,
self._region.h_margins[0]
+ (self.indent - fragments_width - bullet_r_margin),
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't indent=self.indent be provided there, instead of adding self.indent to the left margin?

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

Successfully merging this pull request may close these issues.

2 participants