You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
First of all thank you for an excellent library!
In my use-case I need per-paragraph formatting, which is achievable using RichText-objects. These however require to clear the existing formatting, and are quite cumbersome to use. In our use-case we would also like to use the same context to render into HTML and Word-documents.
Describe the solution you'd like
I would like for a context-vairable: 'I am bolded text' to be formatted properly.
I have very limited understanding in Word styling, but according to my limited understanding, this would not be achievable by modifying the context-variables due to requirement to close the existing formatting.
In this case, the approach would be to:
First render the template with context, as is done now:
After this, add a step to modify the Word-styling
For modifying the Word styling:
Whenever encountering <b>, <i> or <u> (maybe even more styling tags?):
Read the styles from current content tag
Close the current content tag
Open a new content tag, and attach these styles + the bold/italic styles to the content tag
Write the content
Close the content tag, and open a new with styling from the innermost tag
Due to nesting possibilities, the process would need to be recursive.
Describe alternatives you've considered
Instead of HTML-tags, custom tags may also be used, f.ex: ([b], [i], [u])?
Activity
PHvL commentedon Sep 5, 2025
Since we prepare the
contextfor the template as pydantic schema anyway, we've added aBeforeValidatordoing the conversion of HTML tags.