Skip to content

Commit

Permalink
Merge pull request #2799 from getnikola/fix-2798
Browse files Browse the repository at this point in the history
Fix 2798
  • Loading branch information
Kwpolska committed May 25, 2017
2 parents 47db894 + 5ab12ac commit 001fdc2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* Guess file format from file name on new_post (Issue #2798)
* Use BaguetteBox as lightbox in base theme (Issue #2777)
* New ``deduplicate_ids``, for preventing duplication of HTML id
attributes (Issue #2570)
Expand Down
21 changes: 19 additions & 2 deletions nikola/plugins/command/new_post.py
Expand Up @@ -265,16 +265,33 @@ def _execute(self, options, args):
if "@" in content_format:
content_format, content_subformat = content_format.split("@")

if not content_format: # Issue #400
if not content_format and path:
# content_format not specified. If path was given, use
# it to guess (Issue #2798)
extension = os.path.splitext(path)[-1]
for compiler, extensions in self.site.config['COMPILERS'].items():
if extension in extensions:
content_format = compiler

elif not content_format and import_file:
# content_format not specified. If import_file was given, use
# it to guess (Issue #2798)
extension = os.path.splitext(import_file)[-1]
for compiler, extensions in self.site.config['COMPILERS'].items():
if extension in extensions:
content_format = compiler

elif not content_format: # Issue #400
content_format = get_default_compiler(
is_post,
self.site.config['COMPILERS'],
self.site.config['post_pages'])

if content_format not in compiler_names:
elif content_format not in compiler_names:
LOGGER.error("Unknown {0} format {1}, maybe you need to install a plugin or enable an existing one?".format(content_type, content_format))
self.print_compilers()
return

compiler_plugin = self.site.plugin_manager.getPluginByName(
content_format, "PageCompiler").plugin_object

Expand Down

0 comments on commit 001fdc2

Please sign in to comment.