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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
90f587f4
Commit
90f587f4
authored
Sep 05, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the entire `gfm` method to Gitlab::Markdown, which will be a module now
parent
880a233e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
34 deletions
+1
-34
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+1
-34
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
90f587f4
module
GitlabMarkdownHelper
module
GitlabMarkdownHelper
# Replaces references (i.e. @abc, #123, !456, ...) in the text with links to
include
Gitlab
::
Markdown
# the appropriate items in Gitlab.
#
# text - the source text
# html_options - extra options for the reference links as given to link_to
#
# note: reference links will only be generated if @project is set
#
# see Gitlab::Markdown for details on the supported syntax
def
gfm
(
text
,
html_options
=
{})
return
text
if
text
.
nil?
return
text
if
@project
.
nil?
# Extract pre blocks so they are not altered
# from http://github.github.com/github-flavored-markdown/
extractions
=
{}
text
.
gsub!
(
%r{<pre>.*?</pre>|<code>.*?</code>}m
)
do
|
match
|
md5
=
Digest
::
MD5
.
hexdigest
(
match
)
extractions
[
md5
]
=
match
"{gfm-extraction-
#{
md5
}
}"
end
# TODO: add popups with additional information
parser
=
Gitlab
::
Markdown
.
new
(
@project
,
html_options
)
text
=
parser
.
parse
(
text
)
# Insert pre block extractions
text
.
gsub!
(
/\{gfm-extraction-(\h{32})\}/
)
do
extractions
[
$1
]
end
sanitize
text
.
html_safe
,
attributes:
ActionView
::
Base
.
sanitized_allowed_attributes
+
%w(id class )
end
# Use this in places where you would normally use link_to(gfm(...), ...).
# Use this in places where you would normally use link_to(gfm(...), ...).
#
#
...
...
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