i18n/hggettext
changeset 33817 726dd73df3b9
parent 33815 97ee669f1f6d
child 33818 ed04d7254a91
--- a/i18n/hggettext	Wed Aug 02 01:15:07 2017 +0900
+++ b/i18n/hggettext	Sun Aug 13 15:20:16 2017 +0900
@@ -24,6 +24,7 @@
 
 import inspect
 import os
+import re
 import sys
 
 
@@ -60,9 +61,15 @@
             'msgid %s\n' % normalize(s) +
             'msgstr ""\n')
 
+doctestre = re.compile(r'^ +>>> ', re.MULTILINE)
 
 def offset(src, doc, name, default):
     """Compute offset or issue a warning on stdout."""
+    # remove doctest part, in order to avoid backslash mismatching
+    m = doctestre.search(doc)
+    if m:
+        doc = doc[:m.start()]
+
     # Backslashes in doc appear doubled in src.
     end = src.find(doc.replace('\\', '\\\\'))
     if end == -1: