Skip to content
Permalink
Browse files

Drop TexSoup (#33)

- Support Python 2.7
  • Loading branch information...
roniemartinez committed Oct 13, 2018
1 parent f96f2ae commit fbaad9d1008c8e2c07d6eb81718882e2665dd892
Showing with 216 additions and 13 deletions.
  1. +1 −1 .travis.yml
  2. +8 −1 CHANGELOG.md
  3. +2 −0 MANIFEST
  4. +5 −9 README.md
  5. +2 −1 appveyor.yml
  6. +1 −0 setup.py
  7. +16 −0 tests/test_aggregator.py
  8. +165 −0 tests/test_converter.py
  9. +16 −1 tests/test_tokenizer.py
@@ -3,6 +3,7 @@ language: python
cache: pip

python:
- 2.7
- 3.4
- 3.5
- 3.6
@@ -15,7 +16,6 @@ matrix:
sudo: true

install:
- pip install -r requirements.txt
- pip install -r test-requirements.txt

script:
@@ -2,6 +2,12 @@
List of changes to latex2mathml

## [Unreleased]
## [2.6.0] - 2018-10-13
### Fixed
- Drop TexSoup (#33)

### Changed
- Support Python 2.7

## [2.5.2] - 2018-10-10
### Added
@@ -140,7 +146,8 @@ List of changes to latex2mathml
- Element class for xml elements
- simple converter implementation

[Unreleased]: https://github.com/Code-ReaQtor/latex2mathml/compare/2.5.2...master
[Unreleased]: https://github.com/Code-ReaQtor/latex2mathml/compare/2.6.0...master
[2.6.0]: https://github.com/Code-ReaQtor/latex2mathml/releases/tag/2.6.0
[2.5.2]: https://github.com/Code-ReaQtor/latex2mathml/releases/tag/2.5.2
[2.5.1]: https://github.com/Code-ReaQtor/latex2mathml/releases/tag/2.5.1
[2.5.0]: https://github.com/Code-ReaQtor/latex2mathml/releases/tag/2.5.0
@@ -6,5 +6,7 @@ latex2mathml/__init__.py
latex2mathml/aggregator.py
latex2mathml/commands.py
latex2mathml/converter.py
latex2mathml/exceptions.py
latex2mathml/symbols_parser.py
latex2mathml/tokenizer.py
CHANGELOG.md
@@ -460,28 +460,24 @@ A_{m,n} =
</tr>
</table>

### Dependencies

- [TexSoup](https://github.com/alvinwan/TexSoup)

### References
#### LaTeX
## References
### LaTeX

- https://en.wikibooks.org/wiki/LaTeX/Mathematics
- http://artofproblemsolving.com/wiki/index.php?title=Main_Page
- http://milde.users.sourceforge.net/LUCR/Math/
- http://www.forkosh.com/mimetextutorial.html

#### MathML
### MathML

- http://www.xmlmind.com/tutorials/MathML/

#### Continuous Integration
### Continuous Integration

- https://katyhuff.github.io/python-testing/08-ci/
- https://docs.travis-ci.com/user/caching/
- https://github.com/pypa/pip/blob/master/appveyor.yml


### Author
## Author
- [Ronie Martinez](mailto:ronmarti18@gmail.com)
@@ -1,5 +1,7 @@
environment:
matrix:
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python34-x64"
- PYTHON: "C:\\Python35"
@@ -10,7 +12,6 @@ environment:
- PYTHON: "C:\\Python37-x64"

install:
- "%PYTHON%\\Scripts\\pip.exe install -r requirements.txt"
- "%PYTHON%\\Scripts\\pip.exe install -r test-requirements.txt"

build: off
@@ -18,6 +18,7 @@
classifiers=['Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
@@ -142,3 +142,19 @@ def test_null_delimiter():

def test_superscript_with_curly_braces():
assert ['_^', 'a', '3', ['i', '+', '1']] == list(aggregate('a^{i+1}_3'))


def test_issue_33():
latex = r"""\begin{bmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{bmatrix}"""
expected = ['\\bmatrix',
[['_', 'a', ['1', ',', '1'], '_', 'a', ['1', ',', '2'], '\\cdots', '_', 'a', ['1', ',', 'n']],
['_', 'a', ['2', ',', '1'], '_', 'a', ['2', ',', '2'], '\\cdots', '_', 'a', ['2', ',', 'n']],
['\\vdots', '\\vdots', '\\ddots', '\\vdots'],
['_', 'a', ['m', ',', '1'], '_', 'a', ['m', ',', '2'], '\\cdots', '_', 'a', ['m', ',', 'n']]]]
assert expected == list(aggregate(latex))

@@ -274,3 +274,168 @@ def test_null_delimiter(math_and_row):
latex = r'\left\{ \begin{array} { l } { 3x - 5y + 4z = 0} \\ { x - y + 8z = 0} \\ { 2x - 6y + z = 0} \end{array} ' \
r'\right.'
assert _convert(math) == convert(latex)


def test_issue_33(math_and_row):
latex = r"""\begin{bmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{bmatrix}"""
math, row = math_and_row
mo = eTree.SubElement(row, 'mo')
mo.text = '&#x0005B;'

mtable = eTree.SubElement(row, 'mtable')

# 1st row
mtr = eTree.SubElement(mtable, 'mtr')

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mn')
mi.text = '1'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mi = eTree.SubElement(mrow, 'mn')
mi.text = '1'

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mn')
mi.text = '1'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mi = eTree.SubElement(mrow, 'mn')
mi.text = '2'

mtd = eTree.SubElement(mtr, 'mtd')
mo = eTree.SubElement(mtd, 'mo')
mo.text = '&#x022EF;'

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mn')
mi.text = '1'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mi = eTree.SubElement(mrow, 'mi')
mi.text = 'n'

# 2nd row
mtr = eTree.SubElement(mtable, 'mtr')

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mn')
mi.text = '2'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mi = eTree.SubElement(mrow, 'mn')
mi.text = '1'

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mn')
mi.text = '2'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mi = eTree.SubElement(mrow, 'mn')
mi.text = '2'

mtd = eTree.SubElement(mtr, 'mtd')
mo = eTree.SubElement(mtd, 'mo')
mo.text = '&#x022EF;'

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mn = eTree.SubElement(mrow, 'mn')
mn.text = '2'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mi = eTree.SubElement(mrow, 'mi')
mi.text = 'n'

# 3rd row
mtr = eTree.SubElement(mtable, 'mtr')
mtd = eTree.SubElement(mtr, 'mtd')
mo = eTree.SubElement(mtd, 'mo')
mo.text = '&#x022EE;'
mtd = eTree.SubElement(mtr, 'mtd')
mo = eTree.SubElement(mtd, 'mo')
mo.text = '&#x022EE;'
mtd = eTree.SubElement(mtr, 'mtd')
mo = eTree.SubElement(mtd, 'mo')
mo.text = '&#x022F1;'
mtd = eTree.SubElement(mtr, 'mtd')
mo = eTree.SubElement(mtd, 'mo')
mo.text = '&#x022EE;'

# 4th row
mtr = eTree.SubElement(mtable, 'mtr')

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mi')
mi.text = 'm'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mn = eTree.SubElement(mrow, 'mn')
mn.text = '1'

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mi')
mi.text = 'm'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mn = eTree.SubElement(mrow, 'mn')
mn.text = '2'

mtd = eTree.SubElement(mtr, 'mtd')
mo = eTree.SubElement(mtd, 'mo')
mo.text = '&#x022EF;'

mtd = eTree.SubElement(mtr, 'mtd')
msub = eTree.SubElement(mtd, 'msub')
mi = eTree.SubElement(msub, 'mi')
mi.text = 'a'
mrow = eTree.SubElement(msub, 'mrow')
mi = eTree.SubElement(mrow, 'mi')
mi.text = 'm'
mi = eTree.SubElement(mrow, 'mi')
mi.text = ','
mi = eTree.SubElement(mrow, 'mi')
mi.text = 'n'

mo = eTree.SubElement(row, 'mo')
mo.text = '&#x0005D;'
print(_convert(math))
print(convert(latex))
assert _convert(math) == convert(latex)

@@ -86,4 +86,19 @@ def test_subscript():


def test_superscript_with_curly_braces():
assert ['a', '^', '{', 'i', '+', '1', '}', '_', '3'] == list(tokenize('a^{i+1}_3'))
assert ['a', '^', '{', 'i', '+', '1', '}', '_', '3'] == list(tokenize('a^{i+1}_3'))


def test_issue_33():
latex = r"""\begin{bmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{bmatrix}"""
expected = ['\\begin{bmatrix}', 'a', '_', '{', '1', ',', '1', '}', '&', 'a', '_', '{', '1', ',', '2', '}', '&',
'\\cdots', '&', 'a', '_', '{', '1', ',', 'n', '}', '\\\\', 'a', '_', '{', '2', ',', '1', '}', '&', 'a',
'_', '{', '2', ',', '2', '}', '&', '\\cdots', '&', 'a', '_', '{', '2', ',', 'n', '}', '\\\\', '\\vdots',
'&', '\\vdots', '&', '\\ddots', '&', '\\vdots', '\\\\', 'a', '_', '{', 'm', ',', '1', '}', '&', 'a',
'_', '{', 'm', ',', '2', '}', '&', '\\cdots', '&', 'a', '_', '{', 'm', ',', 'n', '}', '\\end{bmatrix}']
assert expected == list(tokenize(latex))

0 comments on commit fbaad9d

Please sign in to comment.
You can’t perform that action at this time.