Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Only put number in rfc tag when its an actual number. Drop anchor
attribute in notes (special headers), because it is not supported by RFC
7991.

Signed-off-by: Miek Gieben <[email protected]>
  • Loading branch information
miekg committed Sep 18, 2018
1 parent f40eb8d commit f4e1286
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 6 additions & 3 deletions xml/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@ func (r *Renderer) headingEnter(w io.Writer, heading *ast.Heading) {
tag := "<section"

mast.AttributeInit(heading)
if mast.Attribute(heading, "id") == nil && heading.HeadingID != "" {
id := r.ensureUniqueHeadingID(heading.HeadingID)
mast.SetAttribute(heading, "id", []byte(id))
// In XML2 output we can't have an anchor attribute on a note.
if !heading.IsSpecial {
if mast.Attribute(heading, "id") == nil && heading.HeadingID != "" {
id := r.ensureUniqueHeadingID(heading.HeadingID)
mast.SetAttribute(heading, "id", []byte(id))
}
}

if heading.IsSpecial {
Expand Down
11 changes: 7 additions & 4 deletions xml/title.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ func (r *Renderer) titleBlock(w io.Writer, t *mast.Title) {
[]string{IntSliceToString(d.Updates), IntSliceToString(d.Obsoletes)},
)...)
// number is deprecated, but xml2rfc want's it here to generate an actual RFC.
attrs = append(attrs, Attributes(
[]string{"number"},
[]string{t.SeriesInfo.Value},
)...)
// But only if number is a integer (what a mess).
if _, err := strconv.Atoi(t.SeriesInfo.Value); err == nil {
attrs = append(attrs, Attributes(
[]string{"number"},
[]string{t.SeriesInfo.Value},
)...)
}
r.outTag(w, "<rfc", attrs)
r.cr(w)

Expand Down

0 comments on commit f4e1286

Please sign in to comment.