Skip to content
Permalink
Browse files

Guess format from path on new_post (Issue #2798)

  • Loading branch information
ralsina committed May 25, 2017
1 parent b8808c2 commit 274cf88dde014bbca506fa42a0eab816689a0404
Showing with 11 additions and 2 deletions.
  1. +11 −2 nikola/plugins/command/new_post.py
@@ -265,16 +265,25 @@ 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: # 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

0 comments on commit 274cf88

Please sign in to comment.
You can’t perform that action at this time.