Skip to main content

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()

Release files for hml_equation_parser 1.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hml_equation_parser 1.0.12
File Size Uploaded
hml_equation_parser-1.0.12.tar.gz 7.7 kB Details

Release files / hml_equation_parser-1.0.12.tar.gz

Download URL hml_equation_parser-1.0.12.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
28f3e053e493095aec6259f07f15e62bd76e4778aa39262db7489a8da60f32ab
BLAKE2b-256 checksum
How to use checksums
0899718a46dcbca6497d76431864a35fcf8038d8e3495f082336f04916683695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.12 This release

1 release file

1.0.11

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page