| 228 | self.doc.write(text) |
| 229 | |
| 230 | def end_a(self): |
| 231 | self.doc.do_translation = False |
| 232 | if self.a_href: |
| 233 | last_write = self.doc.pop_write() |
| 234 | last_write = last_write.rstrip(' ') |
| 235 | if last_write and last_write != '`': |
| 236 | if ':' in last_write: |
| 237 | last_write = last_write.replace(':', r'\:') |
| 238 | self.doc.push_write(last_write) |
| 239 | self.doc.push_write(' <%s>`__' % self.a_href) |
| 240 | elif last_write == '`': |
| 241 | # Look at start_a(). It will do a self.doc.write('`') |
| 242 | # which is the start of the link title. If that is the |
| 243 | # case then there was no link text. We should just |
| 244 | # use an inline link. The syntax of this is |
| 245 | # `<http://url>`_ |
| 246 | self.doc.push_write('`<%s>`__' % self.a_href) |
| 247 | else: |
| 248 | self.doc.push_write(self.a_href) |
| 249 | self.doc.hrefs[self.a_href] = self.a_href |
| 250 | self.doc.write('`__') |
| 251 | self.a_href = None |
| 252 | self.doc.write(' ') |
| 253 | |
| 254 | def start_i(self, attrs=None): |
| 255 | self.doc.do_translation = True |