View Single Post
Old 01-22-2019, 08:25 AM   #10
nirosan
Member
nirosan began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
Thank you.

I already use some python modules to convert latex and asciimath into mathml and it works fine. (Modules: latex2mathml and asciitomathml).

What I need is a python module to convert the mathml into svg or any images to display the rendered mathml. The user should be able to see the rendered formula before she/he can add it into the book.

What I had used is with matplotlib module:

Quote:
dpi = 300
fig = plt.figure(figsize=(0.01, 0.01))
fig.text(0, 0, r'${}$'.format(self.formulas_input.text()), fontsize=fontsize)

output = BytesIO()
fig.savefig(output, dpi=dpi, transparent=True, format='svg',
bbox_inches='tight', pad_inches=0.0, frameon=False)
plt.close(fig)

output.seek(0)
svg_output = output.read()
self.render_svg.load(svg_output)
The problem was matplotlib use numpy.

I did not find a suitable python module to write mathml into svg which can I load into QSvg to display it.
nirosan is offline   Reply With Quote