How to use the pylatexenc.latex2text.MacroTextSpec function in pylatexenc

To help you get started, we’ve selected a few pylatexenc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
'macros': [
        # NOTE: macro will only be assigned arguments if they are explicitly defined as
        #       accepting arguments in latexwalker.py.
        MacroTextSpec('emph', discard=False),
        MacroTextSpec('textrm', discard=False),
        MacroTextSpec('textit', discard=False),
        MacroTextSpec('textbf', discard=False),
        MacroTextSpec('textsc', discard=False),
        MacroTextSpec('textsl', discard=False),
        MacroTextSpec('text', discard=False),

        MacroTextSpec('mathrm', discard=False),
        MacroTextSpec('mathbb', discard=False),
        MacroTextSpec('mathbf', discard=False),
        MacroTextSpec('mathsf', discard=False),
        MacroTextSpec('mathscr', discard=False),
        MacroTextSpec('mathfrak', discard=False),


        MacroTextSpec('input', simplify_repl=fmt_input_macro),
        MacroTextSpec('include', simplify_repl=fmt_input_macro),

    ] + [ MacroTextSpec(x, simplify_repl=y) for x, y in (

        ('includegraphics', placeholder_node_formatter('graphics')),

        ('ref', ''),
        ('autoref', ''),
        ('cref', ''),
        ('Cref', ''),
        ('eqref', '()'),
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
SpecialsTextSpec('``', u"\N{LEFT DOUBLE QUOTATION MARK}"),
            SpecialsTextSpec("''", u"\N{RIGHT DOUBLE QUOTATION MARK}"),
            SpecialsTextSpec("--", u"\N{EN DASH}"),
            SpecialsTextSpec("---", u"\N{EM DASH}"),
            SpecialsTextSpec("!`", u"\N{INVERTED EXCLAMATION MARK}"),
            SpecialsTextSpec("?`", u"\N{INVERTED QUESTION MARK}"),
        ]
    }),

    #
    # CATEGORY: latex-ethuebung
    #
    ('latex-ethuebung', {
        'macros': [
            MacroTextSpec('exercise', simplify_repl=_format_uebung),
            MacroTextSpec('uebung', simplify_repl=_format_uebung),
            MacroTextSpec('hint', 'Hint: %s'),
            MacroTextSpec('hints', 'Hints: %s'),
            MacroTextSpec('hinweis', 'Hinweis: %s'),
            MacroTextSpec('hinweise', 'Hinweise: %s'),
        ],
        'environments': [],
        'specials': []
    }),

]





def _greekletters(letterlist):
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
if ucharname == 'PHI':
            smallname = "GREEK PHI SYMBOL"
        latex_base_specs['macros'].append(
            MacroTextSpec(l, unicodedata.lookup(smallname))
        )
        latex_base_specs['macros'].append(
            MacroTextSpec(l[0].upper()+l[1:], unicodedata.lookup("GREEK CAPITAL LETTER "+ucharname))
            )
_greekletters(
    ('alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa',
     'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi',
     'chi', 'psi', 'omega')
)
latex_base_specs['macros'] += [
    MacroTextSpec('varepsilon', u'\N{GREEK SMALL LETTER EPSILON}'),
    MacroTextSpec('vartheta', u'\N{GREEK THETA SYMBOL}'),
    MacroTextSpec('varpi', u'\N{GREEK PI SYMBOL}'),
    MacroTextSpec('varrho', u'\N{GREEK RHO SYMBOL}'),
    MacroTextSpec('varsigma', u'\N{GREEK SMALL LETTER FINAL SIGMA}'),
    MacroTextSpec('varphi', u'\N{GREEK SMALL LETTER PHI}'),
    ]


unicode_accents_list = (
    # see http://en.wikibooks.org/wiki/LaTeX/Special_Characters for a list
    ("'", u"\N{COMBINING ACUTE ACCENT}"),
    ("`", u"\N{COMBINING GRAVE ACCENT}"),
    ('"', u"\N{COMBINING DIAERESIS}"),
    ("c", u"\N{COMBINING CEDILLA}"),
    ("^", u"\N{COMBINING CIRCUMFLEX ACCENT}"),
    ("~", u"\N{COMBINING TILDE}"),
    ("H", u"\N{COMBINING DOUBLE ACUTE ACCENT}"),
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
def _greekletters(letterlist):
    for l in letterlist:
        ucharname = l.upper()
        if ucharname == 'LAMBDA':
            ucharname = 'LAMDA'
        smallname = "GREEK SMALL LETTER "+ucharname
        if ucharname == 'EPSILON':
            smallname = "GREEK LUNATE EPSILON SYMBOL"
        if ucharname == 'PHI':
            smallname = "GREEK PHI SYMBOL"
        latex_base_specs['macros'].append(
            MacroTextSpec(l, unicodedata.lookup(smallname))
        )
        latex_base_specs['macros'].append(
            MacroTextSpec(l[0].upper()+l[1:], unicodedata.lookup("GREEK CAPITAL LETTER "+ucharname))
            )
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
def _greekletters(letterlist):
    for l in letterlist:
        ucharname = l.upper()
        if ucharname == 'LAMBDA':
            ucharname = 'LAMDA'
        smallname = "GREEK SMALL LETTER "+ucharname
        if ucharname == 'EPSILON':
            smallname = "GREEK LUNATE EPSILON SYMBOL"
        if ucharname == 'PHI':
            smallname = "GREEK PHI SYMBOL"
        latex_base_specs['macros'].append(
            MacroTextSpec(l, unicodedata.lookup(smallname))
        )
        latex_base_specs['macros'].append(
            MacroTextSpec(l[0].upper()+l[1:], unicodedata.lookup("GREEK CAPITAL LETTER "+ucharname))
            )
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
SpecialsTextSpec("!`", u"\N{INVERTED EXCLAMATION MARK}"),
            SpecialsTextSpec("?`", u"\N{INVERTED QUESTION MARK}"),
        ]
    }),

    #
    # CATEGORY: latex-ethuebung
    #
    ('latex-ethuebung', {
        'macros': [
            MacroTextSpec('exercise', simplify_repl=_format_uebung),
            MacroTextSpec('uebung', simplify_repl=_format_uebung),
            MacroTextSpec('hint', 'Hint: %s'),
            MacroTextSpec('hints', 'Hints: %s'),
            MacroTextSpec('hinweis', 'Hinweis: %s'),
            MacroTextSpec('hinweise', 'Hinweise: %s'),
        ],
        'environments': [],
        'specials': []
    }),

]





