diff --git a/PyTeX/build/build/builder.py b/PyTeX/build/build/builder.py index 29098fb..3d7f1a5 100644 --- a/PyTeX/build/build/builder.py +++ b/PyTeX/build/build/builder.py @@ -159,13 +159,20 @@ class PyTeXBuilder: files = self.source_root.glob('*') for file in files: if self.is_supported_file(file.name): + config = self.pytex_config.sub_config( + file.name.split('.', 1)[0] + ) + config.merge_with( + self.pytex_config.default_formatting_config, + strict=False + ) self._pytex_files.append( PyTeXSourceFile( relative_path=RelativePath( self.source_root, file ), - default_config=self.pytex_config.default_formatting_config, + default_config=config, git_version_info=self._git_version_info, target=self._build_target_type.to_target() ) diff --git a/PyTeX/build/build/pytex_config.py b/PyTeX/build/build/pytex_config.py index 45f4a77..d7a9aab 100644 --- a/PyTeX/build/build/pytex_config.py +++ b/PyTeX/build/build/pytex_config.py @@ -96,3 +96,17 @@ class PyTeXConfig(Config): return FormattingConfig() else: return self._default_formatting_config + + @property + def sub_configs(self) -> Dict: + if self._configs is None: + return {} + else: + return self._configs + + def sub_config(self, name: str) -> FormattingConfig: + if name in self.sub_configs.keys(): + return FormattingConfig.from_json(self.sub_configs[name]) + else: + return FormattingConfig() + diff --git a/PyTeX/format/config.py b/PyTeX/format/config.py index 5965dd5..73de7ca 100644 --- a/PyTeX/format/config.py +++ b/PyTeX/format/config.py @@ -58,7 +58,8 @@ def clean_dict(dictionary: Dict) -> Optional[Dict]: class Config: def merge_with(self, other: Config, strict: bool = False): """ - Merges the other config into this one + Merges the other config into this one. + In conflicts, the called-on instance takes effect :param other: :param strict: whether conflicting options are allowed or not :return: self diff --git a/main.py b/main.py index be32c32..7ae2437 100644 --- a/main.py +++ b/main.py @@ -25,7 +25,7 @@ builder = PyTeXBuilder(conf_path) builder.build_tex_sources() -builder.build_tex_files() +# builder.build_tex_files() pass