elapouya / python-docx-template

Use a docx as a jinja2 template
GNU Lesser General Public License v2.1
1.98k stars 385 forks source link

Raise exception when trying to assign paragraph style to RichText #479

Open mgilski opened 1 year ago

mgilski commented 1 year ago

I spent quite a lot of time trying to use an existing paragraph style on a RichText run (with no success obviously). I think the docs don't sufficiently emphasize the fact that this has to be a character style, not paragraph or linked.

I found the source of the problem by trying to create a run with my style using plain python-docx, got this nice error:

ValueError: assigned style is type PARAGRAPH (1), need type CHARACTER (2)

It would be a good idea to re-raise (or not silence) this exception, it will probably save a lot of frustration.