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.
var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee', 'coldfusion',
'csharp', 'css', 'diff', 'golang', 'groovy', 'haxe', 'html',
'java', 'javascript', 'json', 'latex', 'less', 'liquid',
'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php', 'powershell',
'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql', 'svg',
'textile', 'text', 'xml', 'xquery', 'yaml' ];
// 'coffeescript' is transformed to 'coffee' for Ace.
var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee',
'coffeescript', 'coldfusion', 'csharp', 'css', 'diff', 'golang',
'groovy', 'haxe', 'html', 'java', 'javascript', 'json', 'latex',
'less', 'liquid', 'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php',
'powershell', 'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql',
'svg', 'textile', 'text', 'xml', 'xquery', 'yaml' ];
var staticHighlight = require( 'ace/ext/static_highlight' );
var githubTheme = require( 'ace/theme/github' );
@@ -303,6 +304,12 @@ var makePreviewHtml = function () {
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 ) {
// Unsupported language.
skipped++;
+2 -2
View File
@@ -558,12 +558,12 @@ module Gollum
encoding ||= 'utf-8'
begin
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
rescue ::RubyPython::PythonError
rescue
hl_code = code
end
highlighted << hl_code
end
@codemap.each do |id, spec|
body = spec[:output] || begin
if (body = highlighted.shift.to_s).size > 0
+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
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