Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Try 2.
  • Loading branch information
felixfontein committed Dec 28, 2015
1 parent e19120a commit d109043
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nikola/shortcodes.py
Expand Up @@ -258,6 +258,7 @@ def apply_shortcodes(data, registry, site=None):
>>> apply_shortcodes('==> {{% foo bar=baz %}}some data{{% /foo %}} <==', {'foo': lambda *a, **k: k['bar']+k['data']})
'==> bazsome data <=='
"""
empty_string = data[:0] # same string type as data; to make Python 2 happy
try:
# Split input data into text, shortcodes and shortcode endings
sc_data = _split_shortcodes(data)
Expand All @@ -284,7 +285,7 @@ def apply_shortcodes(data, registry, site=None):
data_arg = []
for p in range(pos + 1, found):
data_arg.append(sc_data[p][1])
data_arg = u''.join(data_arg)
data_arg = empty_string.join(data_arg)
pos = found + 1
else:
# Single shortcode
Expand All @@ -299,7 +300,7 @@ def apply_shortcodes(data, registry, site=None):
LOGGER.error('Unknown shortcode {0} (started at {1})', name, _format_position(data, current[2]))
res = ''
result.append(res)
return u''.join(result)
return empty_string.join(result)
except ParsingError as e:
LOGGER.error("{0}".format(e))
sys.exit(1)

0 comments on commit d109043

Please sign in to comment.