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
5794d65a
Commit
5794d65a
authored
Sep 01, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add post_process method to Gitlab::Markdown
parent
ca8d2253
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
+27
-3
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+4
-2
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+22
-0
spec/features/markdown_spec.rb
spec/features/markdown_spec.rb
+1
-1
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
5794d65a
...
@@ -52,7 +52,8 @@ module GitlabMarkdownHelper
...
@@ -52,7 +52,8 @@ module GitlabMarkdownHelper
ref:
@ref
ref:
@ref
)
)
Gitlab
::
Markdown
.
render
(
text
,
context
)
html
=
Gitlab
::
Markdown
.
render
(
text
,
context
)
Gitlab
::
Markdown
.
post_process
(
html
,
current_user
)
end
end
# TODO (rspeicher): Remove all usages of this helper and just call `markdown`
# TODO (rspeicher): Remove all usages of this helper and just call `markdown`
...
@@ -65,7 +66,8 @@ module GitlabMarkdownHelper
...
@@ -65,7 +66,8 @@ module GitlabMarkdownHelper
ref:
@ref
ref:
@ref
)
)
Gitlab
::
Markdown
.
gfm
(
text
,
options
)
html
=
Gitlab
::
Markdown
.
gfm
(
text
,
options
)
Gitlab
::
Markdown
.
post_process
(
html
,
current_user
)
end
end
def
asciidoc
(
text
)
def
asciidoc
(
text
)
...
...
lib/gitlab/markdown.rb
View file @
5794d65a
...
@@ -31,6 +31,24 @@ module Gitlab
...
@@ -31,6 +31,24 @@ module Gitlab
renderer
.
render
(
markdown
)
renderer
.
render
(
markdown
)
end
end
# Perform post-processing on an HTML String
#
# This method is used to perform state-dependent changes to a String of
# HTML, such as removing references that the current user doesn't have
# permission to make (`RedactorFilter`).
#
# html - String to process
# for_user - User state
#
# Returns an HTML-safe String
def
self
.
post_process
(
html
,
for_user
)
result
=
post_processor
.
call
(
html
,
current_user:
for_user
)
result
[
:output
].
to_html
.
html_safe
end
# Provide autoload paths for filters to prevent a circular dependency error
# Provide autoload paths for filters to prevent a circular dependency error
autoload
:AutolinkFilter
,
'gitlab/markdown/autolink_filter'
autoload
:AutolinkFilter
,
'gitlab/markdown/autolink_filter'
autoload
:CommitRangeReferenceFilter
,
'gitlab/markdown/commit_range_reference_filter'
autoload
:CommitRangeReferenceFilter
,
'gitlab/markdown/commit_range_reference_filter'
...
@@ -115,6 +133,10 @@ module Gitlab
...
@@ -115,6 +133,10 @@ module Gitlab
end
end
end
end
def
self
.
post_processor
@post_processor
||=
HTML
::
Pipeline
.
new
([
Gitlab
::
Markdown
::
RedactorFilter
])
end
def
self
.
redcarpet_options
def
self
.
redcarpet_options
# https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use
# https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use
@redcarpet_options
||=
{
@redcarpet_options
||=
{
...
...
spec/features/markdown_spec.rb
View file @
5794d65a
...
@@ -220,7 +220,7 @@ describe 'GitLab Markdown', feature: true do
...
@@ -220,7 +220,7 @@ describe 'GitLab Markdown', feature: true do
end
end
end
end
#
`markdown` calls these two methods
#
Fake a `current_user` helper
def
current_user
def
current_user
@feat
.
user
@feat
.
user
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