I want to build a mini markup mechanism for PDF reports in Odoo 17. How can I use regular expression in Qweb report to change the output?
I want to create a bold text string from **a bold text string**
For that I use
<td name="td_name"><span t-esc="o.minimarkupmagic(line.name)">Bacon Burger</span></td>
in my template. In my model (which I inherit from sale.order) I define a method
def minimarkupmagic(self,txt):
txt = re.sub(r'\*{2,2}(.*?)\*{2,2}', r'\1', txt)
txt = re.sub(r'_{2,2}(.*?)_{2,2}', r'\1', txt)
txtArr = txt.split('\n')
txt = '<br/>'.join(txtArr)
return txt
and send it to my template within
docargs = {
...,
'minimarkupmagic': self.minimarkupmagic
}
from def render_html().
It works half way: I only get an output like
<span class="bold">a bold text string</span>
in my report, so it seems that the method runs after the rendering of the HTML to PDF.
So how could I get my HTML get interpreted earlier and get my correct output?
Thanks!