Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /HKUDS_LightRAG /lightrag /parser /docx /omml /utils.py
| """ | |
| Utility functions to extract text from the supported mathematical equations from xml tags and | |
| convert them into LaTeX | |
| """ | |
| from .cleaners import clean_exp | |
| ns_map = { | |
| "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", | |
| "m": "http://schemas.openxmlformats.org/officeDocument/2006/math", | |
| } | |
| def linear_expression(tag): | |
| """ | |
| Just returns the text contained in the given tag while setting docxlatex_skip_iteration flags | |
| for all its children. | |
| :param tag:defusedxml.Element - An xml element which contains a math equation in linear form | |
| :return text:str - The equation in valid LaTeX syntax | |
| """ | |
| text = "" | |
| for child in tag.iter(): | |
| child.set("docxlatex_skip_iteration", True) | |
| text += child.text if child.text is not None else "" | |
| text = clean_exp(text) | |
| return text | |
| def qn(tag): | |
| """ | |
| A utility function to turn a namespace | |
| prefixed tag name into a Clark-notation qualified tag name for lxml. For | |
| example, qn('m:oMath') returns '{http://schemas.openxmlformats.org/officeDocument/2006/math}oMath' | |
| :param tag:str - A namespace-prefixed tag name | |
| :return qn:str - A Clark-notation qualified name tag for lxml. | |
| """ | |
| prefix, tag_root = tag.split(":") | |
| uri = ns_map[prefix] | |
| return "{{{}}}{}".format(uri, tag_root) | |
Xet Storage Details
- Size:
- 1.32 kB
- Xet hash:
- 8c4fe8a1fa349097ed3902eccf164496cab1f456d13124033306c9f678abed89
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.