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

Handle target-* #604

Merged
merged 58 commits into from May 1, 2018
Merged

Handle target-* #604

merged 58 commits into from May 1, 2018

Conversation

liZe
Copy link
Member

@liZe liZe commented Mar 27, 2018

Replaces #572.

Tontyna and others added 27 commits February 11, 2018 22:42
caused by wrong parameters for LOGGER.debug -- relicts from
using print()
Modified function `validate_content_list_token()` in
weasyprint/css/validation.py so that it can be used to validate
the css properties `content`, `string-set` and `bookmark-label`.
Preparation for code-reduction in the box-building steps and
allowing target-*() not only in `content` but also in `string-set`
and `bookmark-label`.

Therefore weasyprint/css/computed_values.py now computes the
`<content-list>`s of `string-set` and `bookmark-label` in the same
way as it already does for `content`.
In the box building and page layout steps, the CSS properties
`content`, `string-set` and `bookmark-label` now use the same code
to evaluate their <content-list> values.
As a concequence the target-* functions work for all three properties.
According to the spec, the string-set property has a computed value equal to
the specified value, we can't pre-compute values even if it looks easier this
way.
@liZe
Copy link
Member Author

liZe commented Mar 27, 2018

@Tontyna As said in #572, I've merged your PR in a branch and cleaned many things, including:

  • more pythonic code and docstrings,
  • don't use a global target collector,
  • removed debugging info.

Looks like tests pass 😄.

Thanks a lot for your work, that was really useful with good ideas and a clean global logic!

