Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
Linkify
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
Elixir libraries
Linkify
Commits
558a7e9f
Commit
558a7e9f
authored
6 years ago
by
minibikini
Browse files
Options
Downloads
Patches
Plain Diff
improve hashtags
parent
6c7a0c13
No related branches found
No related tags found
7 merge requests
!10
Improve Parser
,
!9
Improve detection of URLs and Asian scripts
,
!8
Improve CI
,
!6
Fix link text
,
!5
Improve hashtags and `rel` attribute
,
!3
fix carriage return
,
!2
Small fixes and improvements
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/auto_linker/builder.ex
+2
-3
2 additions, 3 deletions
lib/auto_linker/builder.ex
lib/auto_linker/parser.ex
+1
-1
1 addition, 1 deletion
lib/auto_linker/parser.ex
test/auto_linker_test.exs
+1
-1
1 addition, 1 deletion
test/auto_linker_test.exs
with
4 additions
and
5 deletions
lib/auto_linker/builder.ex
+
2
−
3
View file @
558a7e9f
...
@@ -125,16 +125,15 @@ defmodule AutoLinker.Builder do
...
@@ -125,16 +125,15 @@ defmodule AutoLinker.Builder do
|>
format_mention
(
name
,
opts
)
|>
format_mention
(
name
,
opts
)
end
end
def
create_hashtag_link
(
tag
,
_buffer
,
opts
)
do
def
create_hashtag_link
(
"#"
<>
tag
,
_buffer
,
opts
)
do
hashtag_prefix
=
opts
[
:hashtag_prefix
]
hashtag_prefix
=
opts
[
:hashtag_prefix
]
url
=
hashtag_prefix
<>
tag
url
=
hashtag_prefix
<>
tag
[]
[
href:
url
]
|>
build_attrs
(
url
,
opts
,
:rel
)
|>
build_attrs
(
url
,
opts
,
:rel
)
|>
build_attrs
(
url
,
opts
,
:target
)
|>
build_attrs
(
url
,
opts
,
:target
)
|>
build_attrs
(
url
,
opts
,
:class
)
|>
build_attrs
(
url
,
opts
,
:class
)
|>
build_attrs
(
url
,
opts
,
:scheme
)
|>
format_hashtag
(
tag
,
opts
)
|>
format_hashtag
(
tag
,
opts
)
end
end
...
...
This diff is collapsed.
Click to expand it.
lib/auto_linker/parser.ex
+
1
−
1
View file @
558a7e9f
...
@@ -45,7 +45,7 @@ defmodule AutoLinker.Parser do
...
@@ -45,7 +45,7 @@ defmodule AutoLinker.Parser do
# https://www.w3.org/TR/html5/forms.html#valid-e-mail-address
# https://www.w3.org/TR/html5/forms.html#valid-e-mail-address
@match_email
~r/^[a-zA-Z0-9.!#$%&'*+\/
=
?^
_
`
{
|
}
~
-
]
+
@
[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?(?:
\
.
[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?)
*
$
/
u
@match_email
~r/^[a-zA-Z0-9.!#$%&'*+\/
=
?^
_
`
{
|
}
~
-
]
+
@
[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?(?:
\
.
[
a
-
zA
-
Z0
-
9
](
?:
[
a
-
zA
-
Z0
-
9
-
]{
0
,
61
}[
a
-
zA
-
Z0
-
9
])
?)
*
$
/
u
@match_hashtag
~r/^
\#
(?<tag>\w+)/u
@match_hashtag
~r/^(?<tag>\
#\
w+)/u
@prefix_extra
[
@prefix_extra
[
"magnet:?"
,
"magnet:?"
,
...
...
This diff is collapsed.
Click to expand it.
test/auto_linker_test.exs
+
1
−
1
View file @
558a7e9f
...
@@ -98,7 +98,7 @@ defmodule AutoLinkerTest do
...
@@ -98,7 +98,7 @@ defmodule AutoLinkerTest do
assert
result_text
==
assert
result_text
==
"<a href=
\"
https://example.com/user/hello
\"
>#hello</a> <a href=
\"
https://example.com/user/world
\"
>#world</a>"
"<a href=
\"
https://example.com/user/hello
\"
>#hello</a> <a href=
\"
https://example.com/user/world
\"
>#world</a>"
assert
MapSet
.
to_list
(
tags
)
==
[
"hello"
,
"world"
]
assert
MapSet
.
to_list
(
tags
)
==
[
"
#
hello"
,
"
#
world"
]
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment