From fc90be29123a51ea02feeedeecd3e8d821ffd7f2 Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Thu, 2 Feb 2023 21:30:58 +1300 Subject: [PATCH] fix: Include figure prefix in name before rendering text Fixes #961 --- xml2rfc/writers/text.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xml2rfc/writers/text.py b/xml2rfc/writers/text.py index dc802bca..a5db6b69 100644 --- a/xml2rfc/writers/text.py +++ b/xml2rfc/writers/text.py @@ -1737,11 +1737,20 @@ def render_figure(self, e, width, **kwargs): pn = e.get('pn') num = pn.split('-')[1].capitalize() children = e.getchildren() - title = "Figure %s" % (num, ) + title = "Figure {}".format(num) if len(children) and children[0].tag == 'name': name = children[0] + if name.text: + name.text = "{prefix}{joiner} {text}".format( + prefix=title, + joiner=kwargs["joiners"]["name"].join, + text=name.text) + else: + name.text = "{prefix}{joiner} ".format( + prefix=title, + joiner=kwargs["joiners"]["name"].join) children = children[1:] - title = self.tjoin(title, name, width, **kwargs) + title = self.render(name, width, **kwargs) lines = [] for c in children: lines = self.ljoin(lines, c, width, **kwargs)