diff --git a/tests/input/elements.xml b/tests/input/elements.xml
index c066b9de..7a302d32 100644
--- a/tests/input/elements.xml
+++ b/tests/input/elements.xml
@@ -181,7 +181,8 @@
Text and format="default": Sections
Person Names and
- Company Names of
+ Company Names and
+ a lot other information of
.
diff --git a/xml2rfc/writers/html.py b/xml2rfc/writers/html.py
index f9f9bff9..65f8c5d0 100644
--- a/xml2rfc/writers/html.py
+++ b/xml2rfc/writers/html.py
@@ -2888,7 +2888,9 @@ def render_xref(self, h, x):
label = 'Section' if section[0].isdigit() else 'Appendix' if re.search(r'^[A-Z](\.|$)', section) else 'Part'
link = x.get('derivedLink')
format = x.get('sectionFormat')
- exptext = ("%s " % x.text.strip()) if (x.text and x.text.strip()) else ''
+ exptext = f'{x.text.lstrip()}' if x.text else ''
+ expchildren = list(x.getchildren())
+ separator = ' ' if exptext != '' or len(expchildren) > 0 else ''
# 9.44.1. displayFormat='of'
#
# The output is an HTML tag, with contents of
@@ -2912,7 +2914,11 @@ def render_xref(self, h, x):
if format == 'of':
span = add.span(h, None,
build.a('%s %s'%(label, section), href=link, classes='relref'),
- ' of %s[' % exptext,
+ ' of ',
+ exptext,
+ *expchildren,
+ separator,
+ '[',
build.a(reftext, href='#%s'%target, classes='xref cite'),
']',
)
@@ -2939,7 +2945,10 @@ def render_xref(self, h, x):
# for an overview.
elif format == 'comma':
span = add.span(h, None,
- '%s[' % exptext,
+ exptext,
+ *expchildren,
+ separator,
+ '[',
build.a(reftext, href='#%s'%target, classes='xref cite'),
'], ',
build.a('%s %s'%(label, section), href=link, classes='relref'),
@@ -2974,7 +2983,10 @@ def render_xref(self, h, x):
# 2.3) for an overview.
elif format == 'parens':
span = add.span(h, None,
- '%s[' % exptext,
+ exptext,
+ *expchildren,
+ separator,
+ '[',
build.a(reftext, href='#%s'%target, classes='xref cite'),
'] (',
build.a('%s %s'%(label, section), href=link, classes='relref'),
@@ -3003,9 +3015,13 @@ def render_xref(self, h, x):
# 2.3 and ...
elif format == 'bare':
a = build.a(section, href=link, classes='relref')
- if x.text and x.text.strip() and x.text.strip() != section:
- aa = build.a(x.text, href=link, classes='relref')
- hh = build.span(a, ' (', aa, ')')
+ if content:
+ hh = build.span(
+ a,
+ ' (',
+ build.a(exptext, *expchildren, href=link, classes='relref'),
+ ')',
+ )
else:
hh = a
hh.tail = x.tail