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
Léo-Paul Géneau
gitlab-ce
Commits
06d6f443
Commit
06d6f443
authored
Oct 08, 2013
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for wiki.
parent
817399e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+8
-2
lib/redcarpet/render/gitlab_html.rb
lib/redcarpet/render/gitlab_html.rb
+5
-1
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
06d6f443
...
@@ -59,10 +59,16 @@ module GitlabMarkdownHelper
...
@@ -59,10 +59,16 @@ module GitlabMarkdownHelper
end
end
end
end
def
create_relative_links
(
text
,
project_path_with_namespace
,
ref
)
def
create_relative_links
(
text
,
project_path_with_namespace
,
ref
,
wiki
=
false
)
links
=
text
.
split
(
"
\n
"
).
map
{
|
a
|
a
.
scan
(
/\]\(([^(]+)\)/
)
}.
reject
{
|
b
|
b
.
empty?
}.
flatten
.
reject
{
|
c
|
c
.
include?
(
"http"
||
"www"
)}
links
=
text
.
split
(
"
\n
"
).
map
{
|
a
|
a
.
scan
(
/\]\(([^(]+)\)/
)
}.
reject
{
|
b
|
b
.
empty?
}.
flatten
.
reject
{
|
c
|
c
.
include?
(
"http"
||
"www"
)}
links
.
each
do
|
string
|
links
.
each
do
|
string
|
text
.
gsub!
(
string
,
"/
#{
project_path_with_namespace
}
/blob/
#{
ref
}
/
#{
string
}
"
)
new_link
=
[
project_path_with_namespace
,
wiki
?
"wiki"
:
"blob"
,
ref
,
string
].
compact
.
join
(
"/"
)
text
.
gsub!
(
string
,
"/
#{
new_link
}
"
)
end
end
text
text
end
end
...
...
lib/redcarpet/render/gitlab_html.rb
View file @
06d6f443
...
@@ -34,10 +34,14 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
...
@@ -34,10 +34,14 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end
end
def
preprocess
(
full_document
)
def
preprocess
(
full_document
)
h
.
create_relative_links
(
full_document
,
@project
.
path_with_namespace
,
@ref
)
h
.
create_relative_links
(
full_document
,
@project
.
path_with_namespace
,
@ref
,
is_wiki?
)
end
end
def
postprocess
(
full_document
)
def
postprocess
(
full_document
)
h
.
gfm
(
full_document
)
h
.
gfm
(
full_document
)
end
end
def
is_wiki?
@template
.
instance_variable_get
(
"@wiki"
)
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