BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9d3344ad
Commit
9d3344ad
authored
Sep 10, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gracefully handle errors in syntax highlighting by leaving the block unformatted
Closes #2433
parent
1c3c3ba5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
CHANGELOG
CHANGELOG
+1
-0
syntax_highlight_filter.rb
lib/gitlab/markdown/syntax_highlight_filter.rb
+4
-0
syntax_highlight_filter_spec.rb
spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb
+22
-0
No files found.
CHANGELOG
View file @
9d3344ad
Please view this file on the master branch, on stable branches it's out of date.
Please view this file on the master branch, on stable branches it's out of date.
v 8.0.0 (unreleased)
v 8.0.0 (unreleased)
- Gracefully handle errors in syntax highlighting by leaving the block unformatted (Stan Hu)
- Fix URL construction for merge requests, issues, notes, and commits for relative URL config (Stan Hu)
- Fix URL construction for merge requests, issues, notes, and commits for relative URL config (Stan Hu)
- Fix emoji URLs in Markdown when relative_url_root is used (Stan Hu)
- Fix emoji URLs in Markdown when relative_url_root is used (Stan Hu)
- Omit filename in Content-Disposition header in raw file download to avoid RFC 6266 encoding issues (Stan HU)
- Omit filename in Content-Disposition header in raw file download to avoid RFC 6266 encoding issues (Stan HU)
...
...
lib/gitlab/markdown/syntax_highlight_filter.rb
View file @
9d3344ad
...
@@ -21,7 +21,11 @@ module Gitlab
...
@@ -21,7 +21,11 @@ module Gitlab
language
=
node
.
attr
(
'class'
)
language
=
node
.
attr
(
'class'
)
code
=
node
.
text
code
=
node
.
text
begin
highlighted
=
block_code
(
code
,
language
)
highlighted
=
block_code
(
code
,
language
)
rescue
highlighted
=
"<pre>
#{
code
}
</pre>"
end
# Replace the parent `pre` element with the entire highlighted block
# Replace the parent `pre` element with the entire highlighted block
node
.
parent
.
replace
(
highlighted
)
node
.
parent
.
replace
(
highlighted
)
...
...
spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb
0 → 100644
View file @
9d3344ad
require
'spec_helper'
module
Gitlab::Markdown
describe
SyntaxHighlightFilter
do
include
FilterSpecHelper
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:reference
)
{
snippet
.
to_reference
}
it
'highlights valid code blocks'
do
result
=
filter
(
'<pre><code>def fun end</code>'
)
expect
(
result
.
to_html
).
to
eq
(
"<pre class=
\"
code highlight js-syntax-highlight plaintext
\"
><code>def fun end</code></pre>
\n
"
)
end
it
'passes through invalid code blocks'
do
allow_any_instance_of
(
SyntaxHighlightFilter
).
to
receive
(
:block_code
).
and_raise
(
StandardError
)
result
=
filter
(
'<pre><code>This is a test</code></pre>'
)
expect
(
result
.
to_html
).
to
eq
(
'<pre>This is a test</pre>'
)
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