How to use the pylatexenc.macrospec.std_macro 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 / test / test_macrospec.py View on Github external
def test_filter_context_0(self):
        
        db = LatexContextDb()
        db.set_unknown_macro_spec(MacroSpec(''))
        db.set_unknown_environment_spec(EnvironmentSpec(''))
        db.add_context_category('cat1',
                                [ std_macro('aaa', '{'), std_macro('bbb', '[{[') ],
                                [ std_environment('eaaa', '{'), std_environment('ebbb', '[{[') ])
        db.add_context_category('cat2',
                                [ std_macro('aaa', '[{'), std_macro('ccc', None) ],
                                [ std_environment('eaaa', '[{'), std_environment('eccc', None) ])
        db.add_context_category('cat3',
                                [ std_macro('ccc', '*{'), std_macro('ddd', '{{[') ],
                                [ std_environment('eccc', '*{'), std_environment('eddd', '{{[') ],
                                prepend=True)
        
        db2 = db.filter_context(keep_categories=['cat1', 'cat2'])
        # this should give 'ccc' from cat2, not cat3
        self.assertEqual(db2.get_macro_spec('ccc').macroname, 'ccc')
        self.assertEqual(db2.get_macro_spec('ccc').args_parser.argspec, '')
        # this should no longer exist
        self.assertEqual(db2.get_macro_spec('ddd').macroname, '')
        self.assertEqual(db2.get_macro_spec('ddd').args_parser.argspec, '')

        # this should give 'eccc' from cat2, not cat3
        self.assertEqual(db2.get_environment_spec('eccc').environmentname, 'eccc')
        self.assertEqual(db2.get_environment_spec('eccc').args_parser.argspec, '')
        # this should no longer exist
        self.assertEqual(db2.get_environment_spec('eddd').environmentname, '')
