Currently we re using javascript new RegExp( #[^,#=!s][^,#=!s]* )
(see [1])
and it mostly works, except that it also matches URLs with anchors like http://this。is/no#hashtag and also we d rather avoid matching foo#bar
一些尝试是用光头进行的,但似乎并没有奏效,或者我没有这样做。
来源案文如下:
#public #writable #kommentarer-till-beta -- all these should be matched
Verkligen #bra jobbat! T ex #kommentarer till #artiklar och #blogginlägg, kool。 -- mixed within text
http://this。is/no#hashtag -- problem
xxy#bar -- We d prefer not matching this one, and。。。
#foo=bar =foo#bar -- we probably shouldn t match any of those either。
#foo,bar #foo;bar #foo-bar #foo:bar -- We re flexible on whether these get matched in part or in full
。
我们想要达到以下产出:
(showing $ instead of <a class=tag href=。。。。。>。。。</a> for readability reasons)
$ $ $ -- all these should be matched
Verkligen $ jobbat! T ex $ till $ och $, kool。 -- mixed within text
http://this。is/no$ -- problem
xxy$ -- We d prefer not matching this one, and。。。
$=bar =foo$ -- we probably shouldn t match any of those either。
$,bar $ $ $ -- We re flexible on whether these get matched in part or in full
[1] http://github。com/ether/pad/blob/master/etherpad/src/plugins/twitterStyleTags/hooks。js