Meera Ghumalia avatar Meera Ghumalia committed 7bd2ee2

Split long URLs gracefully at specific points

Comments (0)

Files changed (1)

sphinx/writers/latex.py

         raise nodes.SkipNode
 
     def visit_reference(self, node):
+#M+
+        self.visiting_reference = True
+#M-
         uri = node.get('refuri', '')
         if not uri and node.get('refid'):
             uri = '%' + self.curfilestack[-1] + '#' + node['refid']
 
 #M+
     def escape_uri(self, text):
-        # allow to break the hyper link
-        return self.encode_uri(text).replace('/', '/\\-').replace('&', '&\\-').replace('\\textbackslash{}\\', '\\')
+        # URL for humans and printable pages. Allow URL to break gracefully at specific points
+        return self.encode_uri(text)\
+            .replace('/', '/\\-')\
+            .replace('&', '&\\-')\
+            .replace('+', '+\\-')\
+            .replace('\\textbackslash{}\\', '\\')\
+            .replace('~', '\\textasciitilde{}')
 #M-
 
     def visit_Text(self, node):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.