add formatter macros for \begin{macrocode}

This commit is contained in:
Maximilian Keßler 2022-02-17 20:46:39 +01:00
parent 205dc4eeac
commit adb168d453
2 changed files with 25 additions and 1 deletions

View file

@ -29,7 +29,9 @@ def get_default_macros(tex_flavour: TeXFlavour):
make_simple_macro('repodirty', FormatterProperty.repo_dirty),
make_simple_macro('sourcename', FormatterProperty.source_file_name),
ConfigEndMacro(),
ConfigBeginMacro()
ConfigBeginMacro(),
MacroCodeBeginMacro(),
MacroCodeBeginMacro(),
]
tex2 = [
ArgumentMacro(

View file

@ -138,6 +138,28 @@ class ConfigEndMacro(SingleLineMacro):
return []
class MacroCodeBeginMacro(SingleLineMacro):
def __init__(self):
super(MacroCodeBeginMacro, self).__init__(r'\begin{macrocode}')
def apply(self, line: str, formatter) -> Union[str, List[str]]:
if not formatter.mode == FormatterMode.meta:
raise NotImplementedError
formatter.mode = FormatterMode.macrocode
return r'% \begin{macrocode}'
class MacroCodeEndMacro(SingleLineMacro):
def __init__(self):
super(MacroCodeEndMacro, self).__init__(r'\end{macrocode}')
def apply(self, line: str, formatter) -> Union[str, List[str]]:
if not formatter.mode == FormatterMode.macrocode:
raise NotImplementedError
formatter.mode = FormatterMode.meta
return r'% \end{macrocode}'
class ArgumentMacro(Macro):
def __init__(
self,