-
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
write_html: support <sup> & <sup> tags inside <table> #860
Comments
Hi @Tolker-KU! Thank you for your nice words 😊 I think this was implemented by @gmischler in #520: I think it should work for |
#520 implements the general ability to render subscript and superscript text, as well as the The reason for the latter was that I couldn't find a standard on which characters to use as markup. I'm not very comfortable with borrowing tags from HTML. Why not just use HTML in the first place then? And while we're on the topic: Adding a conforming commonmark implementation (possibly in parallel) should probably be the long term goal. |
Thank for getting back this quickly. I'm looking for a feature to render subscripts and superscript within cells. As far as I can figure out this is not quite achievable with What do you about adding the |
No, you are right. from fpdf import FPDF
pdf = FPDF()
pdf.set_font("Helvetica")
pdf.add_page()
pdf.write_html(
"""<table border="1"><thead><tr>
<th width="33%">Name</th>
<th width="66%">Formula</th>
</tr></thead><tbody><tr>
<td>Lucas-C</td><td>E = MC<sup>2</sup></td>
</tr</tbody></table>""")
pdf.output("issue_860.pdf") I agree that it would be nice if I also fully agree with you @gmischler on this:
Ideally, we could support combining So I'm not really sure of the path forward regarding Markdown support... |
I think https://markdown-it-py.readthedocs.io/en/latest/using.html#the-token-stream |
Sure, we could do that! I'm not opposed to this, if someone is willing to contribute / initiate such converter to this project, |
I've been looking into how to solving this. It seems that cells in tables rendered from HTML call |
As you have correctly recognized, this is a fundamental limitation of Fixing this cleanly requires some architectural changes to fpdf2. I have outlined a possible solution in #339, and have been working on-and-off on an actual implementation. I hope I'll find time again soon so I can actually show some more progress here. Theoretically, |
By the way, I think that this other, older issue is related: #151 |
Regarding the initial question about Markdown, combining I renamed this issue into: from fpdf import FPDF
pdf = FPDF()
pdf.set_font("Helvetica")
pdf.add_page()
pdf.write_html(
"""<table border="1"><thead><tr>
<th width="33%">Name</th>
<th width="66%">Formula</th>
</tr></thead><tbody><tr>
<td>Lucas-C</td><td>E = MC<sup>2</sup></td>
</tr</tbody></table>""")
pdf.output("issue_860.pdf") Since PR #897 by @gmischler, |
Hi,
Thanks for all the great work going into this project!
I wonder if you have considered supporting subscript/superscript in cell/multicell when styling text with markdown?
Github supports this in their markdown implementation using the HTML tags <sub>/<sup>. I imagine fpdf2 could do something similar.
If you think this is a good idea, I would be happy to take a crack at it. It seems that the machinery for this feature already is in place.
The text was updated successfully, but these errors were encountered: