-
Notifications
You must be signed in to change notification settings - Fork 12
/
linkify.rbl
14 lines (14 loc) · 4.3 KB
/
linkify.rbl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="UTF-8"?>
<rxb:regexbuddy xmlns:rxb="http://www.regexbuddy.com/regexbuddy32.xsd" version="3.2">
<libraryfile>
<action id="_0900_section_html_pattern" caseless="1" freespacing="1" flavor="pcre" flavorreplace="jgsoft">
<regex># Rev:20100913_0900 github.com/jmrware/LinkifyURL # Section text into HTML <A> tags and everything else. ( # $1: Everything not HTML <A> tag. [^<]+(?:(?!<a\b)<[^<]*)* # non A tag stuff starting with non-"<". | (?:(?!<a\b)<[^<]*)+ # non A tag stuff starting with "<". ) # End $1. | ( # $2: HTML <A...>...</A> tag. <a\b[^>]*> # <A...> opening tag. [^<]*(?:(?!</a\b)<[^<]*)* # A tag contents. </a\s*> # </A> closing tag. ) # End $2: </regex>
<description>20100913_0900_section_html_pattern</description>
</action>
<action id="_0900_url_pattern" kind="replace" caseless="1" multiline="1" freespacing="1" flavor="pcre" flavorreplace="jgsoft">
<regex># Rev:20100913_0900 github.com/jmrware/LinkifyURL # Match http & ftp URL that is not already linkified. # Alternative 1: URL delimited by (parentheses). (\() # $1 "(" start delimiter. ((?:ht|f)tps?://[a-z0-9\-._~!$&'()*+,;=:/?#[\]@%]+) # $2: URL. (\)) # $3: ")" end delimiter. | # Alternative 2: URL delimited by [square brackets]. (\[) # $4: "[" start delimiter. ((?:ht|f)tps?://[a-z0-9\-._~!$&'()*+,;=:/?#[\]@%]+) # $5: URL. (\]) # $6: "]" end delimiter. | # Alternative 3: URL delimited by {curly braces}. (\{) # $7: "{" start delimiter. ((?:ht|f)tps?://[a-z0-9\-._~!$&'()*+,;=:/?#[\]@%]+) # $8: URL. (\}) # $9: "}" end delimiter. | # Alternative 4: URL delimited by <angle brackets>. (<|&(?:lt|\#60|\#x3c);) # $10: "<" start delimiter (or HTML entity). ((?:ht|f)tps?://[a-z0-9\-._~!$&'()*+,;=:/?#[\]@%]+) # $11: URL. (>|&(?:gt|\#62|\#x3e);) # $12: ">" end delimiter (or HTML entity). | # Alternative 5: URL not delimited by (), [], {} or <>. ( # $13: Prefix proving URL not already linked. (?: ^ # Can be a beginning of line or string, or | [^=\s'"\]] # a non-"=", non-quote, non-"]", followed by ) \s*['"]? # optional whitespace and optional quote; | [^=\s]\s+ # or... a non-equals sign followed by whitespace. ) # End $13. Non-prelinkified-proof prefix. ( \b # $14: Other non-delimited URL. (?:ht|f)tps?:// # Required literal http, https, ftp or ftps prefix. [a-z0-9\-._~!$'()*+,;=:/?#[\]@%]+ # All URI chars except "&" (normal*). (?: # Either on a "&" or at the end of URI. (?! # Allow a "&" char only if not start of an... &(?:gt|\#0*62|\#x0*3e); # HTML ">" entity, or | &(?:amp|apos|quot|\#0*3[49]|\#x0*2[27]); # a [&'"] entity if [.!&',:?;]? # followed by optional punctuation then (?:[^a-z0-9\-._~!$&'()*+,;=:/?#[\]@%]|$) # a non-URI char or EOS. ) & # If neg-assertion true, match "&" (special). [a-z0-9\-._~!$'()*+,;=:/?#[\]@%]* # More non-& URI chars (normal*). )* # Unroll-the-loop (special normal*)*. [a-z0-9\-_~$()*+=/#[\]@%] # Last char can't be [.!&',;:?] ) # End $14. Other non-delimited URL. </regex>
<replace>$1$4$7$10$13<a href="$2$5$8$11$14">LINK</a>$3$6$9$12</replace>
<description>20100913_0900_url_pattern</description>
</action>
</libraryfile>
</rxb:regexbuddy>