Closed yamsu closed 1 year ago
Investigating. I'm wondering how the font object came to not exist or else no have a size attribute.
Anyhow I've recreated this - thanks to your sample markdown, @yamsu.
So we definitely have a font
object passed into set_subscript
- but it has no size
attribute.
And it has nothing to do with the previous bullets; It's all about the <sub>
element. (Actually <sup>
triggers the same error.)
So it seems when python-pptx's add_run
method is called - for a paragraph
object - it doesn't set the font size for the new run. Normally that doesn't matter. In the case of handling <sub>
and <sup>
it matters because the font size is queried in add_subscript
and add_superscript
, respectively.
If the run's font size is less than 24 points the baseline is dropped / raised by one amount. If greater a larger baseline adjustment is done. (This all appears to be how Powerpoint itself does it.)
The solution for now is to test the run's font size. If it doesn't exist the code assumes the smaller baseline adjustment.
I've tested this and it works. I'll investigate documentation and push this out in the next hour - as 4.1.2. (There's another urgent fix - for card slides - I need to get out.)
Documented (with additional explanations as to how <sub>
and <sup>
work) and released as v4.1.2.
Thanks for the bug report @yamsu!
Hi, I'm unable to add superscript or subscripts in bullets and tables. I have updated the repo and tested on python 3.11 & 3.8 This is the markdown (Removed all meta options and templates). Incidentally, I get the same error with or without the metadata
This is the error: