I am trying to have my wagtail template output <strong></strong>
instead of <b></b>
and <em></em>
instead of <i></i>
.
I manually edited the content_json values within the wagtailcore_pagerevision table records so that the <b>
tags are <strong>
and the <i>
tags are <em>
but the output HTML continues to output <b>
and <i>
tags respectively.
In my template I have {{ block.value|richtext }}
for block and {{ self.body|richtext }}
for non blocks.
The wagtail code doing the work is:
@register.filter
def richtext(value):
if isinstance(value, RichText):
# passing a RichText value through the |richtext filter should have no effect
return value
elif value is None:
html = ''
else:
html = expand_db_html(value)
return mark_safe('<div class="rich-text">' + html + '</div>')
My question is.. how can i tell Wagtail or Django to use <strong>
and <em>
tags?
This does not seem to be a hallo-js WYSIWYG issue or setting, but rather some sort of configuration or other setting that I cannot seem to find.
BTW.. I am using Wagtail 1.13.1 (with default Hallo editor), Django 1.11 and MySQL as the database.
To overcome my issue, i am overriding with this code..
# override the wagtail version and replace <b>, <i>
@register.filter(name='richtext')
def richtext(value):
if isinstance(value, RichText):
# passing a RichText value through the |richtext filter should have no effect
# return value
html = value.source
elif value is None:
html = ''
else:
html = expand_db_html(value)
html = html.replace('<b>', '<strong>').replace('</b>', '</strong>') \
.replace('<i>', '<em>').replace('</i>', '</em>')
return mark_safe('<div class="rich-text">' + html + '</div>')
but there should be a better, more efficient way.