From 7d3643951ebd973eb5f39b5cd8af8da8079d8372 Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Fri, 8 Sep 2023 11:12:15 +1200 Subject: [PATCH] fix: Render xref in name element similar to everywhere else When `xref` is in `title`, if `xref` has a target to a `reference` use square brackets (`[ ]`). If the `xref` target is not a reference don't use brackets or parenthesis. If `xref` element has text content: For `reference` targets: ` []` For other targets: ` ()` --- xml2rfc/writers/html.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xml2rfc/writers/html.py b/xml2rfc/writers/html.py index 6b2d911b..d98a992d 100644 --- a/xml2rfc/writers/html.py +++ b/xml2rfc/writers/html.py @@ -2847,8 +2847,16 @@ def render_xref(self, h, x): if format == 'none': reftext = content hh = build.span(reftext, classes='xref cite') + elif target in self.refname_mapping and format != 'title': + if content: + hh = build.span(content, ' ', '[', reftext, ']', classes='xref cite') + else: + hh = build.span('[', reftext, ']', classes='xref cite') else: - hh = build.span('[', reftext, ']', classes='xref cite') + if content: + hh = build.span(content, ' ', '(', reftext, ')', classes='xref cite') + else: + hh = build.span(reftext, classes='xref cite') else: srefclass = 'xref internal' if not content and format != 'title':