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
5a7451c2
Commit
5a7451c2
authored
Aug 15, 2018
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable CommonMark for files and wikis
parent
bd807fe0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
10 deletions
+9
-10
app/helpers/markup_helper.rb
app/helpers/markup_helper.rb
+1
-3
app/models/repository.rb
app/models/repository.rb
+1
-1
app/views/projects/wikis/_form.html.haml
app/views/projects/wikis/_form.html.haml
+1
-2
spec/helpers/markup_helper_spec.rb
spec/helpers/markup_helper_spec.rb
+6
-4
No files found.
app/helpers/markup_helper.rb
View file @
5a7451c2
...
@@ -107,7 +107,6 @@ module MarkupHelper
...
@@ -107,7 +107,6 @@ module MarkupHelper
def
markup
(
file_name
,
text
,
context
=
{})
def
markup
(
file_name
,
text
,
context
=
{})
context
[
:project
]
||=
@project
context
[
:project
]
||=
@project
context
[
:markdown_engine
]
||=
:redcarpet
html
=
context
.
delete
(
:rendered
)
||
markup_unsafe
(
file_name
,
text
,
context
)
html
=
context
.
delete
(
:rendered
)
||
markup_unsafe
(
file_name
,
text
,
context
)
prepare_for_rendering
(
html
,
context
)
prepare_for_rendering
(
html
,
context
)
end
end
...
@@ -121,8 +120,7 @@ module MarkupHelper
...
@@ -121,8 +120,7 @@ module MarkupHelper
project:
@project
,
project:
@project
,
project_wiki:
@project_wiki
,
project_wiki:
@project_wiki
,
page_slug:
wiki_page
.
slug
,
page_slug:
wiki_page
.
slug
,
issuable_state_filter_enabled:
true
,
issuable_state_filter_enabled:
true
markdown_engine: :redcarpet
}
}
html
=
html
=
...
...
app/models/repository.rb
View file @
5a7451c2
...
@@ -580,7 +580,7 @@ class Repository
...
@@ -580,7 +580,7 @@ class Repository
end
end
def
rendered_readme
def
rendered_readme
MarkupHelper
.
markup_unsafe
(
readme
.
name
,
readme
.
data
,
project:
project
,
markdown_engine: :redcarpet
)
if
readme
MarkupHelper
.
markup_unsafe
(
readme
.
name
,
readme
.
data
,
project:
project
)
if
readme
end
end
cache_method
:rendered_readme
cache_method
:rendered_readme
...
...
app/views/projects/wikis/_form.html.haml
View file @
5a7451c2
...
@@ -2,8 +2,7 @@
...
@@ -2,8 +2,7 @@
-
commit_message
=
commit_message
%
{
page_title:
@page
.
title
}
-
commit_message
=
commit_message
%
{
page_title:
@page
.
title
}
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@page
],
method:
@page
.
persisted?
?
:put
:
:post
,
=
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'
},
html:
{
class:
'wiki-form common-note-form prepend-top-default js-quick-submit'
}
do
|
f
|
data:
{
markdown_version:
CacheMarkdownField
::
CACHE_REDCARPET_VERSION
}
do
|
f
|
=
form_errors
(
@page
)
=
form_errors
(
@page
)
-
if
@page
.
persisted?
-
if
@page
.
persisted?
...
...
spec/helpers/markup_helper_spec.rb
View file @
5a7451c2
...
@@ -207,7 +207,7 @@ describe MarkupHelper do
...
@@ -207,7 +207,7 @@ describe MarkupHelper do
expect
(
helper
).
to
receive
(
:markdown_unsafe
).
with
(
'wiki content'
,
expect
(
helper
).
to
receive
(
:markdown_unsafe
).
with
(
'wiki content'
,
pipeline: :wiki
,
project:
project
,
project_wiki:
@wiki
,
page_slug:
"nested/page"
,
pipeline: :wiki
,
project:
project
,
project_wiki:
@wiki
,
page_slug:
"nested/page"
,
issuable_state_filter_enabled:
true
,
markdown_engine: :redcarpet
)
issuable_state_filter_enabled:
true
)
helper
.
render_wiki_content
(
@wiki
)
helper
.
render_wiki_content
(
@wiki
)
end
end
...
@@ -259,10 +259,12 @@ describe MarkupHelper do
...
@@ -259,10 +259,12 @@ describe MarkupHelper do
expect
(
helper
.
markup
(
'foo.md'
,
content
,
rendered:
'<p>NOEL</p>'
)).
to
eq
(
'<p>NOEL</p>'
)
expect
(
helper
.
markup
(
'foo.md'
,
content
,
rendered:
'<p>NOEL</p>'
)).
to
eq
(
'<p>NOEL</p>'
)
end
end
it
'defaults to Redcarpet'
do
it
'defaults to CommonMark'
do
expect
(
helper
).
to
receive
(
:markdown_unsafe
).
with
(
content
,
hash_including
(
markdown_engine: :redcarpet
)).
and_return
(
'NOEL'
)
expect
(
helper
.
markup
(
'foo.md'
,
'x^2'
)).
to
include
(
'x^2'
)
end
expect
(
helper
.
markup
(
'foo.md'
,
content
)).
to
eq
(
'NOEL'
)
it
'honors markdown_engine for RedCarpet'
do
expect
(
helper
.
markup
(
'foo.md'
,
'x^2'
,
{
markdown_engine: :redcarpet
})).
to
include
(
'x<sup>2</sup>'
)
end
end
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