Skip to content
Browse files
Add file name to shortcode errors
Signed-off-by: Chris Warrick <>
  • Loading branch information
Kwpolska committed Dec 28, 2015
1 parent cb86619 commit e2b09e91e344174033cd8b03585e93b050df30b2
Showing with 5 additions and 5 deletions.
  1. +2 −2 nikola/
  2. +1 −1 nikola/plugins/compile/markdown/
  3. +2 −2 nikola/
@@ -1316,9 +1316,9 @@ def register_shortcode(self, name, f):
self.shortcode_registry[name] = f

def apply_shortcodes(self, data):
def apply_shortcodes(self, data, filename=None):
"""Apply shortcodes from the registry on data."""
return shortcodes.apply_shortcodes(data, self.shortcode_registry)
return shortcodes.apply_shortcodes(data, self.shortcode_registry, self, filename)

def generic_rss_renderer(self, lang, title, link, description, timeline, output_path,
rss_teasers, rss_plain, feed_length=10, feed_url=None,
@@ -76,7 +76,7 @@ def compile_html(self, source, dest, is_two_file=True):
if not is_two_file:
_, data = self.split_metadata(data)
output = markdown(data, self.extensions)
output = apply_shortcodes(output,,
output = apply_shortcodes(output,,, source)

def create_post(self, path, **kw):
@@ -245,7 +245,7 @@ def _split_shortcodes(data):
return result

def apply_shortcodes(data, registry, site=None):
def apply_shortcodes(data, registry, site=None, filename=None):
"""Apply Hugo-style shortcodes on data.
{{% name parameters %}} will end up calling the registered "name" function with the given parameters.
@@ -303,5 +303,5 @@ def apply_shortcodes(data, registry, site=None):
return empty_string.join(result)
except ParsingError as e:
LOGGER.error("Shortcode error in file {0}: {1}".format(filename, e))

This comment has been minimized.

Copy link

felixfontein Dec 28, 2015


How about also making sure the error message sounds good when filename is None? After all, filename is optional.

This comment has been minimized.

Copy link

Kwpolska Dec 28, 2015

Author Member

Fixed in f8cccda. (note that filename is likely not to be empty in most cases)


0 comments on commit e2b09e9

Please sign in to comment.