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

Extend RFC regex to support multiple subsections #282

merged 1 commit into from
Jul 16, 2015

Conversation

mdlayher
Copy link
Member

My previous regex did not create links when multiple subsections were present, e.g. "RFC 4291, Section 2.5.1", as shown here (notice the trailing '1' is not highlighted):

selection064

This cleans up and extends the regex to support zero or more subsections, as shown after the patch:

selection063

Here is example output from this patch:

[zsh|matt@nerr-2]:~/go/tmp 0 % go run main.go 
2015/06/29 14:39:16 in: 
// foo
// RFC foo
// RFC 4291
// RFC 4291 section 1
// RFC 4291 section 10000
// RFC 4291, Section 2
// RFC 4291, Section 2.5
// RFC 4291, Section 2.5.1
// RFC 4291, Section 2.5.1.1.1.1

out: <p>
// foo
// RFC foo
// <a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>
// <a href="http://tools.ietf.org/html/rfc4291#section-1">RFC 4291 section 1</a>
// <a href="http://tools.ietf.org/html/rfc4291#section-10000">RFC 4291 section 10000</a>
// <a href="http://tools.ietf.org/html/rfc4291#section-2">RFC 4291, Section 2</a>
// <a href="http://tools.ietf.org/html/rfc4291#section-2.5">RFC 4291, Section 2.5</a>
// <a href="http://tools.ietf.org/html/rfc4291#section-2.5.1">RFC 4291, Section 2.5.1</a>
// <a href="http://tools.ietf.org/html/rfc4291#section-2.5.1.1.1.1">RFC 4291, Section 2.5.1.1.1.1</a>
</p>

@mdlayher
Copy link
Member Author

/cc @adg

@mdlayher
Copy link
Member Author

Hi @adg , any thoughts?

@adg
Copy link
Contributor

adg commented Jul 16, 2015

Sure, why not.

adg added a commit that referenced this pull request Jul 16, 2015
Extend RFC regex to support multiple subsections
@adg adg merged commit eb1f515 into golang:master Jul 16, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants