1. Luke Plant
  2. sphinx

Commits

Roland Meister  committed a22a3e1

Moved href replacement of colons to hyphens to fix_fragment for the epub builder.

  • Participants
  • Parent commits 9f350c8
  • Branches default

Comments (0)

Files changed (1)

File sphinx/builders/epub.py

View file
  • Ignore whitespace
                 'text': ssp(self.esc(text))
             })
 
+    def fix_fragment(self, match):
+        """Return a href attribute with colons replaced by hyphens.
+        """
+        return match.group(1) + match.group(2).replace(':', '-')
+
     def fix_ids(self, tree):
         """Replace colons with hyphens in href and id attributes.
         Some readers crash because they interpret the part as a
             if 'refuri' in node:
                 m = _refuri_re.match(node['refuri'])
                 if m:
-                    node['refuri'] = m.group(1) + m.group(2).replace(':', '-')
+                    node['refuri'] = self.fix_fragment(m)
             if 'refid' in node:
                 node['refid'] = node['refid'].replace(':', '-')
         for node in tree.traverse(addnodes.desc_signature):
                 for (i, link) in enumerate(links):
                     m = _refuri_re.match(link)
                     if m:
-                        links[i] = m.group(1) + m.group(2).replace(':', '-')
+                        links[i] = self.fix_fragment(m)
                 for subentryname, subentrylinks in subitems:
                     for (i, link) in enumerate(subentrylinks):
                         m = _refuri_re.match(link)
                         if m:
-                            subentrylinks[i] = \
-                                    m.group(1) + m.group(2).replace(':', '-')
+                            subentrylinks[i] = self.fix_fragment(m)
 
     def handle_page(self, pagename, addctx, templatename='page.html',
                     outfilename=None, event_arg=None):