Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Guillaume Ayoub
    @liZe
    Parfait ! :)
    Bonne journée !
    Guillaume Ayoub
    @liZe
    WeasyPrint v54.0 has been released: https://www.courtbouillon.org/blog/00020-footnotes
    Release notes are available here: https://github.com/Kozea/WeasyPrint/releases/tag/v54.0
    Simon
    @simon:delire.party
    [m]
    Hi all. I’m starting a new (small) python project but it’s been years since I’ve done that. What are you favorite tools for basic tasks these days? Things like dependency management (poetry?), testing (pytest?), …
    Guillaume Ayoub
    @liZe
    Hi @simon:delire.party
    Here’s what we use for our new projects:
    • a pyproject.toml using Flit for dependencies management (you can use flit init)
    • a simple python -m venv to create the virtual environment, and venv/bin/pip install -e . to install the package
    • pytest for tests
    Guillaume Ayoub
    @liZe
    I personally like poetry, even if I don’t find it really useful for my use cases, and I personally don’t like pipenv that’s a bit bloated for my taste
    Simon Sapin
    @simon:delire.party
    [m]
    thanks!
    dmoonfire
    @dmoonfire:matrix.org
    [m]
    Since I'm cross language, I end up using asdf or Nix instead for my projects.
    Marko Sandalj
    @msandalj:matrix.org
    [m]

    Hi everyone,

    For the past couple of days I have been trying to implement weasyprint into my Django application and the setup was quit (w)easy and I was soon able to print pdfs but since my pages are full of math equations we use MathJax to convert them to SVGs but once I send markup to backend for printing I get empty spaces instead of equations. I have now spent countless hours trying to figure out how to fix that. That lead me to this Github thread (Kozea/WeasyPrint#59) where I learned that there is this thing called Pandoc that should, with Weasyprint, be able to do what I need but after another session of reading and researching I still don't understand how to get everything to work. And that brings me here, is there anyone who also tried to print HTML with math equations and if yes how have you done it? If no, is there anyone who can try and help me set this up, if its even possible to do it.

    Note that I'm junior developer and some things are still hard to grasp for me.

    Marko Sandalj
    @msandalj:matrix.org
    [m]

    :point_up: Edit: Hi everyone,

    For the past couple of days I have been trying to implement weasyprint into my Django application and the setup was quite (w)easy and I was soon able to print pdfs but since my pages are full of math equations we use MathJax to convert them to SVGs but once I send markup to backend for printing I get empty spaces instead of equations. I have now spent countless hours trying to figure out how to fix that. That lead me to this Github thread (Kozea/WeasyPrint#59) where I learned that there is this thing called Pandoc that should, with Weasyprint, be able to do what I need but after another session of reading and researching I still don't understand how to get everything to work. And that brings me here, is there anyone who also tried to print HTML with math equations and if yes how have you done it? If no, is there anyone who can try and help me set this up, if its even possible to do it.

    Note that I'm junior developer and some things are still hard to grasp for me.

    Guillaume Ayoub
    @liZe
    @msandalj:matrix.org Hi!
    Maybe there’s a solution to get MathJax’ SVG output working with WeasyPrint
    Could you please provide a simple HTML sample that gives an empty space instead of the math formula?
    Marko Sandalj
    @msandalj:matrix.org
    [m]
    Here it is, I stripped everything unnecessary from the file so its more readable
    It is still quite messy since SVGs are inlined
    I'm passing that HTML as a string to the weasyprint html function
    Guillaume Ayoub
    @liZe
    The problem probably comes from a current limitation of WeasyPrint
    CSS is not really applied to SVG when the stylesheet is in the HTML and the SVG is embedded
    It would work if the properties were set on the SVG tags, or (maybe?) if the CSS was embedded in the SVG tag
    Marko Sandalj
    @msandalj:matrix.org
    [m]
    Hmmm, equations should show even if you remove whole style tag. As far as I understand the only thing necessary for equations is the last SVG tag (id="MJX-SVG-global-cache")
    Guillaume Ayoub
    @liZe
    It’s a bit late here and I’m going to sleep, but I’ll spend some time to read your example
    Marko Sandalj
    @msandalj:matrix.org
    [m]
    Of course, thank you!
    Guillaume Ayoub
    @liZe
    See you later!
    Guillaume Ayoub
    @liZe
    Capture d’écran de 2022-01-26 10-11-03.png
    The problem is that formulas reference elements that are in another svg
    Guillaume Ayoub
    @liZe
    Currently, WeasyPrint renders SVG tags independently, and each SVG is separated from the other ones
    I had to copy the defs tag at the end of the HTML into each svg tag to get this rendering
    We should definitely have a better implementation, we know that, there’s no need to open a new issue 😀
    Marko Sandalj
    @msandalj:matrix.org
    [m]
    Okay I tried it and it works 😄
    Just a note if anyone stumbles upon this. For me it worked only when I read the html from a file but not when I tried to pass it as a string.
    Guillaume Ayoub
    @liZe
    Do you know if there’s an option in MathJax to avoid the use tags?
    (Or to include them in each SVG)
    Marko Sandalj
    @msandalj:matrix.org
    [m]
    Yes there is, you can set SVG cache to local and defs will be included in each SVG separately.
    Guillaume Ayoub
    @liZe
    Thanks! Good to know!
    Other than our problem to find defs outside the SVG, don’t hesitate to report an issue if you find a specific bug in the way one formula is rendered
    (And have fun with WeasyPrint!)
    Safa Alfulaij
    @SafaAlfulaij
    Hello all.
    I was testing out WeasyPrint for the first time (I got in love with it the first time I saw it)
    And found out that RTL support is not complete fully.
    What's missing? How much time would it take to complete it?
    Mohammed Y. Alnajdi
    @malnajdi
    @SafaAlfulaij RTL support has come a long way in weasyprint and you can do a lot of things with css and some work around, you can search in the code for RTL and you will see the short comings.
    But, overall i use is in many of my applications to generate Arabic Tickets, Invoices, etc..
    Safa Alfulaij
    @SafaAlfulaij
    I tried today lists and it was not supported there
    I should take a look at the code more to see what aspects are supported, but lists are basic tbh :)
    Mohammed Y. Alnajdi
    @malnajdi
    Which version are you using and if you can share your example
    Safa Alfulaij
    @SafaAlfulaij
    I installed it today directly from pip, so latest I believe
    I also found a bug report
    Kozea/WeasyPrint#1512
    Mohammed Y. Alnajdi
    @malnajdi
    yes, again somethings won't work out of the box. but with some work around it might work. list is basic i agree maybe @liZe can say something about it more.
    Safa Alfulaij
    @SafaAlfulaij
    For now I just added a bullet ​• and manual numbering
    But a more definitive solution is needed
    Guillaume Ayoub
    @liZe
    The position of bullets is not handled yet, but it should be possible to fix it "quite easily" as explained in the bug report
    The code of absolute_width handles the width and the position of the absolute boxes (including bullets)
    It should be possible to fix this issue, at least for ul, by adding ~10 lines of code in this function