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
iv
gitlab-ce
Commits
810d90dd
Commit
810d90dd
authored
Oct 08, 2013
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search and replace relative links in tree/readme
parent
073c8a29
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+10
-1
lib/redcarpet/render/gitlab_html.rb
lib/redcarpet/render/gitlab_html.rb
+4
-0
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
810d90dd
...
...
@@ -34,7 +34,8 @@ module GitlabMarkdownHelper
# see https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch-
filter_html:
true
,
with_toc_data:
true
,
hard_wrap:
true
)
hard_wrap:
true
,
safe_links_only:
true
)
@markdown
=
Redcarpet
::
Markdown
.
new
(
gitlab_renderer
,
# see https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use
no_intra_emphasis:
true
,
...
...
@@ -57,4 +58,12 @@ module GitlabMarkdownHelper
wiki_page
.
formatted_content
.
html_safe
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
}
"
)
end
text
end
end
lib/redcarpet/render/gitlab_html.rb
View file @
810d90dd
...
...
@@ -32,6 +32,10 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
h
.
link_to_gfm
(
content
,
link
,
title:
title
)
end
def
preprocess
(
full_document
)
h
.
create_relative_links
(
full_document
,
@project
.
path_with_namespace
)
end
def
postprocess
(
full_document
)
h
.
gfm
(
full_document
)
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