Mercurial > piecrust2
comparison piecrust/formatting/markdownformatter.py @ 58:95590732e4c9
More robust Markdown configuration handling.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 26 Aug 2014 23:18:58 -0700 |
parents | c95c90c82263 |
children | fdb08d986384 |
comparison
equal
deleted
inserted
replaced
57:c8c522dacfea | 58:95590732e4c9 |
---|---|
16 | 16 |
17 def _ensureInitialized(self): | 17 def _ensureInitialized(self): |
18 if self._extensions is not None: | 18 if self._extensions is not None: |
19 return | 19 return |
20 | 20 |
21 extensions = self.app.config.get('markdown/extensions') | 21 config = self.app.config.get('markdown') |
22 if config is None: | |
23 config = {} | |
24 elif not isinstance(config, dict): | |
25 raise Exception("The `markdown` configuration setting must be " | |
26 "a dictionary.") | |
27 | |
28 extensions = config.get('extensions') | |
22 if extensions is None: | 29 if extensions is None: |
23 extensions = [] | 30 extensions = [] |
24 # Compatibility with PieCrust 1.x | 31 # Compatibility with PieCrust 1.x |
25 if self.app.config.get('markdown/use_markdown_extra'): | 32 if config.get('use_markdown_extra'): |
26 extensions.append('extra') | 33 extensions.append('extra') |
27 self._extensions = extensions | 34 self._extensions = extensions |
28 | 35 |