Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Extend RFC regex to support multiple subsections #282

Merged
merged 1 commit into from
Jul 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions gddo-server/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func importPathFn(path string) htemp.HTML {

var (
h3Pat = regexp.MustCompile(`<h3 id="([^"]+)">([^<]+)</h3>`)
rfcPat = regexp.MustCompile(`RFC\s+(\d{3,4})((,|)\s+[Ss]ection\s+(\d+)((\.\d+|)|)|)`)
rfcPat = regexp.MustCompile(`RFC\s+(\d{3,4})(,?\s+[Ss]ection\s+(\d+(\.\d+)*))?`)
packagePat = regexp.MustCompile(`\s+package\s+([-a-z0-9]\S+)`)
)

Expand Down Expand Up @@ -310,15 +310,10 @@ func commentFn(v string) htemp.HTML {
out = append(out, `<a href="http://tools.ietf.org/html/rfc`...)
out = append(out, src[m[2]:m[3]]...)

// If available, add major section fragment
if m[6] != -1 {
// If available, add section fragment
if m[4] != -1 {
out = append(out, `#section-`...)
out = append(out, src[m[8]:m[9]]...)

// If available, add minor section fragment
if m[13] != -1 {
out = append(out, src[m[12]:m[13]]...)
}
out = append(out, src[m[6]:m[7]]...)
}

out = append(out, `">`...)
Expand Down