Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9dd879bc
Commit
9dd879bc
authored
Oct 02, 2019
by
Harish Ramachandran
Committed by
Jan Provaznik
Nov 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap emojis in links when needed
parent
8dcbe92c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
app/helpers/markup_helper.rb
app/helpers/markup_helper.rb
+6
-4
spec/helpers/markup_helper_spec.rb
spec/helpers/markup_helper_spec.rb
+1
-1
No files found.
app/helpers/markup_helper.rb
View file @
9dd879bc
...
@@ -51,12 +51,14 @@ module MarkupHelper
...
@@ -51,12 +51,14 @@ module MarkupHelper
text
=
fragment
.
children
[
0
].
text
text
=
fragment
.
children
[
0
].
text
fragment
.
children
[
0
].
replace
(
link_to
(
text
,
url
,
html_options
))
fragment
.
children
[
0
].
replace
(
link_to
(
text
,
url
,
html_options
))
else
else
# Traverse the fragment's first generation of children looking for pure
# Traverse the fragment's first generation of children looking for
# text, wrapping anything found in the requested link
# either pure text or emojis, wrapping anything found in the
# requested link
fragment
.
children
.
each
do
|
node
|
fragment
.
children
.
each
do
|
node
|
next
unless
node
.
text?
next
unless
node
.
text?
||
node
.
name
.
match?
(
'gl-emoji'
)
node
.
replace
(
link_to
(
node
.
text
,
url
,
html_options
))
node
.
replace
(
link_to
(
node
.
text
,
url
,
html_options
))
if
node
.
text?
node
.
replace
(
link_to
(
node
.
to_html
.
html_safe
,
url
,
html_options
))
if
node
.
name
.
match?
(
'gl-emoji'
)
end
end
end
end
...
...
spec/helpers/markup_helper_spec.rb
View file @
9dd879bc
...
@@ -210,7 +210,7 @@ describe MarkupHelper do
...
@@ -210,7 +210,7 @@ describe MarkupHelper do
it
'replaces commit message with emoji to link'
do
it
'replaces commit message with emoji to link'
do
actual
=
link_to_markdown
(
':book: Book'
,
'/foo'
)
actual
=
link_to_markdown
(
':book: Book'
,
'/foo'
)
expect
(
actual
)
expect
(
actual
)
.
to
eq
'<
gl-emoji title="open book" data-name="book" data-unicode-version="6.0">📖</gl-emoji
><a href="/foo"> Book</a>'
.
to
eq
'<
a href="/foo"><gl-emoji title="open book" data-name="book" data-unicode-version="6.0">📖</gl-emoji></a
><a href="/foo"> Book</a>'
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment