diff options
author | Daniele Forsi <daniele@forsi.it> | 2016-01-28 19:34:12 +0100 |
---|---|---|
committer | JensDiemer <git@jensdiemer.de> | 2020-01-19 10:05:26 +0100 |
commit | 06bd422b92401f2feb6b4b9fcdfd9d6246068513 (patch) | |
tree | e87e2e954342cbf1fca2751c7f795f2f5f90e4f7 /creole | |
parent | a4e7908f30a41f6bc9fbaf5f6b43d925701aa801 (diff) | |
download | creole-06bd422b92401f2feb6b4b9fcdfd9d6246068513.tar.gz |
Fix "Undefined substitution referenced" error
Add an empty line before "_substitution_data" if not already present.
Fixes issue #26.
Diffstat (limited to 'creole')
-rw-r--r-- | creole/emitter/html2rest_emitter.py | 2 | ||||
-rw-r--r-- | creole/tests/test_html2rest.py | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/creole/emitter/html2rest_emitter.py b/creole/emitter/html2rest_emitter.py index 41891fe..0e0b663 100644 --- a/creole/emitter/html2rest_emitter.py +++ b/creole/emitter/html2rest_emitter.py @@ -86,6 +86,8 @@ class ReStructuredTextEmitter(BaseEmitter): result = self.emit_children(node) if self._substitution_data: # add rest at the end + if not result.endswith("\n\n"): + result += "\n\n" result += "%s\n\n" % self._get_block_data() return result diff --git a/creole/tests/test_html2rest.py b/creole/tests/test_html2rest.py index eb7de66..29d197a 100644 --- a/creole/tests/test_html2rest.py +++ b/creole/tests/test_html2rest.py @@ -71,6 +71,18 @@ class ReStTests(BaseCreoleTest): """ ) + def test_substitution_image_without_p(self): + self.assert_html2rest( + rest_string=""" + |image.png| + + .. |image.png| image:: /url/to/image.png + """, + html_string=""" + <img src="/url/to/image.png" /> + """ + ) + def test_pre_code1(self): self.assert_html2rest( rest_string=""" |