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

PEP8

parent f938d037
# Copyright (c) 2016, Jean-Benoist Leger <jb@leger.tf>
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......@@ -61,7 +61,7 @@ __title__ = 'flatlatex'
__author__ = 'Jean-Benoist Leger'
__licence__ = 'BSD-2'
version_info = (0,2)
__version__ = '.'.join(map(str,version_info))
version_info = (0, 2)
__version__ = '.'.join(map(str, version_info))
from .conv import converter
This diff is collapsed.
# Copyright (c) 2016, Jean-Benoist Leger <jb@leger.tf>
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......@@ -23,23 +23,23 @@
# POSSIBILITY OF SUCH DAMAGE.
known_fracts = {
('1','2'): '½',
('1','3'): '⅓',
('2','3'): '⅔',
('1','4'): '¼',
('3','4'): '¾',
('1','5'): '⅕',
('2','5'): '⅖',
('3','5'): '⅗',
('4','5'): '⅘',
('1','6'): '⅙',
('5','6'): '⅚',
('1','7'): '⅐',
('1','8'): '⅛',
('3','8'): '⅜',
('5','8'): '⅝',
('7','8'): '⅞',
('1','9'): '⅑',
('1', '2'): '½',
('1', '3'): '⅓',
('2', '3'): '⅔',
('1', '4'): '¼',
('3', '4'): '¾',
('1', '5'): '⅕',
('2', '5'): '⅖',
('3', '5'): '⅗',
('4', '5'): '⅘',
('1', '6'): '⅙',
('5', '6'): '⅚',
('1', '7'): '⅐',
('1', '8'): '⅛',
('3', '8'): '⅜',
('5', '8'): '⅝',
('7', '8'): '⅞',
('1', '9'): '⅑',
}
subscript = {
......@@ -140,8 +140,8 @@ superscript = {
'∊': 'ᵋ',
'θ': 'ᶿ',
'ι': 'ᶥ',
'Φ': 'ᶲ',
'φ': 'ᵠ',
'Φ': 'ᶲ',
'φ': 'ᵠ',
'χ': 'ᵡ',
}
......@@ -622,8 +622,6 @@ mono = {
}
symbols = {
r'\_': '_',
r'\\': '\\',
......@@ -967,20 +965,20 @@ symbols = {
}
combinings = {
r'\hat': ('\u0302','hat'),
r'\grave': ('\u0301','grave'),
r'\dot': ('\u0307','dot'),
r'\not': ('\u0338','not'),
r'\overrightarrow': ('\u20d7','overrightarrow'),
r'\overline': ('\u0305','overline'),
r'\tilde': ('\u0303','tilde'),
r'\bar': ('\u0304','bar'),
r'\acute': ('\u0300','acute'),
r'\ddot': ('\u0308','ddot'),
r'\overleftarrow': ('\u20d6','overleftarrow'),
r'\check': ('\u030c','check'),
r'\vec': ('\u20d7','vec'),
r'\underline': ('\u0332','underline'),
r'\hat': ('\u0302', 'hat'),
r'\grave': ('\u0301', 'grave'),
r'\dot': ('\u0307', 'dot'),
r'\not': ('\u0338', 'not'),
r'\overrightarrow': ('\u20d7', 'overrightarrow'),
r'\overline': ('\u0305', 'overline'),
r'\tilde': ('\u0303', 'tilde'),
r'\bar': ('\u0304', 'bar'),
r'\acute': ('\u0300', 'acute'),
r'\ddot': ('\u0308', 'ddot'),
r'\overleftarrow': ('\u20d6', 'overleftarrow'),
r'\check': ('\u030c', 'check'),
r'\vec': ('\u20d7', 'vec'),
r'\underline': ('\u0332', 'underline'),
}
newcommands = (
......
# Copyright (c) 2016, Jean-Benoist Leger <jb@leger.tf>
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......@@ -22,11 +22,13 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
class latexfun:
def __init__(self, fun, nargs):
self.fun = fun
self.nargs = nargs
class LatexSyntaxError(SyntaxError):
pass
# Copyright (c) 2016, Jean-Benoist Leger <jb@leger.tf>
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......@@ -25,25 +25,27 @@
import regex
from .latexfuntypes import LatexSyntaxError
def parse_one_element(s):
R = r'((?>\\(?:[^A-Za-z]|[A-Za-z]+))|(?>[^\{\}\\])|\{(?1)*\})'
r = regex.match(R,s)
r = regex.match(R, s)
if not r:
raise LatexSyntaxError
s = s[r.span()[1]:]
c = r.captures()[0]
if c[0] == '\\':
return ( ('cmd', c), s)
return (('cmd', c), s)
if c[0] == '{':
return ( ('subexpr', c[1:-1]), s)
if c in ('_','^'):
return ( ('oper', c), s)
return ( ('char', c), s)
return (('subexpr', c[1:-1]), s)
if c in ('_', '^'):
return (('oper', c), s)
return (('char', c), s)
def parse(s):
l = []
while len(s)>0:
m,s = parse_one_element(s)
while len(s) > 0:
m, s = parse_one_element(s)
if not (m[1] == ' '):
l.append(m)
return l
# Copyright (c) 2016, Jean-Benoist Leger <jb@leger.tf>
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......@@ -24,8 +24,10 @@
from . import latexfuntypes
def transliterate(alphabet):
alphabet_keys = alphabet.keys()
def fun(flat_input):
flat_output = ''
success = True
......@@ -38,11 +40,6 @@ def transliterate(alphabet):
return (flat_output, success)
return fun
def transliterator(alphabet):
return latexfuntypes.latexfun(lambda x: transliterate(alphabet)(x[0])[0],1)
def transliterator(alphabet):
return latexfuntypes.latexfun(lambda x: transliterate(alphabet)(x[0])[0], 1)
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