Skip to content

Commit 7527cc8

Browse files
brsonShaquille Johnson
authored andcommitted
[CREATE-1256] Enable autolinking (kivikakk#67)
1 parent 9cbe68c commit 7527cc8

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

specs/rtjson/bugs.spec

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ This should be used with rtjson.
88
```````````````````````````````` example
99
nonoe www.reddit.com /r/or r/or either/or
1010
.
11-
{"document":[{"c":[{"e":"text","t":"nonoe www.reddit.com "},{"e":"r/","l":true,"t":"or"},{"e":"text","t":" "},{"e":"r/","t":"or"},{"e":"text","t":" either/or"}],"e":"par"}]}````````````````````````````````
11+
{"document":[{"c":[{"e":"text","t":"nonoe "},{"e":"link","t":"www.reddit.com","u":"http://www.reddit.com"},{"e":"text","t":" "},{"e":"r/","l":true,"t":"or"},{"e":"text","t":" "},{"e":"r/","t":"or"},{"e":"text","t":" either/or"}],"e":"par"}]}````````````````````````````````
1212

1313
We also need to check links at the beginning
1414

1515
```````````````````````````````` example
1616
www.reddit.com nonoe /r/or r/or either/or
1717
.
18-
{"document":[{"c":[{"e":"text","t":"www.reddit.com nonoe "},{"e":"r/","l":true,"t":"or"},{"e":"text","t":" "},{"e":"r/","t":"or"},{"e":"text","t":" either/or"}],"e":"par"}]}````````````````````````````````
18+
{"document":[{"c":[{"e":"link","t":"www.reddit.com","u":"http://www.reddit.com"},{"e":"text","t":" nonoe "},{"e":"r/","l":true,"t":"or"},{"e":"text","t":" "},{"e":"r/","t":"or"},{"e":"text","t":" either/or"}],"e":"par"}]}````````````````````````````````
1919

2020
...and end of lines.
2121

2222
```````````````````````````````` example
2323
nonoe /r/or r/or either/or www.reddit.com
2424
.
25-
{"document":[{"c":[{"e":"text","t":"nonoe "},{"e":"r/","l":true,"t":"or"},{"e":"text","t":" "},{"e":"r/","t":"or"},{"e":"text","t":" either/or www.reddit.com"}],"e":"par"}]}````````````````````````````````
25+
{"document":[{"c":[{"e":"text","t":"nonoe "},{"e":"r/","l":true,"t":"or"},{"e":"text","t":" "},{"e":"r/","t":"or"},{"e":"text","t":" either/or "},{"e":"link","t":"www.reddit.com","u":"http://www.reddit.com"}],"e":"par"}]}````````````````````````````````
2626

2727
We should also make sure that user redditlinks are being covered
2828

@@ -194,3 +194,40 @@ Test pathological input
194194
a*a*a*a*a*a*a*a*a*a*
195195
.
196196
{"document":[{"c":[{"e":"text","f":[[2,1,1],[2,3,1],[2,5,1],[2,7,1],[2,9,1]],"t":"aaaaaaaaaa"}],"e":"par"}]}````````````````````````````````
197+
198+
Autolinking tests
199+
200+
```````````````````````````````` example
201+
http://www.google.com
202+
.
203+
{"document": [{"c": [{"u": "http://www.google.com", "e": "link", "t": "http://www.google.com"}], "e": "par"}]}````````````````````````````````
204+
205+
```````````````````````````````` example
206+
https://www.google.com
207+
.
208+
{"document": [{"c": [{"u": "https://www.google.com", "e": "link", "t": "https://www.google.com"}], "e": "par"}]}````````````````````````````````
209+
210+
```````````````````````````````` example
211+
www.google.com
212+
.
213+
{"document": [{"c": [{"u": "http://www.google.com", "e": "link", "t": "www.google.com"}], "e": "par"}]}````````````````````````````````
214+
215+
This one is checking that a url containing /r/foo isn't mangled in some weird way
216+
217+
```````````````````````````````` example
218+
https://www.reddit.com/r/ModSupport/comments/81dz9w/automod_removing_crossposts/
219+
.
220+
{"document": [{"c": [{"u": "https://www.reddit.com/r/ModSupport/comments/81dz9w/automod_removing_crossposts/", "e": "link", "t": "https://www.reddit.com/r/ModSupport/comments/81dz9w/automod_removing_crossposts/"}], "e": "par"}]}````````````````````````````````
221+
222+
Finally, an example pulled from the wild:
223+
224+
```````````````````````````````` example
225+
As seen here, naked URLs are not being parsed as URLs. If the URL is a Reddit
226+
link, the subreddit is parsed as a clickable link to that subreddit. For
227+
example,
228+
https://www.reddit.com/r/ModSupport/comments/81dz9w/automod_removing_crossposts/
229+
230+
If the link is another link, it is merely displayed as plain text. For example,
231+
https://www.google.com/
232+
.
233+
{"document": [{"c": [{"e": "text", "t": "As seen here, naked URLs are not being parsed as URLs. If the URL is a Redditlink, the subreddit is parsed as a clickable link to that subreddit. Forexample,"}, {"u": "https://www.reddit.com/r/ModSupport/comments/81dz9w/automod_removing_crossposts/", "e": "link", "t": "https://www.reddit.com/r/ModSupport/comments/81dz9w/automod_removing_crossposts/"}], "e": "par"}, {"c": [{"e": "text", "t": "If the link is another link, it is merely displayed as plain text. For example,"}, {"u": "https://www.google.com/", "e": "link", "t": "https://www.google.com/"}], "e": "par"}]}````````````````````````````````

specs/rtjson/rtjson.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Hello reddit, \*\***this should be bold,**\*\* the stars around it should not be
124124

125125
www.thisisalink.com
126126
.
127-
{"document":[{"e":"par","c":[{"e":"text","f":[[1,16,20]],"t":"Hello reddit, **this should be bold,** the stars around it should not be."}]},{"e":"par","c":[{"e":"text","t":"> This is text with an arrow in front"}]},{"e":"blockquote","c":[{"e":"par","c":[{"e":"text","t":"This is a quote"}]}]},{"e":"par","c":[{"e":"text","f":[[2,0,33]],"t":"Here we have something in italics"}]},{"e":"par","c":[{"e":"text","t":"*Here we have something with single-stars around it*"}]},{"e":"par","c":[{"e":"text","t":"`Is this a codeblock?`"}]},{"e":"par","c":[{"e":"text","t":"~~This should not be strike through~~"}]},{"e":"par","c":[{"e":"text","f":[[8,0,18]],"t":"But this should be"}]},{"e":"par","c":[{"e":"text","t":"[Finally here we have no link](www.example.com)"}]},{"e":"par","c":[{"e":"text","t":"www.thisisalink.com"}]}]}````````````````````````````````
127+
{"document": [{"c": [{"e": "text", "t": "Hello reddit, **this should be bold,** the stars around it should not be.", "f": [[1, 16, 20]]}], "e": "par"}, {"c": [{"e": "text", "t": "> This is text with an arrow in front"}], "e": "par"}, {"c": [{"c": [{"e": "text", "t": "This is a quote"}], "e": "par"}], "e": "blockquote"}, {"c": [{"e": "text", "t": "Here we have something in italics", "f": [[2, 0, 33]]}], "e": "par"}, {"c": [{"e": "text", "t": "*Here we have something with single-stars around it*"}], "e": "par"}, {"c": [{"e": "text", "t": "`Is this a codeblock?`"}], "e": "par"}, {"c": [{"e": "text", "t": "~~This should not be strike through~~"}], "e": "par"}, {"c": [{"e": "text", "t": "But this should be", "f": [[8, 0, 18]]}], "e": "par"}, {"c": [{"e": "text", "t": "[Finally here we have no link]("}, {"u": "http://www.example.com", "e": "link", "t": "www.example.com"}, {"e": "text", "t": ")"}], "e": "par"}, {"c": [{"u": "http://www.thisisalink.com", "e": "link", "t": "www.thisisalink.com"}], "e": "par"}]}````````````````````````````````
128128

129129
```````````````````````````````` example
130130
1.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn cm_to_rtjson(cm: String) -> Value {
132132
ext_strikethrough: true,
133133
ext_tagfilter: false,
134134
ext_table: true,
135-
ext_autolink: false,
135+
ext_autolink: true,
136136
ext_tasklist: false,
137137
ext_superscript: false,
138138
ext_footnotes: false,

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ fn main() {
297297
ext_strikethrough: true,
298298
ext_tagfilter: false,
299299
ext_table: true,
300-
ext_autolink: false,
300+
ext_autolink: true,
301301
ext_tasklist: false,
302302
ext_superscript: false,
303303
ext_footnotes: false,

0 commit comments

Comments
 (0)