Workaround bolds ending with space

when bold (or italic) ends with space RST is not happy. We drop this
trailing space and inject a space immediately after strong block
This commit is contained in:
Artem Goncharov 2023-01-12 14:14:53 +01:00
parent 79b1bc1455
commit 471514c654

View File

@ -307,6 +307,18 @@ class OTCDocConvertor:
# <pre class="codeblock"
pre["class"] = "text"
# Another hack: sometimes bold elements ends with space. This is not
# valid from rst pov and we need to fix that by dropping this space and
# inject a space after strong block
for el in soup.body.find_all("strong"):
if (
el.string
and el.string[-1] == " "
):
curr = el.string
el.string.replace_with(curr[:-1])
el.insert_after(" ")
# A very dirty hack - if we have "*" inside of em (italic) regular
# escaping is not working anymore (pandoc is not producing proper
# output). We can only try to put whole italic content as a literal