diff --git a/PyTeX/format/enums.py b/PyTeX/format/enums.py index cd43aeb..991d2a9 100644 --- a/PyTeX/format/enums.py +++ b/PyTeX/format/enums.py @@ -74,6 +74,7 @@ class FormatterProperty(MacroReplacementAtomIF, Enum): year = 'year' raw_name = 'raw_name' # The 'raw' name of the package, without author prefix name = 'name' # class or package name + file_prefix = 'file_prefix' version = 'version' file_name = 'file_name' source_file_name = 'source_file_name' diff --git a/PyTeX/format/macros.py b/PyTeX/format/macros.py index d374c69..169e977 100644 --- a/PyTeX/format/macros.py +++ b/PyTeX/format/macros.py @@ -23,7 +23,7 @@ class MacroReplacement: for arg in self.args: if type(arg) == FormatterProperty: try: - new_args.append(getattr(formatter, arg.value)) + new_args.append(formatter.attribute_dict[arg.value]) except: raise NotImplementedError elif type(arg) == Argument: diff --git a/PyTeX/format/pytex_formatter.py b/PyTeX/format/pytex_formatter.py index a352809..48cdba9 100644 --- a/PyTeX/format/pytex_formatter.py +++ b/PyTeX/format/pytex_formatter.py @@ -151,6 +151,7 @@ class PyTeXFormatter(FormatterIF, ABC): FormatterProperty.pytex_dirty.value: self.git_version_info.pytex_version.dirty, FormatterProperty.tex_type.value: str(self.config.tex_type), FormatterProperty.tex_flavour.value: str(self.config.tex_flavour), + FormatterProperty.file_prefix.value: str(self.file_prefix) } @property @@ -175,6 +176,18 @@ class PyTeXFormatter(FormatterIF, ABC): else: return parts[0] + @property + def file_prefix(self) -> str: + if self.config.naming_scheme == NamingScheme.prepend_author: + if self.config.tex_flavour == TeXFlavour.LaTeX2e: + return self.shortauthor + '@' + self.raw_name + elif self.config.tex_flavour == TeXFlavour.LaTeX3: + return self.shortauthor + '_' + self.raw_name + else: + raise NotImplementedError + else: + return self.raw_name + @property def name(self): if self.config.naming_scheme == NamingScheme.prepend_author: