finer macro selection
This commit is contained in:
parent
a64f5a01bf
commit
065734a628
2 changed files with 15 additions and 8 deletions
|
@ -48,7 +48,7 @@ def formatter_from_file_extension(
|
|||
allow_infile_config=allow_infile_config
|
||||
)
|
||||
if default_macros:
|
||||
formatter.macros = get_default_macros(formatter.config.tex_flavour)
|
||||
formatter.macros = get_default_macros(formatter.config.tex_flavour, formatter.config.tex_type)
|
||||
return formatter
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from .macros import *
|
||||
from .enums import TeXFlavour, Argument
|
||||
from .enums import TeXFlavour, Argument, TeXType
|
||||
|
||||
|
||||
def make_simple_macro(name: str, arg):
|
||||
|
@ -12,7 +12,7 @@ def make_simple_macro(name: str, arg):
|
|||
)
|
||||
|
||||
|
||||
def get_default_macros(tex_flavour: TeXFlavour):
|
||||
def get_default_macros(tex_flavour: TeXFlavour, tex_type: TeXType):
|
||||
both = [
|
||||
make_simple_macro('!', FormatterProperty.file_prefix),
|
||||
make_simple_macro('name', FormatterProperty.name),
|
||||
|
@ -28,14 +28,16 @@ def get_default_macros(tex_flavour: TeXFlavour):
|
|||
make_simple_macro('repocommit', FormatterProperty.repo_commit),
|
||||
make_simple_macro('repodirty', FormatterProperty.repo_dirty),
|
||||
make_simple_macro('sourcename', FormatterProperty.source_file_name),
|
||||
make_simple_macro('outtype', FormatterProperty.tex_out_type),
|
||||
ImplementationBeginMacro(),
|
||||
ImplementationEndMacro(),
|
||||
ConfigEndMacro(),
|
||||
ConfigBeginMacro(),
|
||||
]
|
||||
docstrip = [
|
||||
make_simple_macro('outtype', FormatterProperty.tex_out_type),
|
||||
MacroCodeBeginMacro(),
|
||||
MacroCodeEndMacro(),
|
||||
GuardMacro(),
|
||||
ImplementationBeginMacro(),
|
||||
ImplementationEndMacro(),
|
||||
]
|
||||
tex2 = [
|
||||
ArgumentMacro(
|
||||
|
@ -97,9 +99,14 @@ def get_default_macros(tex_flavour: TeXFlavour):
|
|||
)
|
||||
)
|
||||
]
|
||||
macros = both
|
||||
if tex_flavour == TeXFlavour.LaTeX2e:
|
||||
return tex2 + both
|
||||
macros += tex2
|
||||
elif tex_flavour == TeXFlavour.LaTeX3:
|
||||
return tex3 + both
|
||||
macros += tex3
|
||||
else:
|
||||
raise NotImplementedError
|
||||
if tex_type == TeXType.TeXDocstrip:
|
||||
macros += docstrip
|
||||
|
||||
return macros
|
||||
|
|
Loading…
Reference in a new issue