From a2c006d745e80674a39d7b034e8b18e131493010 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Tue, 26 May 2009 22:51:29 -0300 Subject: [PATCH] =?utf8?q?Agregar=20m=C3=A1s=20tipos=20de=20referencia=20a?= =?utf8?q?=20la=20extensi=C3=B3n=20vref?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Agregar el rol "r" equivalente a \ref y "vrefr" equivalente a \vref. --- ext/vref.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/ext/vref.py b/ext/vref.py index 564e000..5245a30 100644 --- a/ext/vref.py +++ b/ext/vref.py @@ -1,7 +1,19 @@ - from docutils import nodes, utils + +class r(nodes.Inline, nodes.TextElement): + pass + +def r_role(role, rawtext, text, lineno, inliner, options={}, content=[]): + latex = utils.unescape(text, restore_backslashes=True) + return [r(latex=latex)], [] + +def latex_visit_r(self, node): + self.body.append(r'\ref{' + node['latex'] + '}') + raise nodes.SkipNode + + class vref(nodes.Inline, nodes.TextElement): pass @@ -13,7 +25,25 @@ def latex_visit_vref(self, node): self.body.append(r'\vref{' + node['latex'] + '}') raise nodes.SkipNode + +class vrefr(nodes.Inline, nodes.TextElement): + pass + +def vrefr_role(role, rawtext, text, lineno, inliner, options={}, content=[]): + latex = utils.unescape(text, restore_backslashes=True) + return [vrefr(latex=latex)], [] + +def latex_visit_vrefr(self, node): + range = tuple(node['latex'].split(',', 1)) + self.body.append(r'\vrefrange{%s}{%s}' % range) + raise nodes.SkipNode + + def setup(app): + app.add_node(r, latex=(latex_visit_r, None)) app.add_node(vref, latex=(latex_visit_vref, None)) + app.add_node(vrefr, latex=(latex_visit_vrefr, None)) + app.add_role('r', r_role) app.add_role('vref', vref_role) + app.add_role('vrefr', vrefr_role) -- 2.43.0