Feature #24681 » 0001-Replace-syntax-highlighter-CodeRay-with-Rouge.patch
Gemfile | ||
---|---|---|
5 | 5 |
end |
6 | 6 | |
7 | 7 |
gem "rails", "5.2.1" |
8 |
gem "coderay", "~> 1.1.1"
|
|
8 |
gem "rouge", "~> 3.2.1"
|
|
9 | 9 |
gem "request_store", "1.0.5" |
10 | 10 |
gem "mini_mime", "~> 1.0.1" |
11 | 11 |
gem "actionpack-xml_parser" |
lib/redmine/syntax_highlighting.rb | ||
---|---|---|
52 | 52 |
end |
53 | 53 |
end |
54 | 54 | |
55 |
module CodeRay
|
|
56 |
require 'coderay'
|
|
55 |
module Rouge
|
|
56 |
require 'rouge'
|
|
57 | 57 | |
58 |
def self.retrieve_supported_languages |
|
59 |
::CodeRay::Scanners.list + |
|
60 |
# Add CodeRay scanner aliases |
|
61 |
::CodeRay::Scanners.plugin_hash.keys.map(&:to_sym) - |
|
62 |
# Remove internal CodeRay scanners |
|
63 |
%w(debug default raydebug scanner).map(&:to_sym) |
|
64 |
end |
|
65 |
private_class_method :retrieve_supported_languages |
|
58 |
# Customized formatter based on Rouge::Formatters::HTMLLinewise |
|
59 |
# Syntax highlighting is completed within each line. |
|
60 |
class CustomHTMLLinewise < ::Rouge::Formatter |
|
61 |
def initialize(formatter) |
|
62 |
@formatter = formatter |
|
63 |
end |
|
66 | 64 | |
67 |
SUPPORTED_LANGUAGES = retrieve_supported_languages |
|
65 |
def stream(tokens, &b) |
|
66 |
token_lines(tokens) do |line| |
|
67 |
line.each do |tok, val| |
|
68 |
yield @formatter.span(tok, val) |
|
69 |
end |
|
70 |
yield "\n" |
|
71 |
end |
|
72 |
end |
|
73 |
end |
|
68 | 74 | |
69 | 75 |
class << self |
70 | 76 |
# Highlights +text+ as the content of +filename+ |
71 | 77 |
# Should not return line numbers nor outer pre tag |
72 | 78 |
def highlight_by_filename(text, filename) |
73 |
language = ::CodeRay::FileType[filename] |
|
74 |
language ? ::CodeRay.scan(text, language).html(:break_lines => true) : ERB::Util.h(text) |
|
79 |
lexer =::Rouge::Lexer.guess_by_filename(filename) |
|
80 |
formatter = ::Rouge::Formatters::HTML.new |
|
81 |
::Rouge.highlight(text, lexer, CustomHTMLLinewise.new(formatter)) |
|
75 | 82 |
end |
76 | 83 | |
77 | 84 |
# Highlights +text+ using +language+ syntax |
78 | 85 |
# Should not return outer pre tag |
79 | 86 |
def highlight_by_language(text, language) |
80 |
::CodeRay.scan(text, language).html(:wrap => :span) |
|
87 |
lexer = |
|
88 |
find_lexer(language.to_s.downcase) || ::Rouge::Lexers::PlainText |
|
89 |
::Rouge.highlight(text, lexer, ::Rouge::Formatters::HTML) |
|
81 | 90 |
end |
82 | 91 | |
83 | 92 |
def language_supported?(language) |
84 |
SUPPORTED_LANGUAGES.include?(language.to_s.downcase.to_sym) |
|
85 |
rescue |
|
86 |
false |
|
93 |
find_lexer(language.to_s.downcase) ? true : false |
|
94 |
end |
|
95 |
|
|
96 |
private |
|
97 |
# Alias names used by CodeRay and not supported by Rouge |
|
98 |
LANG_ALIASES = { |
|
99 |
'delphi' => 'pascal', |
|
100 |
'cplusplus' => 'cpp', |
|
101 |
'ecmascript' => 'javascript', |
|
102 |
'ecma_script' => 'javascript', |
|
103 |
'java_script' => 'javascript', |
|
104 |
'xhtml' => 'html' |
|
105 |
} |
|
106 | ||
107 |
def find_lexer(language) |
|
108 |
::Rouge::Lexer.find(language) || |
|
109 |
::Rouge::Lexer.find(LANG_ALIASES[language]) |
|
87 | 110 |
end |
88 | 111 |
end |
89 | 112 |
end |
90 | 113 |
end |
91 | 114 | |
92 |
SyntaxHighlighting.highlighter = 'CodeRay'
|
|
115 |
SyntaxHighlighting.highlighter = 'Rouge'
|
|
93 | 116 |
end |
public/javascripts/jstoolbar/jstoolbar-textile.min.js | ||
---|---|---|
1 |
function jsToolBar(e){if(document.createElement&&e&&("undefined"!=typeof document.selection||"undefined"!=typeof e.setSelectionRange)){if(this.textarea=e,this.editor=document.createElement("div"),this.editor.className="jstEditor",this.textarea.parentNode.insertBefore(this.editor,this.textarea),this.editor.appendChild(this.textarea),this.toolbar=document.createElement("div"),this.toolbar.className="jstElements",this.editor.parentNode.insertBefore(this.toolbar,this.editor),this.editor.addEventListener&&navigator.appVersion.match(/\bMSIE\b/)){this.handle=document.createElement("div"),this.handle.className="jstHandle";var t=this.resizeDragStart,n=this;this.handle.addEventListener("mousedown",function(e){t.call(n,e)},!1),window.addEventListener("unload",function(){n.handle.parentNode.removeChild(n.handle);delete n.handle},!1),this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling)}this.context=null,this.toolNodes={}}}function jsButton(e,t,n,o){"undefined"==typeof jsToolBar.strings?this.title=e||null:this.title=jsToolBar.strings[e]||e||null,this.fn=t||function(){},this.scope=n||null,this.className=o||null}function jsSpace(e){this.id=e||null,this.width=null}function jsCombo(e,t,n,o,i){this.title=e||null,this.options=t||null,this.scope=n||null,this.fn=o||function(){},this.className=i||null}jsButton.prototype.draw=function(){if(!this.scope)return null;var e=document.createElement("button");e.setAttribute("type","button"),e.tabIndex=200,this.className&&(e.className=this.className),e.title=this.title;var t=document.createElement("span");if(t.appendChild(document.createTextNode(this.title)),e.appendChild(t),void 0!=this.icon&&(e.style.backgroundImage="url("+this.icon+")"),"function"==typeof this.fn){var n=this;e.onclick=function(){try{n.fn.apply(n.scope,arguments)}catch(e){}return!1}}return e},jsSpace.prototype.draw=function(){var e=document.createElement("span");return this.id&&(e.id=this.id),e.appendChild(document.createTextNode(String.fromCharCode(160))),e.className="jstSpacer",this.width&&(e.style.marginRight=this.width+"px"),e},jsCombo.prototype.draw=function(){if(!this.scope||!this.options)return null;var e=document.createElement("select");this.className&&(e.className=className),e.title=this.title;for(var t in this.options){var n=document.createElement("option");n.value=t,n.appendChild(document.createTextNode(this.options[t])),e.appendChild(n)}var o=this;return e.onchange=function(){try{o.fn.call(o.scope,this.value)}catch(e){alert(e)}return!1},e},jsToolBar.prototype={base_url:"",mode:"wiki",elements:{},help_link:"",getMode:function(){return this.mode},setMode:function(e){this.mode=e||"wiki"},switchMode:function(e){e=e||"wiki",this.draw(e)},setHelpLink:function(e){this.help_link=e},button:function(e){var t=this.elements[e];if("function"!=typeof t.fn[this.mode])return null;var n=new jsButton(t.title,t.fn[this.mode],this,"jstb_"+e);return void 0!=t.icon&&(n.icon=t.icon),n},space:function(e){var t=new jsSpace(e);return void 0!==this.elements[e].width&&(t.width=this.elements[e].width),t},combo:function(e){var t=this.elements[e],n=t[this.mode].list.length;if("function"!=typeof t[this.mode].fn||0==n)return null;for(var o={},i=0;n>i;i++){var s=t[this.mode].list[i];o[s]=t.options[s]}return new jsCombo(t.title,o,this,t[this.mode].fn)},draw:function(e){for(this.setMode(e);this.toolbar.hasChildNodes();)this.toolbar.removeChild(this.toolbar.firstChild);this.toolNodes={};var t,n,o;for(var i in this.elements){t=this.elements[i];var s=void 0==t.type||""==t.type||void 0!=t.disabled&&t.disabled||void 0!=t.context&&null!=t.context&&t.context!=this.context;s||"function"!=typeof this[t.type]||(n=this[t.type](i),n&&(o=n.draw()),o&&(this.toolNodes[i]=o,this.toolbar.appendChild(o)))}},singleTag:function(e,t){e=e||null,t=t||e,e&&t&&this.encloseSelection(e,t)},encloseLineSelection:function(e,t,n){this.textarea.focus(),e=e||"",t=t||"";var o,i,s,l,a,r;if("undefined"!=typeof document.selection?s=document.selection.createRange().text:"undefined"!=typeof this.textarea.setSelectionRange&&(o=this.textarea.selectionStart,i=this.textarea.selectionEnd,l=this.textarea.scrollTop,o=this.textarea.value.substring(0,o).replace(/[^\r\n]*$/g,"").length,i=this.textarea.value.length-this.textarea.value.substring(i,this.textarea.value.length).replace(/^[^\r\n]*/,"").length,s=this.textarea.value.substring(o,i)),s.match(/ $/)&&(s=s.substring(0,s.length-1),t+=" "),r="function"==typeof n?s?n.call(this,s):n(""):s?s:"",a=e+r+t,"undefined"!=typeof document.selection){document.selection.createRange().text=a;var c=this.textarea.createTextRange();c.collapse(!1),c.move("character",-t.length),c.select()}else"undefined"!=typeof this.textarea.setSelectionRange&&(this.textarea.value=this.textarea.value.substring(0,o)+a+this.textarea.value.substring(i),s?this.textarea.setSelectionRange(o+a.length,o+a.length):this.textarea.setSelectionRange(o+e.length,o+e.length),this.textarea.scrollTop=l)},encloseSelection:function(e,t,n){this.textarea.focus(),e=e||"",t=t||"";var o,i,s,l,a,r;if("undefined"!=typeof document.selection?s=document.selection.createRange().text:"undefined"!=typeof this.textarea.setSelectionRange&&(o=this.textarea.selectionStart,i=this.textarea.selectionEnd,l=this.textarea.scrollTop,s=this.textarea.value.substring(o,i),o>0&&this.textarea.value.substr(o-1, 1).match(/\S/)&&(e=" "+e),this.textarea.value.substr(i, 1).match(/\S/)&&(t=t+" ")),s.match(/ $/)&&(s=s.substring(0,s.length-1),t+=" "),r="function"==typeof n?s?n.call(this,s):n(""):s?s:"",a=e+r+t,"undefined"!=typeof document.selection){document.selection.createRange().text=a;var c=this.textarea.createTextRange();c.collapse(!1),c.move("character",-t.length),c.select()}else"undefined"!=typeof this.textarea.setSelectionRange&&(this.textarea.value=this.textarea.value.substring(0,o)+a+this.textarea.value.substring(i),s?this.textarea.setSelectionRange(o+a.length,o+a.length):this.textarea.setSelectionRange(o+e.length,o+e.length),this.textarea.scrollTop=l)},stripBaseURL:function(e){if(""!=this.base_url){var t=e.indexOf(this.base_url);0==t&&(e=e.substr(this.base_url.length))}return e}},jsToolBar.prototype.resizeSetStartH=function(){this.dragStartH=this.textarea.offsetHeight+0},jsToolBar.prototype.resizeDragStart=function(e){var t=this;this.dragStartY=e.clientY,this.resizeSetStartH(),document.addEventListener("mousemove",this.dragMoveHdlr=function(e){t.resizeDragMove(e)},!1),document.addEventListener("mouseup",this.dragStopHdlr=function(e){t.resizeDragStop(e)},!1)},jsToolBar.prototype.resizeDragMove=function(e){this.textarea.style.height=this.dragStartH+e.clientY-this.dragStartY+"px"},jsToolBar.prototype.resizeDragStop=function(e){document.removeEventListener("mousemove",this.dragMoveHdlr,!1),document.removeEventListener("mouseup",this.dragStopHdlr,!1)},jsToolBar.prototype.precodeMenu=function(e){for(var t=["c","clojure","cpp","css","delphi","diff","erb","go","groovy","haml","html","java","javascript","json","lua","php","python","ruby","sass","sql","taskpaper","text","xml","yaml"],n=$("<ul style='position:absolute;'></ul>"),o=0;o<t.length;o++)$("<li></li>").text(t[o]).appendTo(n).mousedown(function(){e($(this).text())});return $("body").append(n),n.menu().width(150).position({my:"left top",at:"left bottom",of:this.toolNodes.precode}),$(document).on("mousedown",function(){n.remove()}),!1},jsToolBar.prototype.elements.strong={type:"button",title:"Strong",fn:{wiki:function(){this.singleTag("*")}}},jsToolBar.prototype.elements.em={type:"button",title:"Italic",fn:{wiki:function(){this.singleTag("_")}}},jsToolBar.prototype.elements.ins={type:"button",title:"Underline",fn:{wiki:function(){this.singleTag("+")}}},jsToolBar.prototype.elements.del={type:"button",title:"Deleted",fn:{wiki:function(){this.singleTag("-")}}},jsToolBar.prototype.elements.code={type:"button",title:"Code",fn:{wiki:function(){this.singleTag("@")}}},jsToolBar.prototype.elements.space1={type:"space"},jsToolBar.prototype.elements.h1={type:"button",title:"Heading 1",fn:{wiki:function(){this.encloseLineSelection("h1. ","",function(e){return e=e.replace(/^h\d+\.\s+/,"")})}}},jsToolBar.prototype.elements.h2={type:"button",title:"Heading 2",fn:{wiki:function(){this.encloseLineSelection("h2. ","",function(e){return e=e.replace(/^h\d+\.\s+/,"")})}}},jsToolBar.prototype.elements.h3={type:"button",title:"Heading 3",fn:{wiki:function(){this.encloseLineSelection("h3. ","",function(e){return e=e.replace(/^h\d+\.\s+/,"")})}}},jsToolBar.prototype.elements.space2={type:"space"},jsToolBar.prototype.elements.ul={type:"button",title:"Unordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^)[#-]?\s*/g,"$1* ")})}}},jsToolBar.prototype.elements.ol={type:"button",title:"Ordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^)[*-]?\s*/g,"$1# ")})}}},jsToolBar.prototype.elements.space3={type:"space"},jsToolBar.prototype.elements.bq={type:"button",title:"Quote",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^) *([^\n]*)/g,"$1> $2")})}}},jsToolBar.prototype.elements.unbq={type:"button",title:"Unquote",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2")})}}},jsToolBar.prototype.elements.pre={type:"button",title:"Preformatted text",fn:{wiki:function(){this.encloseLineSelection("<pre>\n","\n</pre>")}}},jsToolBar.prototype.elements.precode={type:"button",title:"Highlighted code",fn:{wiki:function(){var e=this;this.precodeMenu(function(t){e.encloseLineSelection('<pre><code class="'+t+'">\n',"\n</code></pre>\n")})}}},jsToolBar.prototype.elements.space4={type:"space"},jsToolBar.prototype.elements.link={type:"button",title:"Wiki link",fn:{wiki:function(){this.encloseSelection("[[","]]")}}},jsToolBar.prototype.elements.img={type:"button",title:"Image",fn:{wiki:function(){this.encloseSelection("!","!")}}},jsToolBar.prototype.elements.space5={type:"space"},jsToolBar.prototype.elements.help={type:"button",title:"Help",fn:{wiki:function(){window.open(this.help_link,"","resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes")}}}; |
|
1 |
function jsToolBar(e){if(document.createElement&&e&&("undefined"!=typeof document.selection||"undefined"!=typeof e.setSelectionRange)){if(this.textarea=e,this.editor=document.createElement("div"),this.editor.className="jstEditor",this.textarea.parentNode.insertBefore(this.editor,this.textarea),this.editor.appendChild(this.textarea),this.toolbar=document.createElement("div"),this.toolbar.className="jstElements",this.editor.parentNode.insertBefore(this.toolbar,this.editor),this.editor.addEventListener&&navigator.appVersion.match(/\bMSIE\b/)){this.handle=document.createElement("div"),this.handle.className="jstHandle";var t=this.resizeDragStart,n=this;this.handle.addEventListener("mousedown",function(e){t.call(n,e)},!1),window.addEventListener("unload",function(){n.handle.parentNode.removeChild(n.handle);delete n.handle},!1),this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling)}this.context=null,this.toolNodes={}}}function jsButton(e,t,n,o){"undefined"==typeof jsToolBar.strings?this.title=e||null:this.title=jsToolBar.strings[e]||e||null,this.fn=t||function(){},this.scope=n||null,this.className=o||null}function jsSpace(e){this.id=e||null,this.width=null}function jsCombo(e,t,n,o,i){this.title=e||null,this.options=t||null,this.scope=n||null,this.fn=o||function(){},this.className=i||null}jsButton.prototype.draw=function(){if(!this.scope)return null;var e=document.createElement("button");e.setAttribute("type","button"),e.tabIndex=200,this.className&&(e.className=this.className),e.title=this.title;var t=document.createElement("span");if(t.appendChild(document.createTextNode(this.title)),e.appendChild(t),void 0!=this.icon&&(e.style.backgroundImage="url("+this.icon+")"),"function"==typeof this.fn){var n=this;e.onclick=function(){try{n.fn.apply(n.scope,arguments)}catch(e){}return!1}}return e},jsSpace.prototype.draw=function(){var e=document.createElement("span");return this.id&&(e.id=this.id),e.appendChild(document.createTextNode(String.fromCharCode(160))),e.className="jstSpacer",this.width&&(e.style.marginRight=this.width+"px"),e},jsCombo.prototype.draw=function(){if(!this.scope||!this.options)return null;var e=document.createElement("select");this.className&&(e.className=className),e.title=this.title;for(var t in this.options){var n=document.createElement("option");n.value=t,n.appendChild(document.createTextNode(this.options[t])),e.appendChild(n)}var o=this;return e.onchange=function(){try{o.fn.call(o.scope,this.value)}catch(e){alert(e)}return!1},e},jsToolBar.prototype={base_url:"",mode:"wiki",elements:{},help_link:"",getMode:function(){return this.mode},setMode:function(e){this.mode=e||"wiki"},switchMode:function(e){e=e||"wiki",this.draw(e)},setHelpLink:function(e){this.help_link=e},button:function(e){var t=this.elements[e];if("function"!=typeof t.fn[this.mode])return null;var n=new jsButton(t.title,t.fn[this.mode],this,"jstb_"+e);return void 0!=t.icon&&(n.icon=t.icon),n},space:function(e){var t=new jsSpace(e);return void 0!==this.elements[e].width&&(t.width=this.elements[e].width),t},combo:function(e){var t=this.elements[e],n=t[this.mode].list.length;if("function"!=typeof t[this.mode].fn||0==n)return null;for(var o={},i=0;n>i;i++){var s=t[this.mode].list[i];o[s]=t.options[s]}return new jsCombo(t.title,o,this,t[this.mode].fn)},draw:function(e){for(this.setMode(e);this.toolbar.hasChildNodes();)this.toolbar.removeChild(this.toolbar.firstChild);this.toolNodes={};var t,n,o;for(var i in this.elements){t=this.elements[i];var s=void 0==t.type||""==t.type||void 0!=t.disabled&&t.disabled||void 0!=t.context&&null!=t.context&&t.context!=this.context;s||"function"!=typeof this[t.type]||(n=this[t.type](i),n&&(o=n.draw()),o&&(this.toolNodes[i]=o,this.toolbar.appendChild(o)))}},singleTag:function(e,t){e=e||null,t=t||e,e&&t&&this.encloseSelection(e,t)},encloseLineSelection:function(e,t,n){this.textarea.focus(),e=e||"",t=t||"";var o,i,s,l,a,r;if("undefined"!=typeof document.selection?s=document.selection.createRange().text:"undefined"!=typeof this.textarea.setSelectionRange&&(o=this.textarea.selectionStart,i=this.textarea.selectionEnd,l=this.textarea.scrollTop,o=this.textarea.value.substring(0,o).replace(/[^\r\n]*$/g,"").length,i=this.textarea.value.length-this.textarea.value.substring(i,this.textarea.value.length).replace(/^[^\r\n]*/,"").length,s=this.textarea.value.substring(o,i)),s.match(/ $/)&&(s=s.substring(0,s.length-1),t+=" "),r="function"==typeof n?s?n.call(this,s):n(""):s?s:"",a=e+r+t,"undefined"!=typeof document.selection){document.selection.createRange().text=a;var c=this.textarea.createTextRange();c.collapse(!1),c.move("character",-t.length),c.select()}else"undefined"!=typeof this.textarea.setSelectionRange&&(this.textarea.value=this.textarea.value.substring(0,o)+a+this.textarea.value.substring(i),s?this.textarea.setSelectionRange(o+a.length,o+a.length):this.textarea.setSelectionRange(o+e.length,o+e.length),this.textarea.scrollTop=l)},encloseSelection:function(e,t,n){this.textarea.focus(),e=e||"",t=t||"";var o,i,s,l,a,r;if("undefined"!=typeof document.selection?s=document.selection.createRange().text:"undefined"!=typeof this.textarea.setSelectionRange&&(o=this.textarea.selectionStart,i=this.textarea.selectionEnd,l=this.textarea.scrollTop,s=this.textarea.value.substring(o,i),o>0&&this.textarea.value.substr(o-1, 1).match(/\S/)&&(e=" "+e),this.textarea.value.substr(i, 1).match(/\S/)&&(t=t+" ")),s.match(/ $/)&&(s=s.substring(0,s.length-1),t+=" "),r="function"==typeof n?s?n.call(this,s):n(""):s?s:"",a=e+r+t,"undefined"!=typeof document.selection){document.selection.createRange().text=a;var c=this.textarea.createTextRange();c.collapse(!1),c.move("character",-t.length),c.select()}else"undefined"!=typeof this.textarea.setSelectionRange&&(this.textarea.value=this.textarea.value.substring(0,o)+a+this.textarea.value.substring(i),s?this.textarea.setSelectionRange(o+a.length,o+a.length):this.textarea.setSelectionRange(o+e.length,o+e.length),this.textarea.scrollTop=l)},stripBaseURL:function(e){if(""!=this.base_url){var t=e.indexOf(this.base_url);0==t&&(e=e.substr(this.base_url.length))}return e}},jsToolBar.prototype.resizeSetStartH=function(){this.dragStartH=this.textarea.offsetHeight+0},jsToolBar.prototype.resizeDragStart=function(e){var t=this;this.dragStartY=e.clientY,this.resizeSetStartH(),document.addEventListener("mousemove",this.dragMoveHdlr=function(e){t.resizeDragMove(e)},!1),document.addEventListener("mouseup",this.dragStopHdlr=function(e){t.resizeDragStop(e)},!1)},jsToolBar.prototype.resizeDragMove=function(e){this.textarea.style.height=this.dragStartH+e.clientY-this.dragStartY+"px"},jsToolBar.prototype.resizeDragStop=function(e){document.removeEventListener("mousemove",this.dragMoveHdlr,!1),document.removeEventListener("mouseup",this.dragStopHdlr,!1)},jsToolBar.prototype.precodeMenu=function(e){for(var t=["c","clojure","cpp","css","delphi","diff","erb","go","groovy","haml","html","java","javascript","json","lua","pascal","php","python","ruby","sass","sql","text","xml","yaml"],n=$("<ul style='position:absolute;'></ul>"),o=0;o<t.length;o++)$("<li></li>").text(t[o]).appendTo(n).mousedown(function(){e($(this).text())});return $("body").append(n),n.menu().width(150).position({my:"left top",at:"left bottom",of:this.toolNodes.precode}),$(document).on("mousedown",function(){n.remove()}),!1},jsToolBar.prototype.elements.strong={type:"button",title:"Strong",fn:{wiki:function(){this.singleTag("*")}}},jsToolBar.prototype.elements.em={type:"button",title:"Italic",fn:{wiki:function(){this.singleTag("_")}}},jsToolBar.prototype.elements.ins={type:"button",title:"Underline",fn:{wiki:function(){this.singleTag("+")}}},jsToolBar.prototype.elements.del={type:"button",title:"Deleted",fn:{wiki:function(){this.singleTag("-")}}},jsToolBar.prototype.elements.code={type:"button",title:"Code",fn:{wiki:function(){this.singleTag("@")}}},jsToolBar.prototype.elements.space1={type:"space"},jsToolBar.prototype.elements.h1={type:"button",title:"Heading 1",fn:{wiki:function(){this.encloseLineSelection("h1. ","",function(e){return e=e.replace(/^h\d+\.\s+/,"")})}}},jsToolBar.prototype.elements.h2={type:"button",title:"Heading 2",fn:{wiki:function(){this.encloseLineSelection("h2. ","",function(e){return e=e.replace(/^h\d+\.\s+/,"")})}}},jsToolBar.prototype.elements.h3={type:"button",title:"Heading 3",fn:{wiki:function(){this.encloseLineSelection("h3. ","",function(e){return e=e.replace(/^h\d+\.\s+/,"")})}}},jsToolBar.prototype.elements.space2={type:"space"},jsToolBar.prototype.elements.ul={type:"button",title:"Unordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^)[#-]?\s*/g,"$1* ")})}}},jsToolBar.prototype.elements.ol={type:"button",title:"Ordered list",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^)[*-]?\s*/g,"$1# ")})}}},jsToolBar.prototype.elements.space3={type:"space"},jsToolBar.prototype.elements.bq={type:"button",title:"Quote",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^) *([^\n]*)/g,"$1> $2")})}}},jsToolBar.prototype.elements.unbq={type:"button",title:"Unquote",fn:{wiki:function(){this.encloseLineSelection("","",function(e){return e=e.replace(/\r/g,""),e.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2")})}}},jsToolBar.prototype.elements.pre={type:"button",title:"Preformatted text",fn:{wiki:function(){this.encloseLineSelection("<pre>\n","\n</pre>")}}},jsToolBar.prototype.elements.precode={type:"button",title:"Highlighted code",fn:{wiki:function(){var e=this;this.precodeMenu(function(t){e.encloseLineSelection('<pre><code class="'+t+'">\n',"\n</code></pre>\n")})}}},jsToolBar.prototype.elements.space4={type:"space"},jsToolBar.prototype.elements.link={type:"button",title:"Wiki link",fn:{wiki:function(){this.encloseSelection("[[","]]")}}},jsToolBar.prototype.elements.img={type:"button",title:"Image",fn:{wiki:function(){this.encloseSelection("!","!")}}},jsToolBar.prototype.elements.space5={type:"space"},jsToolBar.prototype.elements.help={type:"button",title:"Help",fn:{wiki:function(){window.open(this.help_link,"","resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes")}}}; |
public/javascripts/jstoolbar/jstoolbar.js | ||
---|---|---|
380 | 380 | |
381 | 381 |
/* Code highlighting menu */ |
382 | 382 |
jsToolBar.prototype.precodeMenu = function(fn){ |
383 |
var codeRayLanguages = ["c", "clojure", "cpp", "css", "delphi", "diff", "erb", "go", "groovy", "haml", "html", "java", "javascript", "json", "lua", "php", "python", "ruby", "sass", "sql", "taskpaper", "text", "xml", "yaml"];
|
|
383 |
var hlLanguages = ["c", "clojure", "cpp", "css", "diff", "erb", "go", "groovy", "haml", "html", "java", "javascript", "json", "lua", "pascal", "php", "python", "ruby", "sass", "sql", "text", "xml", "yaml"];
|
|
384 | 384 |
var menu = $("<ul style='position:absolute;'></ul>"); |
385 |
for (var i = 0; i < codeRayLanguages.length; i++) {
|
|
386 |
$("<li></li>").text(codeRayLanguages[i]).appendTo(menu).mousedown(function(){
|
|
385 |
for (var i = 0; i < hlLanguages.length; i++) {
|
|
386 |
$("<li></li>").text(hlLanguages[i]).appendTo(menu).mousedown(function(){
|
|
387 | 387 |
fn($(this).text()); |
388 | 388 |
}); |
389 | 389 |
} |
public/stylesheets/application.css | ||
---|---|---|
1396 | 1396 |
.ui-datepicker-title select {width:70px !important; margin-top:-2px !important; margin-right:4px !important;} |
1397 | 1397 | |
1398 | 1398 | |
1399 |
/************* CodeRay styles *************/ |
|
1400 |
.syntaxhl div {display: inline;} |
|
1401 |
.syntaxhl .code pre { overflow: auto } |
|
1402 | ||
1403 |
.syntaxhl .annotation { color:#007 } |
|
1404 |
.syntaxhl .attribute-name { color:#b48 } |
|
1405 |
.syntaxhl .attribute-value { color:#700 } |
|
1406 |
.syntaxhl .binary { color:#549 } |
|
1407 |
.syntaxhl .binary .char { color:#325 } |
|
1408 |
.syntaxhl .binary .delimiter { color:#325 } |
|
1409 |
.syntaxhl .char { color:#D20 } |
|
1410 |
.syntaxhl .char .content { color:#D20 } |
|
1411 |
.syntaxhl .char .delimiter { color:#710 } |
|
1412 |
.syntaxhl .class { color:#B06; font-weight:bold } |
|
1413 |
.syntaxhl .class-variable { color:#369 } |
|
1414 |
.syntaxhl .color { color:#0A0 } |
|
1415 |
.syntaxhl .comment { color:#777 } |
|
1416 |
.syntaxhl .comment .char { color:#444 } |
|
1417 |
.syntaxhl .comment .delimiter { color:#444 } |
|
1418 |
.syntaxhl .constant { color:#036; font-weight:bold } |
|
1419 |
.syntaxhl .decorator { color:#B0B } |
|
1420 |
.syntaxhl .definition { color:#099; font-weight:bold } |
|
1421 |
.syntaxhl .delimiter { color:black } |
|
1422 |
.syntaxhl .directive { color:#088; font-weight:bold } |
|
1423 |
.syntaxhl .docstring { color:#D42; } |
|
1424 |
.syntaxhl .doctype { color:#34b } |
|
1425 |
.syntaxhl .done { text-decoration: line-through; color: gray } |
|
1426 |
.syntaxhl .entity { color:#800; font-weight:bold } |
|
1427 |
.syntaxhl .error { color:#F00; background-color:#FAA } |
|
1428 |
.syntaxhl .escape { color:#666 } |
|
1429 |
.syntaxhl .exception { color:#C00; font-weight:bold } |
|
1430 |
.syntaxhl .float { color:#60E } |
|
1431 |
.syntaxhl .function { color:#06B; font-weight:bold } |
|
1432 |
.syntaxhl .function .delimiter { color:#059 } |
|
1433 |
.syntaxhl .function .content { color:#037 } |
|
1434 |
.syntaxhl .global-variable { color:#d70 } |
|
1435 |
.syntaxhl .hex { color:#02b } |
|
1436 |
.syntaxhl .id { color:#33D; font-weight:bold } |
|
1437 |
.syntaxhl .include { color:#B44; font-weight:bold } |
|
1438 |
.syntaxhl .inline { background-color: hsla(0,0%,0%,0.07); color: black } |
|
1439 |
.syntaxhl .inline-delimiter { font-weight: bold; color: #666 } |
|
1440 |
.syntaxhl .instance-variable { color:#33B } |
|
1441 |
.syntaxhl .integer { color:#00D } |
|
1442 |
.syntaxhl .imaginary { color:#f00 } |
|
1443 |
.syntaxhl .important { color:#D00 } |
|
1444 |
.syntaxhl .key { color: #606 } |
|
1445 |
.syntaxhl .key .char { color: #60f } |
|
1446 |
.syntaxhl .key .delimiter { color: #404 } |
|
1447 |
.syntaxhl .keyword { color:#080; font-weight:bold } |
|
1448 |
.syntaxhl .label { color:#970; font-weight:bold } |
|
1449 |
.syntaxhl .local-variable { color:#950 } |
|
1450 |
.syntaxhl .map .content { color:#808 } |
|
1451 |
.syntaxhl .map .delimiter { color:#40A} |
|
1452 |
.syntaxhl .map { background-color:hsla(200,100%,50%,0.06); } |
|
1453 |
.syntaxhl .namespace { color:#707; font-weight:bold } |
|
1454 |
.syntaxhl .octal { color:#40E } |
|
1455 |
.syntaxhl .operator { } |
|
1456 |
.syntaxhl .predefined { color:#369; font-weight:bold } |
|
1457 |
.syntaxhl .predefined-constant { color:#069 } |
|
1458 |
.syntaxhl .predefined-type { color:#0a8; font-weight:bold } |
|
1459 |
.syntaxhl .preprocessor { color:#579 } |
|
1460 |
.syntaxhl .pseudo-class { color:#00C; font-weight:bold } |
|
1461 |
.syntaxhl .regexp { background-color:hsla(300,100%,50%,0.06); } |
|
1462 |
.syntaxhl .regexp .content { color:#808 } |
|
1463 |
.syntaxhl .regexp .delimiter { color:#404 } |
|
1464 |
.syntaxhl .regexp .modifier { color:#C2C } |
|
1465 |
.syntaxhl .reserved { color:#080; font-weight:bold } |
|
1466 |
.syntaxhl .shell { background-color:hsla(120,100%,50%,0.06); } |
|
1467 |
.syntaxhl .shell .content { color:#2B2 } |
|
1468 |
.syntaxhl .shell .delimiter { color:#161 } |
|
1469 |
.syntaxhl .string { background-color:hsla(0,100%,50%,0.05); } |
|
1470 |
.syntaxhl .string .char { color: #b0b } |
|
1471 |
.syntaxhl .string .content { color: #D20 } |
|
1472 |
.syntaxhl .string .delimiter { color: #710 } |
|
1473 |
.syntaxhl .string .modifier { color: #E40 } |
|
1474 |
.syntaxhl .symbol { color:#A60 } |
|
1475 |
.syntaxhl .symbol .content { color:#A60 } |
|
1476 |
.syntaxhl .symbol .delimiter { color:#740 } |
|
1477 |
.syntaxhl .tag { color:#070; font-weight:bold } |
|
1478 |
.syntaxhl .type { color:#339; font-weight:bold } |
|
1479 |
.syntaxhl .value { color: #088 } |
|
1480 |
.syntaxhl .variable { color:#037 } |
|
1481 | ||
1482 |
.syntaxhl .insert { background: hsla(120,100%,50%,0.12) } |
|
1483 |
.syntaxhl .delete { background: hsla(0,100%,50%,0.12) } |
|
1484 |
.syntaxhl .change { color: #bbf; background: #007 } |
|
1485 |
.syntaxhl .head { color: #f8f; background: #505 } |
|
1486 |
.syntaxhl .head .filename { color: white; } |
|
1487 | ||
1488 |
.syntaxhl .delete .eyecatcher { background-color: hsla(0,100%,50%,0.2); border: 1px solid hsla(0,100%,45%,0.5); margin: -1px; border-bottom: none; border-top-left-radius: 5px; border-top-right-radius: 5px; } |
|
1489 |
.syntaxhl .insert .eyecatcher { background-color: hsla(120,100%,50%,0.2); border: 1px solid hsla(120,100%,25%,0.5); margin: -1px; border-top: none; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; } |
|
1490 | ||
1491 |
.syntaxhl .insert .insert { color: #0c0; background:transparent; font-weight:bold } |
|
1492 |
.syntaxhl .delete .delete { color: #c00; background:transparent; font-weight:bold } |
|
1493 |
.syntaxhl .change .change { color: #88f } |
|
1494 |
.syntaxhl .head .head { color: #f4f } |
|
1399 |
/************* Rouge styles *************/ |
|
1400 |
/* generated by: pygmentize -f html -a .syntaxhl -S colorful */ |
|
1401 |
.syntaxhl .hll { background-color: #ffffcc } |
|
1402 |
.syntaxhl { background: #fafafa; } |
|
1403 |
.syntaxhl .c { color: #888888 } /* Comment */ |
|
1404 |
.syntaxhl .err { color: #FF0000; background-color: #FFAAAA } /* Error */ |
|
1405 |
.syntaxhl .k { color: #008800; font-weight: bold } /* Keyword */ |
|
1406 |
.syntaxhl .o { color: #333333 } /* Operator */ |
|
1407 |
.syntaxhl .ch { color: #888888 } /* Comment.Hashbang */ |
|
1408 |
.syntaxhl .cm { color: #888888 } /* Comment.Multiline */ |
|
1409 |
.syntaxhl .cp { color: #557799 } /* Comment.Preproc */ |
|
1410 |
.syntaxhl .cpf { color: #888888 } /* Comment.PreprocFile */ |
|
1411 |
.syntaxhl .c1 { color: #888888 } /* Comment.Single */ |
|
1412 |
.syntaxhl .cs { color: #cc0000; font-weight: bold } /* Comment.Special */ |
|
1413 |
.syntaxhl .gd { color: #A00000 } /* Generic.Deleted */ |
|
1414 |
.syntaxhl .ge { font-style: italic } /* Generic.Emph */ |
|
1415 |
.syntaxhl .gr { color: #FF0000 } /* Generic.Error */ |
|
1416 |
.syntaxhl .gh { color: #000080; font-weight: bold } /* Generic.Heading */ |
|
1417 |
.syntaxhl .gi { color: #00A000 } /* Generic.Inserted */ |
|
1418 |
.syntaxhl .go { color: #888888 } /* Generic.Output */ |
|
1419 |
.syntaxhl .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ |
|
1420 |
.syntaxhl .gs { font-weight: bold } /* Generic.Strong */ |
|
1421 |
.syntaxhl .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ |
|
1422 |
.syntaxhl .gt { color: #0044DD } /* Generic.Traceback */ |
|
1423 |
.syntaxhl .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ |
|
1424 |
.syntaxhl .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ |
|
1425 |
.syntaxhl .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ |
|
1426 |
.syntaxhl .kp { color: #003388; font-weight: bold } /* Keyword.Pseudo */ |
|
1427 |
.syntaxhl .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ |
|
1428 |
.syntaxhl .kt { color: #333399; font-weight: bold } /* Keyword.Type */ |
|
1429 |
.syntaxhl .m { color: #6600EE; font-weight: bold } /* Literal.Number */ |
|
1430 |
.syntaxhl .s { background-color: #fff0f0 } /* Literal.String */ |
|
1431 |
.syntaxhl .na { color: #0000CC } /* Name.Attribute */ |
|
1432 |
.syntaxhl .nb { color: #007020 } /* Name.Builtin */ |
|
1433 |
.syntaxhl .nc { color: #BB0066; font-weight: bold } /* Name.Class */ |
|
1434 |
.syntaxhl .no { color: #003366; font-weight: bold } /* Name.Constant */ |
|
1435 |
.syntaxhl .nd { color: #555555; font-weight: bold } /* Name.Decorator */ |
|
1436 |
.syntaxhl .ni { color: #880000; font-weight: bold } /* Name.Entity */ |
|
1437 |
.syntaxhl .ne { color: #FF0000; font-weight: bold } /* Name.Exception */ |
|
1438 |
.syntaxhl .nf { color: #0066BB; font-weight: bold } /* Name.Function */ |
|
1439 |
.syntaxhl .nl { color: #997700; font-weight: bold } /* Name.Label */ |
|
1440 |
.syntaxhl .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ |
|
1441 |
.syntaxhl .nt { color: #007700 } /* Name.Tag */ |
|
1442 |
.syntaxhl .nv { color: #996633 } /* Name.Variable */ |
|
1443 |
.syntaxhl .ow { color: #000000; font-weight: bold } /* Operator.Word */ |
|
1444 |
.syntaxhl .w { color: #bbbbbb } /* Text.Whitespace */ |
|
1445 |
.syntaxhl .mb { color: #6600EE; font-weight: bold } /* Literal.Number.Bin */ |
|
1446 |
.syntaxhl .mf { color: #6600EE; font-weight: bold } /* Literal.Number.Float */ |
|
1447 |
.syntaxhl .mh { color: #005588; font-weight: bold } /* Literal.Number.Hex */ |
|
1448 |
.syntaxhl .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ |
|
1449 |
.syntaxhl .mo { color: #4400EE; font-weight: bold } /* Literal.Number.Oct */ |
|
1450 |
.syntaxhl .sa { background-color: #fff0f0 } /* Literal.String.Affix */ |
|
1451 |
.syntaxhl .sb { background-color: #fff0f0 } /* Literal.String.Backtick */ |
|
1452 |
.syntaxhl .sc { color: #0044DD } /* Literal.String.Char */ |
|
1453 |
.syntaxhl .dl { background-color: #fff0f0 } /* Literal.String.Delimiter */ |
|
1454 |
.syntaxhl .sd { color: #DD4422 } /* Literal.String.Doc */ |
|
1455 |
.syntaxhl .s2 { background-color: #fff0f0 } /* Literal.String.Double */ |
|
1456 |
.syntaxhl .se { color: #666666; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */ |
|
1457 |
.syntaxhl .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */ |
|
1458 |
.syntaxhl .si { background-color: #eeeeee } /* Literal.String.Interpol */ |
|
1459 |
.syntaxhl .sx { color: #DD2200; background-color: #fff0f0 } /* Literal.String.Other */ |
|
1460 |
.syntaxhl .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */ |
|
1461 |
.syntaxhl .s1 { background-color: #fff0f0 } /* Literal.String.Single */ |
|
1462 |
.syntaxhl .ss { color: #AA6600 } /* Literal.String.Symbol */ |
|
1463 |
.syntaxhl .bp { color: #007020 } /* Name.Builtin.Pseudo */ |
|
1464 |
.syntaxhl .fm { color: #0066BB; font-weight: bold } /* Name.Function.Magic */ |
|
1465 |
.syntaxhl .vc { color: #336699 } /* Name.Variable.Class */ |
|
1466 |
.syntaxhl .vg { color: #dd7700; font-weight: bold } /* Name.Variable.Global */ |
|
1467 |
.syntaxhl .vi { color: #3333BB } /* Name.Variable.Instance */ |
|
1468 |
.syntaxhl .vm { color: #996633 } /* Name.Variable.Magic */ |
|
1469 |
.syntaxhl .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ |
|
1495 | 1470 | |
1496 | 1471 |
/***** Media print specific styles *****/ |
1497 | 1472 |
@media print { |
public/stylesheets/rtl.css | ||
---|---|---|
373 | 373 |
/* Custom JQuery styles */ |
374 | 374 |
.ui-datepicker-title select {margin-left:4px !important; margin-right:0 !important;} |
375 | 375 | |
376 |
/************* CodeRay styles *************/ |
|
377 |
.syntaxhl .line-numbers {margin:0px 0px 0px 5px;} |
|
378 | ||
379 | 376 |
/***** Media print specific styles *****/ |
380 | 377 |
@media print { |
381 | 378 |
} |
test/helpers/application_helper_test.rb | ||
---|---|---|
1062 | 1062 | |
1063 | 1063 |
def test_syntax_highlight |
1064 | 1064 |
raw = <<-RAW |
1065 |
<pre><code class="ruby"> |
|
1066 |
# Some ruby code here |
|
1065 |
<pre><code class="ECMA_script"> |
|
1066 |
/* Hello */ |
|
1067 |
document.write("Hello World!"); |
|
1067 | 1068 |
</code></pre> |
1068 | 1069 |
RAW |
1069 | 1070 | |
1070 | 1071 |
expected = <<-EXPECTED |
1071 |
<pre><code class="ruby syntaxhl"><span class=\"CodeRay\"><span class="comment"># Some ruby code here</span></span> |
|
1072 |
</code></pre> |
|
1072 |
<pre><code class=\"ECMA_script syntaxhl\"><span class=\"cm\">/* Hello */</span><span class=\"nb\">document</span><span class=\"p\">.</span><span class=\"nx\">write</span><span class=\"p\">(</span><span class=\"s2\">\"Hello World!\"</span><span class=\"p\">);</span></code></pre> |
|
1073 | 1073 |
EXPECTED |
1074 | 1074 | |
1075 | 1075 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '') |
test/unit/lib/redmine/syntax_highlighting/coderay_test.rb | ||
---|---|---|
1 |
# Redmine - project management software |
|
2 |
# Copyright (C) 2006-2017 Jean-Philippe Lang |
|
3 |
# |
|
4 |
# This program is free software; you can redistribute it and/or |
|
5 |
# modify it under the terms of the GNU General Public License |
|
6 |
# as published by the Free Software Foundation; either version 2 |
|
7 |
# of the License, or (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program; if not, write to the Free Software |
|
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | ||
18 |
require File.expand_path('../../../../../test_helper', __FILE__) |
|
19 | ||
20 |
class Redmine::SyntaxHighlighting::CodeRayTest < ActiveSupport::TestCase |
|
21 |
def test_retrieve_supported_languages_should_return_array_of_symbols |
|
22 |
assert_kind_of Array, Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages) |
|
23 |
assert_kind_of Symbol, Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages).first |
|
24 |
end |
|
25 | ||
26 |
def test_retrieve_supported_languages_should_return_array_of_symbols_holding_languages |
|
27 |
assert_includes Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages), :ruby |
|
28 |
end |
|
29 | ||
30 |
def test_retrieve_supported_languages_should_return_array_of_symbols_holding_languages_aliases |
|
31 |
assert_includes Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages), :javascript |
|
32 |
end |
|
33 | ||
34 |
def test_retrieve_supported_languages_should_return_array_of_symbols_not_holding_internal_languages |
|
35 |
refute_includes Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages), :default |
|
36 |
end |
|
37 |
end |
test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb | ||
---|---|---|
66 | 66 |
~~~ |
67 | 67 |
STR |
68 | 68 |
assert_select_in @formatter.new(text).to_html, 'pre code.ruby.syntaxhl' do |
69 |
assert_select 'span.keyword', :text => 'def'
|
|
69 |
assert_select 'span.k', :text => 'def' |
|
70 | 70 |
end |
71 | 71 |
end |
72 | 72 |
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb | ||
---|---|---|
547 | 547 | |
548 | 548 |
def test_should_allow_valid_language_class_attribute_on_code_tags |
549 | 549 |
# language name is double-quoted |
550 |
assert_html_output({"<code class=\"ruby\">test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
|
|
550 |
assert_html_output({"<code class=\"ruby\">test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"nb\">test</span></code>"}, false)
|
|
551 | 551 |
# language name is single-quoted |
552 |
assert_html_output({"<code class='ruby'>test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
|
|
552 |
assert_html_output({"<code class='ruby'>test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"nb\">test</span></code>"}, false)
|
|
553 | 553 |
end |
554 | 554 | |
555 | 555 |
def test_should_not_allow_valid_language_class_attribute_on_non_code_offtags |