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
Jérome Perrin
gitlab-ce
Commits
362d7fde
Commit
362d7fde
authored
Jun 16, 2016
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: don't error in css_classes
parent
e9f19190
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
lib/banzai/filter/syntax_highlight_filter.rb
lib/banzai/filter/syntax_highlight_filter.rb
+8
-5
No files found.
lib/banzai/filter/syntax_highlight_filter.rb
View file @
362d7fde
...
...
@@ -19,8 +19,15 @@ module Banzai
language
=
node
.
attr
(
'class'
)
code
=
node
.
text
lexer
=
Rouge
::
Lexer
.
find_fancy
(
language
)
formatter
=
Rouge
::
Formatters
::
HTML
.
new
css_classes
=
"code highlight js-syntax-highlight
#{
lexer
.
tag
}
"
begin
highlighted
=
%<<pre class="#{css_classes}"><code>#{block_code(code, language)}</code></pre>>
highlighted
=
''
highlighted
<<
%<<pre class="#{css_classes}"><code>>
highlighted
<<
formatter
.
format
(
lexer
.
lex
(
code
))
highlighted
<<
%<</code></pre>>
rescue
# Gracefully handle syntax highlighter bugs/errors to ensure
# users can still access an issue/comment/etc.
...
...
@@ -31,10 +38,6 @@ module Banzai
replace_parent_pre_element
(
node
,
highlighted
)
end
def
css_classes
"code highlight js-syntax-highlight
#{
lexer
.
tag
}
"
end
private
def
replace_parent_pre_element
(
node
,
highlighted
)
...
...
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