hml_equation_parser

Convert eqaution string in hml to latex string.


License
Other
Install
pip install hml_equation_parser==1.0.12

Documentation

hml-equation-parser

Usage

If you have equation string from hml document, you can convert it to latex string by using eq2latex function.

>>> import hml_equation_parser as hp
>>> hp.eq2latex("LEFT ⌊ a+b RIGHT βŒ‹")
'\\left \\lfloor a+b \\right \\rfloor'

Sample code

Let's assume that you have test.hml file for converting. There are some sample code to show how to parse hml documents. You can refer to this sample codes in hmlParser.py(parseHmlSample, convertEquationSample, extract2HtmlStrSample).

import hml_equation_parser as hp

doc = hp.parseHmlSample("test.hml")  # parse hml document and make ElementTree

doc = hp.convertEquationSample(doc)  # find equations from ElementTree and convert them to latex string
string = hp.extract2HtmlStrSample(doc)  # convert ElementTree to html document with MathJax.

import codecs

f = codecs.open("test.html", "w", "utf8")
f.write(string)
f.close()

hml-equation-parser ν•œκΈ€ λ¬Έμ„œ

μ‚¬μš©λ²•

hmlλ¬Έμ„œμ—μ„œ μˆ˜μ‹ string을 λ½‘μ•„λƒˆλ‹€λ©΄ eq2latex ν•¨μˆ˜λ₯Ό μ΄μš©ν•˜μ—¬ latex μˆ˜μ‹μœΌλ‘œ λ³€ν™˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

>>> import hml_equation_parser as hp
>>> hp.eq2latex("LEFT ⌊ a+b RIGHT βŒ‹")
'\\left \\lfloor a+b \\right \\rfloor'

예제 μ½”λ“œ

hmlλ¬Έμ„œλ₯Ό νŒŒμ‹±ν•˜μ—¬ 전체 λ¬Έμ„œμ—μ„œ μˆ˜μ‹μ„ λ°”κΎΈκ³ μ‹Άλ‹€λ©΄ λ‹€μŒ μ½”λ“œλ₯Ό μ°Έμ‘°ν•˜λ©΄ λ©λ‹ˆλ‹€. μ˜ˆμ œμ—μ„œλŠ” test.hml을 νŒŒμ‹±ν•˜μ—¬ htmlλ¬Έμ„œλ‘œ λ°”κΏ‰λ‹ˆλ‹€. νŒŒμ‹±μ— λŒ€ν•œ 더 μžμ„Έν•œ λ‚΄μš©μ€ library의 hmlParser.py μ½”λ“œλ₯Ό μ°Έμ‘°ν•˜μ„Έμš”(parseHmlSample, convertEquationSample, extract2HtmlStrSample).

import hml_equation_parser as hp

doc = hp.parseHmlSample("test.hml")  # parse hml document and make ElementTree

doc = hp.convertEquationSample(doc)  # find equations from ElementTree and convert them to latex string
string = hp.extract2HtmlStrSample(doc)  # convert ElementTree to html document with MathJax.

import codecs

f = codecs.open("test.html", "w", "utf8")
f.write(string)
f.close()