BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
817399e3
Commit
817399e3
authored
Oct 08, 2013
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show links with correct ref.
parent
810d90dd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+4
-4
gitlab_html.rb
lib/redcarpet/render/gitlab_html.rb
+2
-1
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
817399e3
...
...
@@ -59,10 +59,10 @@ module GitlabMarkdownHelper
end
end
def
create_relative_links
(
text
,
project_path_with_namespace
)
to_be_fixed
=
text
.
split
(
"
\n
"
).
map
{
|
a
|
a
.
scan
(
/\]\(([^(]+)\)/
)
}.
reject
{
|
b
|
b
.
empty?
}.
flatten
.
reject
{
|
c
|
c
.
include?
(
"http"
||
"www"
)}
to_be_fixed
.
each
do
|
string
|
text
.
gsub!
(
string
,
"/
#{
project_path_with_namespace
}
/blob/
master
/
#{
string
}
"
)
def
create_relative_links
(
text
,
project_path_with_namespace
,
ref
)
links
=
text
.
split
(
"
\n
"
).
map
{
|
a
|
a
.
scan
(
/\]\(([^(]+)\)/
)
}.
reject
{
|
b
|
b
.
empty?
}.
flatten
.
reject
{
|
c
|
c
.
include?
(
"http"
||
"www"
)}
links
.
each
do
|
string
|
text
.
gsub!
(
string
,
"/
#{
project_path_with_namespace
}
/blob/
#{
ref
}
/
#{
string
}
"
)
end
text
end
...
...
lib/redcarpet/render/gitlab_html.rb
View file @
817399e3
...
...
@@ -6,6 +6,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def
initialize
(
template
,
options
=
{})
@template
=
template
@project
=
@template
.
instance_variable_get
(
"@project"
)
@ref
=
@template
.
instance_variable_get
(
"@ref"
)
super
options
end
...
...
@@ -33,7 +34,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
end
def
preprocess
(
full_document
)
h
.
create_relative_links
(
full_document
,
@project
.
path_with_namespace
)
h
.
create_relative_links
(
full_document
,
@project
.
path_with_namespace
,
@ref
)
end
def
postprocess
(
full_document
)
...
...
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