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
c4f26d4b
Commit
c4f26d4b
authored
Sep 04, 2018
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added feature flag 'commonmark_for_repositories'
parent
3aea946e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
2 deletions
+33
-2
app/helpers/markup_helper.rb
app/helpers/markup_helper.rb
+6
-0
app/models/repository.rb
app/models/repository.rb
+6
-1
app/views/projects/wikis/_form.html.haml
app/views/projects/wikis/_form.html.haml
+4
-1
spec/helpers/markup_helper_spec.rb
spec/helpers/markup_helper_spec.rb
+17
-0
No files found.
app/helpers/markup_helper.rb
View file @
c4f26d4b
...
...
@@ -107,6 +107,7 @@ module MarkupHelper
def
markup
(
file_name
,
text
,
context
=
{})
context
[
:project
]
||=
@project
context
[
:markdown_engine
]
||=
:redcarpet
unless
commonmark_for_repositories_enabled?
html
=
context
.
delete
(
:rendered
)
||
markup_unsafe
(
file_name
,
text
,
context
)
prepare_for_rendering
(
html
,
context
)
end
...
...
@@ -122,6 +123,7 @@ module MarkupHelper
page_slug:
wiki_page
.
slug
,
issuable_state_filter_enabled:
true
)
context
[
:markdown_engine
]
||=
:redcarpet
unless
commonmark_for_repositories_enabled?
html
=
case
wiki_page
.
format
...
...
@@ -176,6 +178,10 @@ module MarkupHelper
end
end
def
commonmark_for_repositories_enabled?
Feature
.
enabled?
(
:commonmark_for_repositories
,
default_enabled:
true
)
end
private
# Return +text+, truncated to +max_chars+ characters, excluding any HTML
...
...
app/models/repository.rb
View file @
c4f26d4b
...
...
@@ -580,7 +580,12 @@ class Repository
end
def
rendered_readme
MarkupHelper
.
markup_unsafe
(
readme
.
name
,
readme
.
data
,
project:
project
)
if
readme
return
unless
readme
context
=
{
project:
project
}
context
[
:markdown_engine
]
=
:redcarpet
unless
MarkupHelper
.
commonmark_for_repositories_enabled?
MarkupHelper
.
markup_unsafe
(
readme
.
name
,
readme
.
data
,
context
)
end
cache_method
:rendered_readme
...
...
app/views/projects/wikis/_form.html.haml
View file @
c4f26d4b
-
commit_message
=
@page
.
persisted?
?
s_
(
"WikiPageEdit|Update %{page_title}"
)
:
s_
(
"WikiPageCreate|Create %{page_title}"
)
-
commit_message
=
commit_message
%
{
page_title:
@page
.
title
}
-
markdown_version
=
params
[
:legacy_render
]
?
CacheMarkdownField
::
CACHE_REDCARPET_VERSION
:
0
-
if
params
[
:legacy_render
]
||
!
commonmark_for_repositories_enabled?
-
markdown_version
=
CacheMarkdownField
::
CACHE_REDCARPET_VERSION
-
else
-
markdown_version
=
0
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@page
],
method:
@page
.
persisted?
?
:put
:
:post
,
html:
{
class:
'wiki-form common-note-form prepend-top-default js-quick-submit'
},
...
...
spec/helpers/markup_helper_spec.rb
View file @
c4f26d4b
...
...
@@ -212,6 +212,17 @@ describe MarkupHelper do
helper
.
render_wiki_content
(
@wiki
)
end
it
'uses Wiki pipeline for markdown files with RedCarpet if feature disabled'
do
stub_feature_flags
(
commonmark_for_repositories:
false
)
allow
(
@wiki
).
to
receive
(
:format
).
and_return
(
:markdown
)
expect
(
helper
).
to
receive
(
:markdown_unsafe
).
with
(
'wiki content'
,
pipeline: :wiki
,
project:
project
,
project_wiki:
@wiki
,
page_slug:
"nested/page"
,
issuable_state_filter_enabled:
true
,
markdown_engine: :redcarpet
)
helper
.
render_wiki_content
(
@wiki
)
end
it
"uses Asciidoctor for asciidoc files"
do
allow
(
@wiki
).
to
receive
(
:format
).
and_return
(
:asciidoc
)
...
...
@@ -266,6 +277,12 @@ describe MarkupHelper do
it
'honors markdown_engine for RedCarpet'
do
expect
(
helper
.
markup
(
'foo.md'
,
'x^2'
,
{
markdown_engine: :redcarpet
})).
to
include
(
'x<sup>2</sup>'
)
end
it
'uses RedCarpet if feature disabled'
do
stub_feature_flags
(
commonmark_for_repositories:
false
)
expect
(
helper
.
markup
(
'foo.md'
,
'x^2'
,
{
markdown_engine: :redcarpet
})).
to
include
(
'x<sup>2</sup>'
)
end
end
describe
'#first_line_in_markdown'
do
...
...
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