Skip to content

Commit e2b09e9

Browse files
committedDec 28, 2015
Add file name to shortcode errors
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent cb86619 commit e2b09e9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed
 

‎nikola/nikola.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1316,9 +1316,9 @@ def register_shortcode(self, name, f):
13161316
return
13171317
self.shortcode_registry[name] = f
13181318

1319-
def apply_shortcodes(self, data):
1319+
def apply_shortcodes(self, data, filename=None):
13201320
"""Apply shortcodes from the registry on data."""
1321-
return shortcodes.apply_shortcodes(data, self.shortcode_registry)
1321+
return shortcodes.apply_shortcodes(data, self.shortcode_registry, self, filename)
13221322

13231323
def generic_rss_renderer(self, lang, title, link, description, timeline, output_path,
13241324
rss_teasers, rss_plain, feed_length=10, feed_url=None,

‎nikola/plugins/compile/markdown/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def compile_html(self, source, dest, is_two_file=True):
7676
if not is_two_file:
7777
_, data = self.split_metadata(data)
7878
output = markdown(data, self.extensions)
79-
output = apply_shortcodes(output, self.site.shortcode_registry, self.site)
79+
output = apply_shortcodes(output, self.site.shortcode_registry, self.site, source)
8080
out_file.write(output)
8181

8282
def create_post(self, path, **kw):

‎nikola/shortcodes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def _split_shortcodes(data):
245245
return result
246246

247247

248-
def apply_shortcodes(data, registry, site=None):
248+
def apply_shortcodes(data, registry, site=None, filename=None):
249249
"""Apply Hugo-style shortcodes on data.
250250
251251
{{% 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):
303303
result.append(res)
304304
return empty_string.join(result)
305305
except ParsingError as e:
306-
LOGGER.error("{0}".format(e))
306+
LOGGER.error("Shortcode error in file {0}: {1}".format(filename, e))
307307
sys.exit(1)

0 commit comments

Comments
 (0)
Failed to load comments.