Skip to content

Commit

Permalink
fix: Include figure prefix in name before rendering text
Browse files Browse the repository at this point in the history
  • Loading branch information
kesara committed Feb 2, 2023
1 parent ac0b90d commit ca58f21
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/valid/draft-miek-test.pages.text
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,8 @@ A.10. Figure tests
This is a figure
This is a figure

Figure 4: This is the caption, with text in `typewriter`. Which
isnt converted to a <spanx> style, because this is copied as-is.
Figure 4: This is the caption, with text in `typewriter`. Which isnt
converted to a <spanx> style, because this is copied as-is.

And how a figure that is not centered, do to using figure and not
Figure.
Expand Down
4 changes: 2 additions & 2 deletions tests/valid/draft-miek-test.text
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,8 @@ A.10. Figure tests
This is a figure
This is a figure

Figure 4: This is the caption, with text in `typewriter`. Which
isnt converted to a <spanx> style, because this is copied as-is.
Figure 4: This is the caption, with text in `typewriter`. Which isnt
converted to a <spanx> style, because this is copied as-is.

And how a figure that is not centered, do to using figure and not
Figure.
Expand Down
4 changes: 2 additions & 2 deletions tests/valid/draft-miek-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,8 @@ A.10. Figure tests
This is a figure
This is a figure

Figure 4: This is the caption, with text in `typewriter`. Which
isnt converted to a <spanx> style, because this is copied as-is.
Figure 4: This is the caption, with text in `typewriter`. Which isnt
converted to a <spanx> style, because this is copied as-is.

And how a figure that is not centered, do to using figure and not
Figure.
Expand Down
13 changes: 11 additions & 2 deletions xml2rfc/writers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1736,11 +1736,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)
Expand Down

0 comments on commit ca58f21

Please sign in to comment.