diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 49f3a2125..c2b7edf4d 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -193,3 +193,10 @@ def _new_contains(self, key): return key in self.children nodes.Node.__contains__ = _new_contains + +# monkey-patch Element.copy to copy the rawsource + +def _new_copy(self): + return self.__class__(self.rawsource, **self.attributes) + +nodes.Element.copy = _new_copy diff --git a/tests/test_markup.py b/tests/test_markup.py index 5d56bea30..4c8e7264f 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -127,9 +127,9 @@ def test_latex_escaping(): yield (verify, u'Γ\\\\∞$', None, ur'\(\Gamma\)\textbackslash{}\(\infty\)\$') # in verbatim code fragments - yield (verify, u'::\n\n @Γ\\∞$[]', None, - u'\\begin{Verbatim}[commandchars=@\\[\\]]\n' - u'@PYGZat[]@(@Gamma@)\\@(@infty@)@$@PYGZlb[]@PYGZrb[]\n' + yield (verify, u'::\n\n @Γ\\∞${}', None, + u'\\begin{Verbatim}[commandchars=\\\\\\{\\}]\n' + u'@\\(\\Gamma\\)\\PYGZbs{}\\(\\infty\\)\\$\\PYGZob{}\\PYGZcb{}\n' u'\\end{Verbatim}') # in URIs yield (verify_re, u'`test `_', None,