github phfaist / pylatexenc / test / test_macrospec.py View on Github external
def test_can_get_macro_spec(self):
        db = LatexContextDb()
        db.set_unknown_macro_spec(MacroSpec(''))
        db.add_context_category('cat1', [ std_macro('aaa', '{'), std_macro('bbb', '[{[') ], [])
        db.add_context_category('cat2', [ std_macro('aaa', '[{'), std_macro('ccc', None) ], [])
        db.add_context_category('cat3', [ std_macro('ccc', '*{'), std_macro('ddd', '{{[') ], [],
                                prepend=True)

        self.assertEqual(list(db.categories()), ['cat3', 'cat1', 'cat2'])
        
        self.assertEqual(db.get_macro_spec('aaa').macroname, 'aaa')
        self.assertEqual(db.get_macro_spec('aaa').args_parser.argspec, '{')

        self.assertEqual(db.get_macro_spec('bbb').macroname, 'bbb')
        self.assertEqual(db.get_macro_spec('bbb').args_parser.argspec, '[{[')

        self.assertEqual(db.get_macro_spec('ccc').macroname, 'ccc')
        self.assertEqual(db.get_macro_spec('ccc').args_parser.argspec, '*{')

        self.assertEqual(db.get_macro_spec('ddd').macroname, 'ddd')
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
std_macro("u", False, 1),
            std_macro("v", False, 1),

            MacroSpec('ensuremath', args_parser=MacroStandardArgsParser('{', args_math_mode=[True])),

            std_macro("not", False, 1),

            std_macro("vec", False, 1),
            std_macro("dot", False, 1),
            std_macro("hat", False, 1),
            std_macro("check", False, 1),
            std_macro("breve", False, 1),
            std_macro("acute", False, 1),
            std_macro("grave", False, 1),
            std_macro("tilde", False, 1),
            std_macro("bar", False, 1),
            std_macro("ddot", False, 1),

            std_macro('frac', False, 2),
            std_macro('nicefrac', False, 2),

            std_macro('sqrt', True, 1),

            std_macro('ket', False, 1),
            std_macro('bra', False, 1),
            std_macro('braket', False, 2),
            std_macro('ketbra', False, 2),

            std_macro('texorpdfstring', False, 2),
        ],
        'environments': [
            # NOTE: Starred variants (as in \begin{equation*}) are not specified as
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
#
    # CATEGORY: latex-ethuebung
    #
    ('latex-ethuebung', {
        'macros': [
            # ethuebung
            std_macro('UebungLoesungFont', False, 1),
            std_macro('UebungHinweisFont', False, 1),
            std_macro('UebungExTitleFont', False, 1),
            std_macro('UebungSubExTitleFont', False, 1),
            std_macro('UebungTipsFont', False, 1),
            std_macro('UebungLabel', False, 1),
            std_macro('UebungSubLabel', False, 1),
            std_macro('UebungLabelEnum', False, 1),
            std_macro('UebungLabelEnumSub', False, 1),
            std_macro('UebungSolLabel', False, 1),
            std_macro('UebungHinweisLabel', False, 1),
            std_macro('UebungHinweiseLabel', False, 1),
            std_macro('UebungSolEquationLabel', False, 1),
            std_macro('UebungTipsLabel', False, 1),
            std_macro('UebungTipsEquationLabel', False, 1),
            std_macro('UebungsblattTitleSeries', False, 1),
            std_macro('UebungsblattTitleSolutions', False, 1),
            std_macro('UebungsblattTitleTips', False, 1),
            std_macro('UebungsblattNumber', False, 1),
            std_macro('UebungsblattTitleFont', False, 1),
            std_macro('UebungTitleCenterVSpacing', False, 1),
            std_macro('UebungAttachedSolutionTitleTop', False, 1),
            std_macro('UebungAttachedSolutionTitleFont', False, 1),
            std_macro('UebungAttachedSolutionTitle', False, 1),
            std_macro('UebungTextAttachedSolution', False, 1),
            std_macro('UebungDueByLabel', False, 1),
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
std_macro('UebungsblattNumber', False, 1),
            std_macro('UebungsblattTitleFont', False, 1),
            std_macro('UebungTitleCenterVSpacing', False, 1),
            std_macro('UebungAttachedSolutionTitleTop', False, 1),
            std_macro('UebungAttachedSolutionTitleFont', False, 1),
            std_macro('UebungAttachedSolutionTitle', False, 1),
            std_macro('UebungTextAttachedSolution', False, 1),
            std_macro('UebungDueByLabel', False, 1),
            std_macro('UebungDueBy', False, 1),
            std_macro('UebungLecture', False, 1),
            std_macro('UebungProf', False, 1),
            std_macro('UebungLecturer', False, 1),
            std_macro('UebungSemester', False, 1),
            std_macro('UebungLogoFile', False, 1),
            std_macro('UebungLanguage', False, 1),
            std_macro('UebungStyle', False, 1),
            #
            std_macro('uebung', '{['),
            std_macro('exercise', '{['),
            std_macro('keywords', False, 1),
            std_macro('subuebung', False, 1),
            std_macro('subexercise', False, 1),
            std_macro('pdfloesung', True, 1),
            std_macro('pdfsolution', True, 1),
            std_macro('exenumfulllabel', False, 1),
            std_macro('hint', False, 1),
            std_macro('hints', False, 1),
            std_macro('hinweis', False, 1),
            std_macro('hinweise', False, 1),
        ],
        'environments': [
        ],
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
std_macro("H", False, 1),
            std_macro("k", False, 1),
            std_macro("=", False, 1),
            std_macro("b", False, 1),
            std_macro(".", False, 1),
            std_macro("d", False, 1),
            std_macro("r", False, 1),
            std_macro("u", False, 1),
            std_macro("v", False, 1),

            MacroSpec('ensuremath', args_parser=MacroStandardArgsParser('{', args_math_mode=[True])),

            std_macro("not", False, 1),

            std_macro("vec", False, 1),
            std_macro("dot", False, 1),
            std_macro("hat", False, 1),
            std_macro("check", False, 1),
            std_macro("breve", False, 1),
            std_macro("acute", False, 1),
            std_macro("grave", False, 1),
            std_macro("tilde", False, 1),
            std_macro("bar", False, 1),
            std_macro("ddot", False, 1),

            std_macro('frac', False, 2),
            std_macro('nicefrac', False, 2),

            std_macro('sqrt', True, 1),

            std_macro('ket', False, 1),
            std_macro('bra', False, 1),
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
std_macro('cite', '*[[{'),
            std_macro('citet', '*[[{'),
            std_macro('citep', '*[[{'),
            std_macro('citealt', '*[[{'),
            std_macro('citealp', '*[[{'),
            std_macro('citeauthor', '*[[{'),
            std_macro('citefullauthor', '[[{'),
            std_macro('citeyear', '[[{'),
            std_macro('citeyearpar', '[[{'),
            std_macro('Citet', '*[[{'),
            std_macro('Citep', '*[[{'),
            std_macro('Citealt', '*[[{'),
            std_macro('Citealp', '*[[{'),
            std_macro('Citeauthor', '*[[{'),

            std_macro('citetext', '{'),
            std_macro('citenum', '{'),

            std_macro('defcitealias', '{{'),
            std_macro('citetalias', '[[{'),
            std_macro('citepalias', '[[{'),
        ],
        'environments': [
        ],
        'specials': [
        ]}),


    #
    # CATEGORY: latex-ethuebung
    #
    ('latex-ethuebung', {
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
std_macro('UebungDueBy', False, 1),
            std_macro('UebungLecture', False, 1),
            std_macro('UebungProf', False, 1),
            std_macro('UebungLecturer', False, 1),
            std_macro('UebungSemester', False, 1),
            std_macro('UebungLogoFile', False, 1),
            std_macro('UebungLanguage', False, 1),
            std_macro('UebungStyle', False, 1),
            #
            std_macro('uebung', '{['),
            std_macro('exercise', '{['),
            std_macro('keywords', False, 1),
            std_macro('subuebung', False, 1),
            std_macro('subexercise', False, 1),
            std_macro('pdfloesung', True, 1),
            std_macro('pdfsolution', True, 1),
            std_macro('exenumfulllabel', False, 1),
            std_macro('hint', False, 1),
            std_macro('hints', False, 1),
            std_macro('hinweis', False, 1),
            std_macro('hinweise', False, 1),
        ],
        'environments': [
        ],
        'specials': [
        ]
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
'environments': [
            std_environment('enumerate', '['),
            std_environment('itemize', '['),
            std_environment('description', '['),
        ],
        'specials': [
        ]}),

    #
    # CATEGORY: natbib
    #
    ('natbib', {
        'macros': [
            std_macro('cite', '*[[{'),
            std_macro('citet', '*[[{'),
            std_macro('citep', '*[[{'),
            std_macro('citealt', '*[[{'),
            std_macro('citealp', '*[[{'),
            std_macro('citeauthor', '*[[{'),
            std_macro('citefullauthor', '[[{'),
            std_macro('citeyear', '[[{'),
            std_macro('citeyearpar', '[[{'),
            std_macro('Citet', '*[[{'),
            std_macro('Citep', '*[[{'),
            std_macro('Citealt', '*[[{'),
            std_macro('Citealp', '*[[{'),
            std_macro('Citeauthor', '*[[{'),

            std_macro('citetext', '{'),
            std_macro('citenum', '{'),

            std_macro('defcitealias', '{{'),
github phfaist / pylatexenc / pylatexenc / latexwalker / _defaultspecs.py View on Github external
std_macro('UebungSemester', False, 1),
            std_macro('UebungLogoFile', False, 1),
            std_macro('UebungLanguage', False, 1),
            std_macro('UebungStyle', False, 1),
            #
            std_macro('uebung', '{['),
            std_macro('exercise', '{['),
            std_macro('keywords', False, 1),
            std_macro('subuebung', False, 1),
            std_macro('subexercise', False, 1),
            std_macro('pdfloesung', True, 1),
            std_macro('pdfsolution', True, 1),
            std_macro('exenumfulllabel', False, 1),
            std_macro('hint', False, 1),
            std_macro('hints', False, 1),
            std_macro('hinweis', False, 1),
            std_macro('hinweise', False, 1),
        ],
        'environments': [
        ],
        'specials': [
        ]