--- /dev/null
+from . import parse_link
+from docutils import nodes
+from docutils.parsers import rst
+
+def abbr(name, rawtext, text, lineno, inliner, options={}, content=[]):
+ abbr, title = parse_link(text)
+ if not title:
+ return [nodes.abbreviation(abbr, abbr)], []
+ return [nodes.abbreviation(abbr, abbr, title=title)], []
+
+def register():
+ rst.roles.register_local_role('abbr', abbr)
self.docinfo = self.body[start:]
self.body = []
+ # Have <abbr> properly with title
+ def visit_abbreviation(self, node):
+ attrs = {}
+ if node.hasattr('title'):
+ attrs['title'] = node['title']
+ self.body.append(self.starttag(node, 'abbr', '', **attrs))
+
+ def depart_abbreviation(self, node):
+ self.body.append('</abbr>')
+
# Remove useless cruft from images, such as width, height, scale; don't put
# URI in alt text.
def visit_image(self, node):