Skip to content

Pin pydyf<0.11 to fix PDF export with WeasyPrint + Support multiple author emails and render them as mailto links - #531

Open
alireza5969 wants to merge 2 commits into
manubot:mainfrom
alireza5969:main
Open

alireza5969 wants to merge 2 commits into
manubot:mainfrom
alireza5969:main

Conversation

@alireza5969

@alireza5969 alireza5969 commented Oct 23, 2026 •

Copy link
Copy Markdown

Problem 1

bash build/build.sh fails at the PDF export step on a fresh environment
created from build/environment.yml:

File ".../weasyprint/document.py", line 157, in transform
    super().transform(a, b, c, d, e, f)
AttributeError: 'super' object has no attribute 'transform'
Error producing PDF.

HTML export works, and the CSS warnings printed before the traceback are
harmless (WeasyPrint skips properties it doesn't support).

Cause

The pinned WeasyPrint version calls Stream.transform() from pydyf, but
pydyf 0.11 removed that method. Because pydyf isn't pinned, a fresh
install resolves to a version that is incompatible with WeasyPrint.

Fix

Pin pydyf<0.11 in build/environment.yml:

dependencies:
  - pydyf<0.11

Testing

  • Created a fresh environment with Miniforge/mamba from build/environment.yml
  • Before the change: PDF export fails with the error above
  • After the change (mamba install "pydyf<0.11"): bash build/build.sh
    completes and produces the PDF

Notes

This pin can be removed once the project bumps WeasyPrint to a version
compatible with newer pydyf (WeasyPrint 61+).

Problem 2

The correspondence block in content/00.front-matter.md renders author.email directly:

{{ author.name }} \<{{ author.email }}\>

This has two problems:

  1. List values render as a Python repr. email is documented as a string, but users naturally write several addresses as a YAML list. Jinja then prints the list repr, producing output like Name <['a@x.org', 'b@y.org']>.
  2. Emails are never links, even for a single string. The \< and \> are escaped, so Pandoc does not autolink the address. The output is plain text such as Name <a@x.org>.

Change

  • content/00.front-matter.md: in the #correspondence block, normalize author.email to a list. A string becomes a one-item list, a list is used as is, and null or a missing value becomes an empty list. Each address is then rendered as an explicit [addr](mailto:addr) link.
  • Addresses are shown in parentheses after the author's name, and multiple addresses are comma-separated: Name (a@x.org, b@y.org).
  • USAGE.md: document that email may be a string or a list.

No change to Manubot itself is needed.

Why in the template and not in Manubot

Manubot normalizes affiliations and funders to lists in manubot/process/util.py. Doing the same for email would break existing manuscripts whose custom templates use {{ author.email }} as a string, because they would start printing list reprs. Handling both types in the template is backward compatible.

Behavior

email in metadata.yaml Before After
`a@x.org` (string) `Name a@x.org` (plain text) `Name (`a@x.org`)`
`[a@x.org, b@y.org]` `Name <['a@x.org', 'b@y.org']>` `Name (`a@x.org`, `b@y.org`)`
`[a@x.org]` repr garbage linked, as for a string
`null` / missing `Name <>` or error `Name` only

Testing

Rendered the template with Manubot's Jinja2 environment (make_logging_undefined, same delimiters and extensions) and converted the result with Pandoc to HTML. I checked string, list, single-item list, null, missing and non-corresponding authors, plus addresses containing underscores and dots. I also confirmed the correspondence block in a real manuscript build, where each address becomes a working mailto: link.

Note for reviewers

This changes the visible format from Name <email> to Name (email). I think this is better, since the angle brackets were needed only to imitate an email header. If you prefer to keep <...>, it is a two-character change in one line.

@AppVeyorBot

Copy link
Copy Markdown

AppVeyor build 1.0.350 for commit b5684ef is now complete.

Found 51 potential spelling error(s). Preview:content/02.delete-me.md:44:adipiscing
content/02.delete-me.md:44:aliqua
content/02.delete-me.md:44:amet
content/02.delete-me.md:44:consectetur
content/02.delete-me.md:44:dolore
content/02.delete-me.md:44:eiusmod
content/02.delete-me.md:44:elit
content/02.delete-me.md:44:incididunt
content/02.delete-me.md:44:ipsum
content/02.delete-me.md:44:labore
content/02.delete-me.md:44:Lorem
content/02.delete-me.md:44:magna
content/02...
The rendered manuscript from this build is temporarily available for download at:

`manubot` printed out `X Y <['x@y.com', 'x.y@gmail.com']>. ` with no hyperlinks.

I changed it so it can print out the correspondings' emails neatly.
@alireza5969 alireza5969 changed the title Pin pydyf<0.11 to fix PDF export with WeasyPrint Pin pydyf<0.11 to fix PDF export with WeasyPrint + Support multiple author emails and render them as mailto links Oct 23, 2026
@AppVeyorBot

Copy link
Copy Markdown

AppVeyor build 1.0.351

Found 51 potential spelling error(s). Preview:content/02.delete-me.md:44:adipiscing
content/02.delete-me.md:44:aliqua
content/02.delete-me.md:44:amet
content/02.delete-me.md:44:consectetur
content/02.delete-me.md:44:dolore
content/02.delete-me.md:44:eiusmod
content/02.delete-me.md:44:elit
content/02.delete-me.md:44:incididunt
content/02.delete-me.md:44:ipsum
content/02.delete-me.md:44:labore
content/02.delete-me.md:44:Lorem
content/02.delete-me.md:44:magna
content/02...
for commit 787b602 is now complete. The rendered manuscript from this build is temporarily available for download at:

@agitter

agitter commented Oct 23, 2026

Copy link
Copy Markdown
Member

If the package version needs to be locked, merging that change makes sense. I haven't tested it yet.

email is documented as a string, but users naturally write several addresses as a YAML list

I don't see this as a real problem we've faced. Our users provide one email address as a string, as documented. I'm not that interested in generalizing to support multiple emails per author.

csunijena added a commit to rfb-data-hub/guidelines-living-doc that referenced this pull request Nov 5, 2026
…ty README (#1)

* Update Manubot CI actions, pin pydyf, and personalize README

- Bump GitHub Actions to current major versions:
  checkout v6->v7, cache v5->v6, setup-miniconda v3->v4,
  upload-artifact v6->v7, setup-python v6->v7
- Pin pydyf<0.11 in build/environment.yml: weasyprint 53.4 fails
  with pydyf >= 0.11 in the local (non-Docker) PDF build path
  (cf. manubot/rootstock#531)
- Replace rootstock placeholder title and description in README

* Import accepted Chem Rev manuscript into Manubot content

- Split manuscript into numbered section files plus abstract
- Convert 10 figures to PNG in content/images with fignos IDs
- Convert 292 numbered references to Manubot citation keys
  (279 DOI-based, 13 manual references)
- Move authors/keywords to metadata.yaml and align corresponding
  authors (Goulet, Brushett, Aziz) and Zenodo affiliations
- Correct Kangro spelling (verified against DE914264C) and add
  the missing final period to the abstract

* Use non-deprecated auto-activate input for setup-miniconda v4

* Set corresponding authors to Goulet and Stolze

* Rewrite README for the living document; add Zenodo release metadata

- README now describes the manuscript, the living-document intent, and a
  contributor tutorial instead of the rootstock boilerplate.
- .zenodo.json provides complete deposit metadata for Zenodo's GitHub
  release integration (only official releases mint DOIs).

This branch has not been deployed

No deployments
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.

3 participants