def _greekletters(letterlist):
    for l in letterlist:
        ucharname = l.upper()
        if ucharname == 'LAMBDA':
            ucharname = 'LAMDA'
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
ch = unicode(ch)
        combining = unicode(combining)
        if (ch == u"\N{LATIN SMALL LETTER DOTLESS I}"):
            ch = u"i"
        if (ch == u"\N{LATIN SMALL LETTER DOTLESS J}"):
            ch = u"j"
        #print u"Accenting %s with %s"%(ch, combining) # this causes UnicdeDecodeError!!!
        return unicodedata.normalize('NFC', unicode(ch)+combining)

    return u"".join([getaccented(ch, combining) for ch in c])


for u in unicode_accents_list:
    (mname, mcombining) = u
    latex_base_specs['macros'].append(
        MacroTextSpec(mname, lambda x, l2tobj, c=mcombining: make_accented_char(x, c, l2tobj))
    )
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
smallname = "GREEK PHI SYMBOL"
        latex_base_specs['macros'].append(
            MacroTextSpec(l, unicodedata.lookup(smallname))
        )
        latex_base_specs['macros'].append(
            MacroTextSpec(l[0].upper()+l[1:], unicodedata.lookup("GREEK CAPITAL LETTER "+ucharname))
            )
_greekletters(
    ('alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa',
     'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi',
     'chi', 'psi', 'omega')
)
latex_base_specs['macros'] += [
    MacroTextSpec('varepsilon', u'\N{GREEK SMALL LETTER EPSILON}'),
    MacroTextSpec('vartheta', u'\N{GREEK THETA SYMBOL}'),
    MacroTextSpec('varpi', u'\N{GREEK PI SYMBOL}'),
    MacroTextSpec('varrho', u'\N{GREEK RHO SYMBOL}'),
    MacroTextSpec('varsigma', u'\N{GREEK SMALL LETTER FINAL SIGMA}'),
    MacroTextSpec('varphi', u'\N{GREEK SMALL LETTER PHI}'),
    ]


unicode_accents_list = (
    # see http://en.wikibooks.org/wiki/LaTeX/Special_Characters for a list
    ("'", u"\N{COMBINING ACUTE ACCENT}"),
    ("`", u"\N{COMBINING GRAVE ACCENT}"),
    ('"', u"\N{COMBINING DIAERESIS}"),
    ("c", u"\N{COMBINING CEDILLA}"),
    ("^", u"\N{COMBINING CIRCUMFLEX ACCENT}"),
    ("~", u"\N{COMBINING TILDE}"),
    ("H", u"\N{COMBINING DOUBLE ACUTE ACCENT}"),
    ("k", u"\N{COMBINING OGONEK}"),
github phfaist / pylatexenc / pylatexenc / latex2text / _defaultspecs.py View on Github external
EnvironmentTextSpec('list', discard=False),
        EnvironmentTextSpec('itemize', discard=False),
        EnvironmentTextSpec('subequations', discard=False),
        EnvironmentTextSpec('figure', discard=False),
        EnvironmentTextSpec('table', discard=False),

    ],
    'specials': [
        SpecialsTextSpec('&', '   '), # ignore tabular alignments, just add a little space
    ],

    'macros': [
        # NOTE: macro will only be assigned arguments if they are explicitly defined as
        #       accepting arguments in latexwalker.py.
        MacroTextSpec('emph', discard=False),
        MacroTextSpec('textrm', discard=False),
        MacroTextSpec('textit', discard=False),
        MacroTextSpec('textbf', discard=False),
        MacroTextSpec('textsc', discard=False),
        MacroTextSpec('textsl', discard=False),
        MacroTextSpec('text', discard=False),

        MacroTextSpec('mathrm', discard=False),
        MacroTextSpec('mathbb', discard=False),
        MacroTextSpec('mathbf', discard=False),
        MacroTextSpec('mathsf', discard=False),
        MacroTextSpec('mathscr', discard=False),
        MacroTextSpec('mathfrak', discard=False),


        MacroTextSpec('input', simplify_repl=fmt_input_macro),
        MacroTextSpec('include', simplify_repl=fmt_input_macro),