diff --git a/pynliner/__init__.py b/pynliner/__init__.py index 873d0a8..c1d2311 100644 --- a/pynliner/__init__.py +++ b/pynliner/__init__.py @@ -170,11 +170,12 @@ def _unsubstitute_output(self): """ Put substitutions back into the output """ - self.output = re.sub( - SUBSTITUTION_PATTERN, - lambda m: self._substitutions[int(m.group(1))], - self.output - ) + if self._substitutions: + self.output = re.sub( + SUBSTITUTION_PATTERN, + lambda m: self._substitutions[int(m.group(1))], + self.output + ) def _get_soup(self): """Convert source string to BeautifulSoup object. Sets it to self.soup.