Category talk:OoRexx: Difference between revisions
Content added Content deleted
mNo edit summary |
(→Coloring / Highlighting Rexx code: custom js (temp) solution) |
||
Line 144: | Line 144: | ||
I vote YES for syntax colouring as I've never seen anything else that makes code easier readable and in consequence more comprehensible especially to others. At this level I would describe syntax colouring as a no-brainer. |
I vote YES for syntax colouring as I've never seen anything else that makes code easier readable and in consequence more comprehensible especially to others. At this level I would describe syntax colouring as a no-brainer. |
||
I understand that someone feels no need to use syntax highlighting for himself, but it should be clear that he'll do a favour to others by providing it. --[[User:DMacho|D.Macho]] 11:29, 11 June 2012 (UTC) |
I understand that someone feels no need to use syntax highlighting for himself, but it should be clear that he'll do a favour to others by providing it. --[[User:DMacho|D.Macho]] 11:29, 11 June 2012 (UTC) |
||
I'm not voting, but if color highlight is really undesirable, here's a compromise: go to your RC preference page, select "Appearance", then "custom javascript", edit and add the following:<lang javascript> |
|||
(function(){ |
|||
function get_code_pres() { |
|||
var pres = document.getElementsByTagName('pre'); |
|||
var codes = []; |
|||
for(var i = 0; i < pres.length; i++) |
|||
if(pres[i].className.match(/\bhighlighted_source\b/)) |
|||
codes.push(pres[i]); |
|||
return codes; |
|||
} |
|||
function toggle_highlight(pre) { |
|||
if(pre._alt_html == null) { |
|||
pre._alt_html = pre.innerHTML; |
|||
var spans = pre.getElementsByTagName('span'); |
|||
for (var i = 0; i < spans.length; i++) |
|||
spans[i].className = ''; |
|||
} else { |
|||
var tmp=pre.innerHTML; |
|||
pre.innerHTML=pre._alt_html; |
|||
pre._alt_html=tmp; |
|||
} |
|||
} |
|||
function add_toggle_links(codes) { |
|||
var codes = get_code_pres(); |
|||
for(var i = 0; i < codes.length;i++) { |
|||
var a=document.createElement('a'); |
|||
a.textContent='Toggle syntax highlighting'; |
|||
a.style.cursor = 'pointer'; |
|||
(function(e) { |
|||
a.addEventListener('click', function(){ toggle_highlight(e); }, false); |
|||
e.parentNode.insertBefore(a, e); |
|||
})(codes[i]); |
|||
// uncomment next line to have blocks unhighlighted as soon as page loads |
|||
// toggle_highlight(codes[i]); |
|||
} |
|||
} |
|||
add_toggle_links(); |
|||
})();</lang> which will <s>format your hard drive</s> add a link before each code block to toggle highlights. I only tested it on Firefox, though it should work with other browsers. If you want to used it and find it lacking, let me know. --[[User:Ledrug|Ledrug]] 16:08, 12 June 2012 (UTC) |