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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
7cc4b3f6
Commit
7cc4b3f6
authored
Sep 07, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1406 from riyad/markdown-code-fixes
Markdown code fixes
parents
60ab3bea
d661b893
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+1
-1
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+10
-4
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+5
-0
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
7cc4b3f6
...
...
@@ -27,7 +27,7 @@ module GitlabMarkdownHelper
filter_html:
true
,
with_toc_data:
true
,
hard_wrap:
true
)
@markdown
||
=
Redcarpet
::
Markdown
.
new
(
gitlab_renderer
,
@markdown
=
Redcarpet
::
Markdown
.
new
(
gitlab_renderer
,
# see https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use
no_intra_emphasis:
true
,
tables:
true
,
...
...
lib/gitlab/markdown.rb
View file @
7cc4b3f6
...
...
@@ -47,7 +47,9 @@ module Gitlab
# Note: reference links will only be generated if @project is set
def
gfm
(
text
,
html_options
=
{})
return
text
if
text
.
nil?
return
text
if
@project
.
nil?
# prevents the string supplied through the _text_ argument to be altered
text
=
text
.
dup
@html_options
=
html_options
...
...
@@ -78,9 +80,12 @@ module Gitlab
#
# text - Text to parse
#
# Note: reference links will only be generated if @project is set
#
# Returns parsed text
def
parse
(
text
)
text
=
text
.
gsub
(
REFERENCE_PATTERN
)
do
|
match
|
# parse reference links
text
.
gsub!
(
REFERENCE_PATTERN
)
do
|
match
|
prefix
=
$1
||
''
reference
=
$2
identifier
=
$3
||
$4
||
$5
...
...
@@ -91,9 +96,10 @@ module Gitlab
else
match
end
end
end
if
@project
text
=
text
.
gsub
(
EMOJI_PATTERN
)
do
|
match
|
# parse emoji
text
.
gsub!
(
EMOJI_PATTERN
)
do
|
match
|
if
valid_emoji?
(
$2
)
image_tag
(
"emoji/
#{
$2
}
.png"
,
size:
"20x20"
,
class:
'emoji'
,
title:
$1
,
alt:
$1
)
else
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
7cc4b3f6
...
...
@@ -247,6 +247,11 @@ describe GitlabMarkdownHelper do
it
"ignores invalid emoji"
do
gfm
(
":invalid-emoji:"
).
should_not
match
(
/<img/
)
end
it
"should work independet of reference links (i.e. without @project being set)"
do
@project
=
nil
gfm
(
":+1:"
).
should
match
(
/<img/
)
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