diff --git a/PyTeX/format/enums.py b/PyTeX/format/enums.py index 991d2a9..3df3feb 100644 --- a/PyTeX/format/enums.py +++ b/PyTeX/format/enums.py @@ -4,8 +4,24 @@ from typing import Optional class NamingScheme(Enum): - prepend_author = 0 - clean = 1 + prepend_author = 'prepend_author' + clean = 'clean' + + @staticmethod + def parse(naming_scheme: str) -> Optional[NamingScheme]: + if naming_scheme is None: + return None + switcher = { + 'prepend-author': NamingScheme.prepend_author, + 'prepend author': NamingScheme.prepend_author, + 'author': NamingScheme.prepend_author, + 'clean': NamingScheme.clean, + 'raw': NamingScheme.clean + } + if not naming_scheme in switcher.keys(): + raise NotImplementedError + else: + return switcher[naming_scheme] class TeXType(Enum): diff --git a/PyTeX/format/formatting_config.py b/PyTeX/format/formatting_config.py index 6a89fb1..656765c 100644 --- a/PyTeX/format/formatting_config.py +++ b/PyTeX/format/formatting_config.py @@ -44,7 +44,7 @@ class FormattingConfig(Config): info = filled_content[YAML_INFO] self._author = info[YAML_AUTHOR] - self._naming_scheme = info[YAML_NAMING_SCHEME] + self._naming_scheme = NamingScheme.parse(info[YAML_NAMING_SCHEME]) self._tex_flavour = TeXFlavour.parse(info[YAML_TEX_FLAVOUR]) self._tex_type = TeXType.parse(info[YAML_TEX_TYPE]) self._description = info[YAML_DESCRIPTION] diff --git a/PyTeX/format/pytex_formatter.py b/PyTeX/format/pytex_formatter.py index fa1bcfd..e8a38d7 100644 --- a/PyTeX/format/pytex_formatter.py +++ b/PyTeX/format/pytex_formatter.py @@ -162,7 +162,7 @@ class PyTeXFormatter(FormatterIF, ABC): @property def shortauthor(self) -> str: - parts = self.config.author.replace('ß', 'ss').split(' ') # TODO: better non-alphanumeric handling + parts = self.config.author.lower().replace('ß', 'ss').split(' ') # TODO: better non-alphanumeric handling if len(parts) == 1: return parts[0] else: