Skip to content

Commit

Permalink
Added back the ability to place <iref> elements in locations where th…
Browse files Browse the repository at this point in the history
…ey will translate to invalid HTML. Avoided invalid HTML by pushing the span up one level, as a previous sibling, when needed. Fixes issue #378.

 - Legacy-Id: 2750
  • Loading branch information
levkowetz committed Nov 17, 2018
1 parent 38a7ec2 commit ecb73cb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/tests/input/draft-v3-features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ foo = bar
<name>Tables</name>
<section>
<name>Bare Table (unnamed, no anchor, with iref)</name>
<iref item="Bare Table"/>
<table>
<iref item="Bare Table"/>
<thead>
<tr>
<th>Column 1</th>
Expand Down
1 change: 1 addition & 0 deletions cli/xml2rfc/data/v3.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@
attribute anchor { xsd:ID }?,
attribute pn { xsd:ID }?,
name?,
iref*,
thead?,
tbody+,
tfoot?
Expand Down
3 changes: 3 additions & 0 deletions cli/xml2rfc/data/v3.rng
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,9 @@
<optional>
<ref name="name"/>
</optional>
<zeroOrMore>
<ref name="iref"/>
</zeroOrMore>
<optional>
<ref name="thead"/>
</optional>
Expand Down
7 changes: 6 additions & 1 deletion cli/xml2rfc/writers/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,12 @@ def entry(dl, name, value):
#
# <span class="iref" id="s-Paragraphs-first-1"/>
def render_iref(self, h, x):
return add.span(h, x, classes='iref', id=x.get('pn'))
span = build.span(classes='iref', id=x.get('pn'))
if h.tag in ['table', ]:
h.addprevious(span)
else:
h.append(span)
return span

# 9.28. <keyword>
#
Expand Down

0 comments on commit ecb73cb

Please sign in to comment.