Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Milan
diaspora
Commits
06ab4986
Commit
06ab4986
authored
Mar 15, 2014
by
Jonne Haß
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4847 from hincupetru/3692-hashtags-inside-markdown-link
Solved problem with hashtags inside markdown links
parents
3c4d8d95
7c4d783d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
Changelog.md
Changelog.md
+1
-0
app/assets/javascripts/app/helpers/text_formatter.js
app/assets/javascripts/app/helpers/text_formatter.js
+10
-5
spec/javascripts/app/helpers/text_formatter_spec.js
spec/javascripts/app/helpers/text_formatter_spec.js
+7
-0
No files found.
Changelog.md
View file @
06ab4986
...
...
@@ -24,6 +24,7 @@
*
Fixed Atom Feed Error if reshared Post is deleted [#4638] (https://github.com/diaspora/diaspora/issues/4638)
*
Show hovercards in the notification drop-down for users on the same pod
[
#4843
](
https://github.com/diaspora/diaspora/pull/4843
)
*
The photo stream no longer repeats after the last photo
[
#4726
](
https://github.com/diaspora/diaspora/issues/4726
)
*
Stop parsing hashtags inside markdown links
[
#3692
](
https://github.com/diaspora/diaspora/issues/3692
)
## Features
*
You can report a single post by clicking the correct icon in the controler section
[
#4517
](
https://github.com/diaspora/diaspora/pull/4517
)
...
...
app/assets/javascripts/app/helpers/text_formatter.js
View file @
06ab4986
...
...
@@ -108,11 +108,16 @@ $(function() {
};
textFormatter
.
hashtagify
=
function
hashtagify
(
text
){
var
utf8WordCharcters
=
/
(\s
|^|>
)
#
([\u
0080-
\u
FFFF|
\w
|-
]
+|<3
)
/g
return
text
.
replace
(
utf8WordCharcters
,
function
(
hashtag
,
preceeder
,
tagText
)
{
return
preceeder
+
"
<a href='/tags/
"
+
tagText
.
toLowerCase
()
+
"
' class='tag'>#
"
+
tagText
+
"
</a>
"
})
var
utf8WordCharcters
=
/
(\s
|^|>
)
#
([\u
0080-
\u
FFFF|
\w
|-
]
+|<3
)
/g
;
var
linkRegex
=
/<a
[^
>
]
*>
(
.*
?)
<
\/
a>/g
;
if
(
text
.
match
(
linkRegex
))
return
text
;
else
return
text
.
replace
(
utf8WordCharcters
,
function
(
hashtag
,
preceeder
,
tagText
)
{
return
preceeder
+
"
<a href='/tags/
"
+
tagText
.
toLowerCase
()
+
"
' class='tag'>#
"
+
tagText
+
"
</a>
"
});
};
textFormatter
.
mentionify
=
function
mentionify
(
text
,
mentions
)
{
...
...
spec/javascripts/app/helpers/text_formatter_spec.js
View file @
06ab4986
...
...
@@ -238,6 +238,13 @@ describe("app.helpers.textFormatter", function(){
expect
(
formattedText
).
toContain
(
"
/tags/parties
"
)
})
it
(
"
doesn't create tag if the text is a link
"
,
function
(){
var
link
=
$
(
'
<a/>
'
,
{
href
:
'
http://me.co
'
}).
html
(
'
#me
'
)[
0
].
outerHTML
;
var
result
=
this
.
formatter
.
hashtagify
(
link
);
expect
(
result
).
toEqual
(
link
);
})
})
})
...
...
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