Merge pull request #533 from wrs/wrs_syntaxfixes

Two little syntax highlighting fixes
This commit is contained in:
bootstraponline
2012-10-10 16:56:37 -07:00
3 changed files with 23 additions and 8 deletions
@@ -195,12 +195,13 @@ var previewSet = function( text ) {
}; };
// 'c', 'c++', 'cpp' are github specific and transformed to c_cpp for Ace. // 'c', 'c++', 'cpp' are github specific and transformed to c_cpp for Ace.
var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee', 'coldfusion', // 'coffeescript' is transformed to 'coffee' for Ace.
'csharp', 'css', 'diff', 'golang', 'groovy', 'haxe', 'html', var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee',
'java', 'javascript', 'json', 'latex', 'less', 'liquid', 'coffeescript', 'coldfusion', 'csharp', 'css', 'diff', 'golang',
'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php', 'powershell', 'groovy', 'haxe', 'html', 'java', 'javascript', 'json', 'latex',
'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql', 'svg', 'less', 'liquid', 'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php',
'textile', 'text', 'xml', 'xquery', 'yaml' ]; 'powershell', 'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql',
'svg', 'textile', 'text', 'xml', 'xquery', 'yaml' ];
var staticHighlight = require( 'ace/ext/static_highlight' ); var staticHighlight = require( 'ace/ext/static_highlight' );
var githubTheme = require( 'ace/theme/github' ); var githubTheme = require( 'ace/theme/github' );
@@ -303,6 +304,12 @@ var makePreviewHtml = function () {
aceMode = 'c_cpp'; aceMode = 'c_cpp';
} }
// Pygments's name for CoffeeScript is 'coffeescript', but Ace
// calls it 'coffee'.
if ( declaredLanguage === 'coffeescript' ) {
aceMode = 'coffee';
}
if ( $.inArray( declaredLanguage, languages ) === -1 ) { if ( $.inArray( declaredLanguage, languages ) === -1 ) {
// Unsupported language. // Unsupported language.
skipped++; skipped++;
+1 -1
View File
@@ -558,7 +558,7 @@ module Gollum
encoding ||= 'utf-8' encoding ||= 'utf-8'
begin begin
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s}) hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
rescue ::RubyPython::PythonError rescue
hl_code = code hl_code = code
end end
highlighted << hl_code highlighted << hl_code
+8
View File
@@ -534,6 +534,14 @@ np.array([[2,2],[1,3]],np.float)
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\">&lt;p&gt;</span>a\n!rel<span class=\"nt\">&lt;/p&gt;</span>\n</pre></div>\n}, output assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\">&lt;p&gt;</span>a\n!rel<span class=\"nt\">&lt;/p&gt;</span>\n</pre></div>\n}, output
end end
test "code block in unsupported language" do
@wiki.write_page("a", :markdown, "a\n```nonexistent\ncode\n```\nb", commit_details)
page = @wiki.page("a")
output = page.formatted_data
assert_equal %Q{<p>a\ncode\nb</p>}, output
end
######################################################################### #########################################################################
# #
# Web Sequence Diagrams # Web Sequence Diagrams