Skip to content
Permalink
Browse files

Add file name to shortcode errors

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 28, 2015
1 parent cb86619 commit e2b09e91e344174033cd8b03585e93b050df30b2
Showing with 5 additions and 5 deletions.
  1. +2 −2 nikola/nikola.py
  2. +1 −1 nikola/plugins/compile/markdown/__init__.py
  3. +2 −2 nikola/shortcodes.py
@@ -1316,9 +1316,9 @@ def register_shortcode(self, name, f):
return
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, self.site.shortcode_registry, self.site)
output = apply_shortcodes(output, self.site.shortcode_registry, self.site, source)
out_file.write(output)

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):
result.append(res)
return empty_string.join(result)
except ParsingError as e:
LOGGER.error("{0}".format(e))
LOGGER.error("Shortcode error in file {0}: {1}".format(filename, e))

This comment has been minimized.

Copy link
@felixfontein

felixfontein Dec 28, 2015

Contributor

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

Kwpolska Dec 28, 2015

Author Member

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

sys.exit(1)

0 comments on commit e2b09e9

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