There's a lot of work to do before merging:

  • Some functions get an optional target_collector because some boxes can't be anchors. I'm pretty sure that I've missed some parts of the code when it's needed (yes, we'll probably need to add this target_collector parameter in even more functions).
  • The target_collectorcan probably be used in / instead of _gather_links_and_bookmarks (not sure about this, I have to check again but I'm really tired right now 😉).
  • We have to follow the specs more carefully about the content property, attr() and other CSS functions. The tricky part is to discard erratic functions sometimes during validation and sometimes during values computation. Moreover, there are subtle syntax changes in attr() and new values in content.
  • And of course, we have to write some serious tests 😉.

@liZe liZe added this to the 43 milestone Mar 28, 2018
@liZe
Copy link
Member Author

liZe commented Apr 4, 2018

I've just realized my explanations are probably not clear at all, and that you probably need to update your fork with the latest git commits of this target-collector branch. Here's how to update your GitHub fork, that'll hopefully be useful!

@liZe
Copy link
Member Author

liZe commented Apr 4, 2018

My next job is to move the computing part from build.py into computed_values.py

I've already done half of the work, pushing in the next days.

@liZe
Copy link
Member Author

liZe commented Apr 18, 2018

@Tontyna I'm happy with the current state of this branch, I only miss tests of bad syntaxes for target-* functions (the good ones are tested). I'll merge it soon.

@Tontyna
Copy link
Contributor

Tontyna commented Apr 19, 2018

Sorry for being absent so long -- had holidays, a flu and then a pile of undone jobs...
The list of commit messages looks promising. Will explore the branch this weekend and give feedback.

@Tontyna
Copy link
Contributor

Tontyna commented May 1, 2018

I only miss tests of bad syntaxes

I can imagine thousands of *bad syntaxes". But I'm not good at writing unit-tests. Actually I parsed a lot of rather ugly html snippets -- WeasyPrint bravely handled the valid rules and discarded the invalid ones and of course the not-yet-supported, too.

Think the only missing test for content would be a css to cover the spec's comma separated URI list and the text for speech, something like content: url(xxx), url(yyy), <content-list> / "alternate text". And a style containing leader(). Just to prove that WeasyPrint eats them up / as a starting point for future implementation...
And maybe a test for string-set setting multiple strings.

All in all: I consider this PR is ready to merge.

@liZe
Copy link
Member Author

liZe commented May 1, 2018

All in all: I consider this PR is ready to merge.

Well, you're right, tests can come later.

Thanks a lot for this PR, that was a lot of fun!

@liZe liZe merged commit f147714 into master May 1, 2018
@liZe liZe deleted the target-collector branch May 1, 2018 19:39
@Tontyna
Copy link
Contributor

Tontyna commented May 1, 2018

That was the first step to solve #23.

Next step should be: Make the page and pages (and probably other) counters of the @page context available in the document context . That's tricky. The target_collector could be extended to monitor the requested counters... already have a few ideas how to do that, #93 is on my mind, too. Will PR when something useful emerges.

@liZe
Copy link
Member Author

liZe commented May 1, 2018

Next step should be: Make the page and pages (and probably other) counters of the @page context available in the document context . That's tricky.

Oh yeah.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 14, 2018
Version 43
----------

Released on 2018-11-09.

Bug fixes:

* `#726 <https://github.com/Kozea/WeasyPrint/issues/726>`_:
  Make empty strings clear previous values of named strings
* `#729 <https://github.com/Kozea/WeasyPrint/issues/729>`_:
  Include tools in packaging

This version also includes the changes from unstable rc1 and rc2 versions
listed below.

Version 43rc2
-------------

Released on 2018-11-02.

**This version is experimental, don't use it in production. If you find bugs,
please report them!**

Bug fixes:

* `#706 <https://github.com/Kozea/WeasyPrint/issues/706>`_:
  Fix text-indent at the beginning of a page
* `#687 <https://github.com/Kozea/WeasyPrint/issues/687>`_:
  Allow query strings in file:// URIs
* `#720 <https://github.com/Kozea/WeasyPrint/issues/720>`_:
  Optimize minimum size calculation of long inline elements
* `#717 <https://github.com/Kozea/WeasyPrint/issues/717>`_:
  Display <details> tags as blocks
* `#691 <https://github.com/Kozea/WeasyPrint/issues/691>`_:
  Don't recalculate max content widths when distributing extra space for tables
* `#722 <https://github.com/Kozea/WeasyPrint/issues/722>`_:
  Fix bookmarks and strings set on images
* `#723 <https://github.com/Kozea/WeasyPrint/issues/723>`_:
  Warn users when string() is not used in page margin


Version 43rc1
-------------

Released on 2018-10-15.

**This version is experimental, don't use it in production. If you find bugs,
please report them!**

Dependencies:

* Python 3.4+ is now needed, Python 2.x is not supported anymore
* Cairo 1.15.4+ is now needed, but 1.10+ should work with missing features
  (such as links, outlines and metadata)
* Pdfrw is not needed anymore

New features:

* `Beautiful website <https://weasyprint.org>`_
* `#579 <https://github.com/Kozea/WeasyPrint/issues/579>`_:
  Initial support of flexbox
* `#592 <https://github.com/Kozea/WeasyPrint/pull/592>`_:
  Support @font-face on Windows
* `#306 <https://github.com/Kozea/WeasyPrint/issues/306>`_:
  Add a timeout parameter to the URL fetcher functions
* `#594 <https://github.com/Kozea/WeasyPrint/pull/594>`_:
  Split tests using modern pytest features
* `#599 <https://github.com/Kozea/WeasyPrint/pull/599>`_:
  Make tests pass on Windows
* `#604 <https://github.com/Kozea/WeasyPrint/pull/604>`_:
  Handle target counters and target texts
* `#631 <https://github.com/Kozea/WeasyPrint/pull/631>`_:
  Enable counter-increment and counter-reset in page context
* `#622 <https://github.com/Kozea/WeasyPrint/issues/622>`_:
  Allow pathlib.Path objects for HTML, CSS and Attachment classes
* `#674 <https://github.com/Kozea/WeasyPrint/issues/674>`_:
  Add extensive installation instructions for Windows

Bug fixes:

* `#558 <https://github.com/Kozea/WeasyPrint/issues/558>`_:
  Fix attachments
* `#565 <https://github.com/Kozea/WeasyPrint/issues/565>`_,
  `#596 <https://github.com/Kozea/WeasyPrint/issues/596>`_,
  `#539 <https://github.com/Kozea/WeasyPrint/issues/539>`_:
  Fix many PDF rendering, printing and compatibility problems
* `#614 <https://github.com/Kozea/WeasyPrint/issues/614>`_:
  Avoid crashes and endless loops caused by a Pango bug
* `#662 <https://github.com/Kozea/WeasyPrint/pull/662>`_:
  Fix warnings and errors when generating documentation
* `#666 <https://github.com/Kozea/WeasyPrint/issues/666>`_,
  `#685 <https://github.com/Kozea/WeasyPrint/issues/685>`_:
  Fix many table layout rendering problems
* `#680 <https://github.com/Kozea/WeasyPrint/pull/680>`_:
  Don't crash when there's no font available
* `#662 <https://github.com/Kozea/WeasyPrint/pull/662>`_:
  Fix support of some align values in tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants