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
Tatuya Kamada
gitlab-ce
Commits
66dd61ef
Commit
66dd61ef
authored
Oct 12, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
parents
fba61417
7a01d0cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
lib/redcarpet/render/gitlab_html.rb
lib/redcarpet/render/gitlab_html.rb
+12
-0
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+18
-0
No files found.
lib/redcarpet/render/gitlab_html.rb
View file @
66dd61ef
...
...
@@ -10,6 +10,17 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
super
options
end
# If project has issue number 39, apostrophe will be linked in
# regular text to the issue as Redcarpet will convert apostrophe to
# #39;
# We replace apostrophe with right single quote before Redcarpet
# does the processing and put the apostrophe back in postprocessing.
# This only influences regular text, code blocks are untouched.
def
normal_text
(
text
)
return
text
unless
text
.
present?
text
.
gsub
(
"'"
,
"’"
)
end
def
block_code
(
code
,
language
)
# New lines are placed to fix an rendering issue
# with code wrapped inside <h1> tag for next case:
...
...
@@ -44,6 +55,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end
def
postprocess
(
full_document
)
full_document
.
gsub!
(
"’"
,
"'"
)
unless
@template
.
instance_variable_get
(
"@project_wiki"
)
||
@project
.
nil?
full_document
=
h
.
create_relative_links
(
full_document
)
end
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
66dd61ef
...
...
@@ -530,6 +530,24 @@ describe GitlabMarkdownHelper do
markdown
(
actual
).
should
match
(
%r{<li>light by <a.+>@
#{
member
.
user
.
username
}
</a></li>}
)
end
it
"should not link the apostrophe to issue 39"
do
project
.
team
<<
[
user
,
:master
]
project
.
issues
.
stub
(
:where
).
with
(
iid:
'39'
).
and_return
([
issue
])
actual
=
"Yes, it is @
#{
member
.
user
.
username
}
's task."
expected
=
/Yes, it is <a.+>@
#{
member
.
user
.
username
}
<\/a>'s task/
markdown
(
actual
).
should
match
(
expected
)
end
it
"should not link the apostrophe to issue 39 in code blocks"
do
project
.
team
<<
[
user
,
:master
]
project
.
issues
.
stub
(
:where
).
with
(
iid:
'39'
).
and_return
([
issue
])
actual
=
"Yes, `it is @
#{
member
.
user
.
username
}
's task.`"
expected
=
/Yes, <code>it is @gfm\'s task.<\/code>/
markdown
(
actual
).
should
match
(
expected
)
end
it
"should handle references in <em>"
do
actual
=
"Apply _!
#{
merge_request
.
iid
}
_ ASAP"
...
...
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