Commit c11566f0 authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

Docstrings

parent 332d61f9
......@@ -22,4 +22,34 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""
LaTeX math to Unicode text converter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flatlatex is a basic converter from LaTeX math to human readable text math using
unicode characters.
Example:
>>> import flatlatex
>>> c = flatlatex.converter()
>>> c.convert(
... r'\\forall \\eta>0\\, \\exists n\\in\\mathbb{N}\\, \\forall i>n\\, |u_i-n|<\\eta')
'∀η>0 ∃n∊ℕ ∀i>n |uᵢ-n|<η'
The behavior can be change:
>>> import flatlatex
>>> c = flatlatex.converter()
>>> c.convert(r'\\frac{8}{9}')
'⁸⁄₉'
>>> c.allow_zw = False
>>> c.convert(r'\\frac{8}{9}')
'8/9'
"""
__title__ = 'flatlatex'
__author__ = 'Jean-Benoist Leger'
__licence__ = 'BSD-2'
from .conv import converter
......@@ -32,7 +32,16 @@ class LatexSyntaxError(SyntaxError):
pass
class converter:
"""flatlatex converter class
:attrib allow_zw: boolean which indicate if zero width characters are allowed
(True by default).
:attrib allow_combinings: boolean which indicate if combining characters are allowed
(True by default).
"""
def __init__(self):
"""Initialize a convert method."""
# transliteration
self.__cmds = {
......@@ -68,6 +77,10 @@ class converter:
self.allow_combinings = True
def convert(self, expr):
"""Convert LaTeX math to Unicode text.
:param expr: LaTeX math expression to convert"""
parsed = parser.parse(expr)
outvec = []
idx = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment