问题
I am django newbie and working on a math based project. I need to save texts involving mathematical symbols like integral
, sigma
, product
etc. At the same time, I also need to emphasize or bold some texts (and do all kinds of rich text editing) and include figures that explains a mathematical concept.
At present, I am just saving all the fields in a CharField
(with dummy texts and without including any mathematical symbol) and have no idea how to include such a field. If you have any idea/hint or you have worked on similar projects, please help.
回答1:
The most obvious way to do that in Django is indeed to use a CharField and use it to store some LaTeX fragments like:
x=\frac{-b+\sqrt{b^2-4ac}}{2a}
which represents the following expression:
LaTeX can also be used to style your texts very easily. You can integrate a free editor for typing expressions of this kind like mathquill if you plan to store long fragments, use a Django TextField. LaTeX expressions can also be beautifully rendered by Mathjax or KaTeX Edit: You can also use math.stackexchange.com editor: stackedit. It's opensource and you find it there: github.com/benweet/stackedit. It uses KaTeX to render LaTeX math expressions.
来源:https://stackoverflow.com/questions/48297768/django-how-to-integrate-a-maths-editor