dir=q->key<key;preresultlistener =N*r/pre;

wenniuwuren
阅读(7845)
&当后台获取到前台传来的文件时(例如上传功能, 导入功能), 返回类型为application/json, 这个时候响应到前端的JSON格式的数据格式可能是:
&pre style=&word-wrap: break- white-space: pre-&&{&JsonKey&:&JsonValue&}&/pre&
这个是不同浏览器对返回数据处理的问题。
解决方法:
& 1. 在前端解决
var reg = /&pre.+?&(.+)&\/pre&/g;
var result = data.match(reg);
data = RegExp.$1;data就是后台返回前端的数据, 用正则表达式处理一下即可。
& 2. 在后台解决
将返回的类型从application/json改为text/html
这个解决方法因为每个系统后台采用Struts或者SpringMVC不同可能处理有点不一样在此就不举例了。
阅读排行榜/ jeesite_chen
项目语言:JAVA
权限:read-only(如需更高权限请先加入项目)
jeesite_chen/
Index: demo.js
===================================================================
--- demo.js (revision 0)
+++ demo.js (revision 2)
@@ -0,0 +1,301 @@
+/* jBox 测试代码开始 */
+var skin2 =
+$(function () {
changeSkin();
$(window).scroll(function () { $('.sel-skin').css({ top: $(window).scrollTop() + 300 }); });
+function viewConfig(name) {
var height = name == 'defaults' ? 500 : 'auto';
jBox.open('id:' + name, '$.jBox.' + name, 'auto', height, { top: '50px', loaded: function () {
$('.jbox-content').css('background-color', '#eeeeee').find('pre').css('border', 'none')
+function changeSkin(show) {
var skin = $('#select-skin').val().split('|');
document.getElementById('skin').href = &../Skins& + (skin2 == true ? &2& : &&) + &/& + skin[0] + &/jbox.css&;
$('.sel-skin').css('background-color', skin[1]);
if (show) {
$.jBox.tip('换肤成功,当前皮肤:' + skin[0], 'success');
+function show_jbox_set_defaults() {
$.(&请自行在 jBox/i18n/ 目录下修改相应js文件。&);
+function show_jbox_set_border(val) {
$.jBox.setDefaults({ defaults: { border: val} }); // 只修改全局 border
$.('边框已设置为 ' + val);
+function demo_1_1() {
$.('jQuery jBox&br /&&br /&版本:v2.0&br /&日期:&br /&官网:&a target=&_blank& href=&/jbox&&/jbox&/a&');
+function demo_1_2() {
$.jBox('id:id-html', { bottomText: '这是底部文字' });
+function demo_1_3() {
$.jBox(&get:ajax.html&);
+function demo_1_4() {
$.jBox(&iframe:&, {
title: &百度一下&,
width: 800,
height: 350,
buttons: { '关闭': true }
+function demo_1_5() {
var content = {
content: '状态一',
buttons: { '下一步': 1, '取消': 0 },
buttonsFocus: 0,
submit: function (v, h, f) {
if (v == 0) {
// close the window
$.jBox.nextState(); //go forward
// 或 $.jBox.goToState('state2')
content: '状态二,请关闭窗口哇:)',
buttons: { '上一步': 1, '取消': 0 },
buttonsFocus: 0,
submit: function (v, h, f) {
if (v == 0) {
// close the window
$.jBox.prevState() //go back
// 或 $.jBox.goToState('state1');
$.jBox(content);
+function demo_1_6() {
var html = &&div style='padding:10'&输入姓名:&input type='text' id='yourname' name='yourname' /&&/div&&;
var submit = function (v, h, f) {
if (f.yourname == '') {
$.jBox.tip(&请输入您的姓名。&, 'error', { focusId: &yourname& }); // 关闭设置 yourname 为焦点
$.jBox.tip(&你叫:& + f.yourname);
//$.jBox.tip(&你叫:& + h.find(&#yourname&).val());
//$.jBox.tip(&你叫:& + h.find(&:input[name='yourname']&).val());
$.jBox(html, { title: &你叫什么名字?&, submit: submit });
+function demo_2_1() {
$.jBox.open(&iframe:&, &百度一下&, 800, 350, { buttons: { '关闭': true} });
+function demo_2_2() {
var html1 = '&div class=&msg-div&&' +
'&p&购买数量:&/p&&div class=&field&&&input type=&text& id=&amount& name=&amount& style=&width:75& value=&1& /&&/div&' +
'&p&收货地址:&/p&&div class=&field&&&textarea id=&address& name=&address&&&/textarea&&/div&' +
'&div class=&errorBlock& style=&display:&&&/div&' +
'&/div&';
var html2 = '&div class=&msg-div&&' +
'&p&给卖家留言:&span style=&color:gray&&(选填,可以告诉卖家您对商品的特殊要求)&/span&&/p&&div class=&field&&&textarea id=&message& name=&message&&&/textarea&&/div&' +
'&/div&';
var data = {};
var states = {};
states.state1 = {
content: html1,
buttons: { '下一步': 1, '取消': 0 },
submit: function (v, h, f) {
if (v == 0) {
// close the window
h.find('.errorBlock').hide('fast', function () { $(this).remove(); });
data.amount = f. //或 h.find('#amount').val();
if (data.amount == '' || parseInt(data.amount) & 1) {
$('&div class=&errorBlock& style=&display:&&请输入购买数量!&/div&').prependTo(h).show('fast');
data.address = f.
if (data.address == '') {
$('&div class=&errorBlock& style=&display:&&请输入收货地址!&/div&').prependTo(h).show('fast');
$.jBox.nextState(); //go forward
// 或 $.jBox.goToState('state2')
states.state2 = {
content: html2,
buttons: { '上一步': -1, '提交': 1, '取消': 0 },
buttonsFocus: 1, // focus on the second button
submit: function (v, o, f) {
if (v == 0) {
// close the window
} else if (v == -1) {
$.jBox.prevState() //go back
// 或 $.jBox.goToState('state1');
data.message = f.
// do ajax request here
$.jBox.nextState('&div class=&msg-div&&正在提交...&/div&');
// 或 $.jBox.goToState('state3', '&div class=&msg-div&&正在提交...&/div&')
// asume that the ajax is done, than show the result
var msg = [];
msg.push('&div class=&msg-div&&');
msg.push('&p&下面是提交的数据&/p&');
for (var p in data) {
msg.push('&p&' + p + ':' + data[p] + '&/p&');
msg.push('&/div&');
window.setTimeout(function () { $.jBox.nextState(msg.join('')); }, 2000);
states.state3 = {
content: '',
buttons: {} // no buttons
states.state4 = {
content: '',
buttons: { '确定': 0 }
$.jBox.open(states, '提交订单', 450, 'auto');
+function demo_3_1() {
//加了个其它参数closed
$.jBox.prompt('Hello jBox', 'jBox', 'info', { closed: function () { alert('prompt is closed.'); } });
+function demo_3_2() {
$.jBox.alert('Hello jBox', 'jBox');
+function demo_3_3() {
$.('Hello jBox', 'jBox');
+function demo_3_4() {
$.jBox.success('Hello jBox', 'jBox');
+function demo_3_5() {
$.jBox.error('Hello jBox', 'jBox');
+function demo_3_6() {
var submit = function (v, h, f) {
if (v == 'ok')
jBox.tip(v, 'info');
else if (v == 'cancel')
jBox.tip(v, 'info');
$.jBox.confirm(&确定吗?&, &提示&, submit);
+function demo_3_6_2() {
var submit = function (v, h, f) {
if (v == true)
jBox.tip(&恩&, 'info');
jBox.tip(&好吖&, 'info');
// 自定义按钮
$.jBox.confirm(&天使,做我女朋友吧?&, &表白提示&, submit, { buttons: { '恩': true, '好吖': false} });
+function demo_3_7() {
var submit = function (v, h, f) {
if (v == 'yes') {
$.jBox.tip('已保存。', 'success');
if (v == 'no') {
$.jBox.tip('没保存。');
if (v == 'cancel') {
$.jBox.tip('已取消。');
// 可根据需求仿上例子定义按钮
$.jBox.warning(&内容已修改,是否保存?&, &提示&, submit);
+function demo_4_1() {
$.jBox.tip('Hello jBox');
+function demo_4_2() {
//加了个其它参数focusId
$.jBox.tip('关闭后设置输入框为焦点', 'info', { focusId: 'tip-input' });
+function demo_4_3() {
//加了个其它参数closed
$.jBox.tip('关闭后设置输入框为已选', 'error', { closed: function () { $('#tip-input2').select(); } });
+function demo_4_4() {
$.jBox.tip(&正在XX,你懂的...&, 'loading');
// 模拟2秒后完成操作
window.setTimeout(function () { $.jBox.tip('XX已完成。', 'success'); }, 2000);
+function demo_4_5() {
var submit = function (v, h, f) {
if (v == 'ok') {
$.jBox.tip(&正在删除数据...&, 'loading');
// 模拟2秒后完成操作
window.setTimeout(function () { $.jBox.tip('删除成功。', 'success'); }, 2000);
else if (v == 'cancel') {
$.jBox.confirm(&确定要删除数据吗?&, &提示&, submit);
+function demo_5_1() {
$.jBox.messager('Hello jBox', 'jBox');
+function demo_5_2() {
$.jBox.messager(&Hello jBox 2&, &my title&, null, { width: 350, showType: 'fade' });
+function demo_5_3() {
$.jBox.messager(&Hello jBox 3&, &my title&, 3000, {
width: 350,
icon: 'info',
showType: 'show',
buttons: { '去看看': true },
submit: function (v, h, f) {
$.('看个蛋蛋?');
Index: jbox.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: jbox.png
===================================================================
--- jbox.png (revision 0)
+++ jbox.png (revision 2)
Property changes on: jbox.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: highlight/highlight.pack.js
===================================================================
--- highlight/highlight.pack.js (revision 0)
+++ highlight/highlight.pack.js (revision 2)
@@ -0,0 +1,5 @@
+Syntax highlighting with language autodetection.
+http://softwaremaniacs.org/soft/highlight/
+var hljs=new function(){var LANGUAGES={};var selected_languages={};function escape(value){return value.replace(/&/gm,'&').replace(/&/gm,'&').replace(/&/gm,'&')};function contains(array,item){if(!array)for(var i=0;i&array.i++)if(array[i]==item)return false};function langRe(language,value,global){var mode='m'+(language.case_insensitive?'i':'')+(global?'g':'');return new RegExp(value,mode)};function findCode(pre){for(var i=0;i&pre.childNodes.i++){node=pre.childNodes[i];if(node.nodeName=='CODE')if(!(node.nodeType==3&&node.nodeValue.match(/\s+/)))return null}};function blockText(block){var result='';for(var i=0;i&block.childNodes.i++)if(block.childNodes[i].nodeType==3)result+=block.childNodes[i].nodeVelse if(block.childNodes[i].nodeName=='BR')result+='\n';else result+=blockText(block.childNodes[i]);return result};function blockLanguage(block){var classes=block.className.split(/\s+/);classes=classes.concat(block.parentNode.className.split(/\s+/));for(var i=0;i&classes.i++){var class_=classes[i].replace(/^language-/,'');if(class_=='no-highlight'){throw'No highlight'};if(LANGUAGES[class_]){return class_}}};function nodeStream(node){var result=[];(function(node,offset){for(var i=0;i&node.childNodes.i++){if(node.childNodes[i].nodeType==3)offset+=node.childNodes[i].nodeValue.else if(node.childNodes[i].nodeName=='BR')offset+=1;else{result.push({event:'start',offset:offset,node:node.childNodes[i]});offset=arguments.callee(node.childNodes[i],offset);result.push({event:'stop',offset:offset,node:node.childNodes[i]})}};return offset})(node,0);return result};function mergeStreams(stream1,stream2,value){var processed=0;var result='';var nodeStack=[];function selectStream(){if(stream1.length&&stream2.length){if(stream1[0].offset!=stream2[0].offset)return(stream1[0].offset&stream2[0].offset)?stream1:stream2;else return(stream1[0].event=='start'&&stream2[0].event=='stop')?stream2:stream1}else{return stream1.length?stream1:stream2}};function open(node){var result='&'+node.nodeName.toLowerCase();for(var i=0;i&node.attributes.i++){var attribute=node.attributes[i];result+=' '+attribute.nodeName.toLowerCase();if(attribute.nodeValue!=undefined){result+='=&'+escape(attribute.nodeValue)+'&'}};return result+'&'};function close(node){return'&/'+node.nodeName.toLowerCase()+'&'};while(stream1.length||stream2.length){var current=selectStream().splice(0,1)[0];result+=escape(value.substr(processed,current.offset-processed));processed=current.if(current.event=='start'){result+=open(current.node);nodeStack.push(current.node)}else if(current.event=='stop'){var i=nodeStack.do{i--;var node=nodeStack[i];result+=close(node)}while(node!=current.node);nodeStack.splice(i,1);while(i&nodeStack.length){result+=open(nodeStack[i]);i++}}};result+=value.substr(processed);return result};function highlight(language_name,value){function compileSubModes(mode,language){mode.sub_modes=[];for(var i=0;i&mode.contains.i++){for(var j=0;j&language.modes.j++){if(language.modes[j].className==mode.contains[i]){mode.sub_modes[mode.sub_modes.length]=language.modes[j]}}}};function subMode(lexem,mode){if(!mode.contains){return null};if(!mode.sub_modes){compileSubModes(mode,language)};for(var i=0;i&mode.sub_modes.i++){if(mode.sub_modes[i].beginRe.test(lexem)){return mode.sub_modes[i]}};return null};function endOfMode(mode_index,lexem){if(modes[mode_index].end&&modes[mode_index].endRe.test(lexem))return 1;if(modes[mode_index].endsWithParent){var level=endOfMode(mode_index-1,lexem);return level?level+1:0};return 0};function isIllegal(lexem,mode){return mode.illegalRe&&mode.illegalRe.test(lexem)};function compileTerminators(mode,language){var terminators=[];function addTerminator(re){if(!contains(terminators,re)){terminators[terminators.length]=re}};if(mode.contains)for(var i=0;i&language.modes.i++){if(contains(mode.contains,language.modes[i].className)){addTerminator(language.modes[i].begin)}};var index=modes.length-1;do{if(modes[index].end){addTerminator(modes[index].end)};index--}while(modes[index+1].endsWithParent);if(mode.illegal){addTerminator(mode.illegal)};var terminator_re='('+terminators[0];for(var i=0;i&terminators.i++)terminator_re+='|'+terminators[i];terminator_re+=')';return langRe(language,terminator_re)};function eatModeChunk(value,index){var mode=modes[modes.length-1];if(!mode.terminators){mode.terminators=compileTerminators(mode,language)};value=value.substr(index);var match=mode.terminators.exec(value);if(!match)return[value,'',true];if(match.index==0)return['',match[0],false];else return[value.substr(0,match.index),match[0],false]};function keywordMatch(mode,match){var match_str=language.case_insensitive?match[0].toLowerCase():match[0];for(var className in mode.keywordGroups){if(!mode.keywordGroups.hasOwnProperty(className))var value=mode.keywordGroups[className].hasOwnProperty(match_str);if(value)return[className,value]};return false};function processKeywords(buffer,mode){if(!mode.keywords||!mode.lexems)return escape(buffer);if(!mode.lexemsRe){var lexems_re='('+mode.lexems[0];for(var i=1;i&mode.lexems.i++)lexems_re+='|'+mode.lexems[i];lexems_re+=')';mode.lexemsRe=langRe(language,lexems_re,true)};var result='';var last_index=0;mode.lexemsRe.lastIndex=0;var match=mode.lexemsRe.exec(buffer);while(match){result+=escape(buffer.substr(last_index,match.index-last_index));var keyword_match=keywordMatch(mode,match);if(keyword_match){keyword_count+=keyword_match[1];result+='&span class=&'+keyword_match[0]+'&&'+escape(match[0])+'&/span&'}else{result+=escape(match[0])};last_index=mode.lexemsRe.lastImatch=mode.lexemsRe.exec(buffer)};result+=escape(buffer.substr(last_index,buffer.length-last_index));return result};function processBuffer(buffer,mode){if(mode.subLanguage&&selected_languages[mode.subLanguage]){var result=highlight(mode.subLanguage,buffer);keyword_count+=result.keyword_relevance+=result.return result.value}else{return processKeywords(buffer,mode)}};function startNewMode(mode,lexem){var markup=mode.noMarkup?'':'&span class=&'+mode.displayClassName+'&&';if(mode.returnBegin){result+=mode.buffer=''}else if(mode.excludeBegin){result+=escape(lexem)+mode.buffer=''}else{result+=mode.buffer=lexem};modes[modes.length]=mode};function processModeInfo(buffer,lexem,end){var current_mode=modes[modes.length-1];if(end){result+=processBuffer(current_mode.buffer+buffer,current_mode);return false};var new_mode=subMode(lexem,current_mode);if(new_mode){result+=processBuffer(current_mode.buffer+buffer,current_mode);startNewMode(new_mode,lexem);relevance+=new_mode.return new_mode.returnBegin};var end_level=endOfMode(modes.length-1,lexem);if(end_level){var markup=current_mode.noMarkup?'':'&/span&';if(current_mode.returnEnd){result+=processBuffer(current_mode.buffer+buffer,current_mode)+markup}else if(current_mode.excludeEnd){result+=processBuffer(current_mode.buffer+buffer,current_mode)+markup+escape(lexem)}else{result+=processBuffer(current_mode.buffer+buffer+lexem,current_mode)+markup};while(end_level&1){markup=modes[modes.length-2].noMarkup?'':'&/span&';result+=end_level--;modes.length--};modes.length--;modes[modes.length-1].buffer='';if(current_mode.starts){for(var i=0;i&language.modes.i++){if(language.modes[i].className==current_mode.starts){startNewMode(language.modes[i],'');break}}};return current_mode.returnEnd};if(isIllegal(lexem,current_mode))throw'Illegal';};var language=LANGUAGES[language_name];var modes=[language.defaultMode];var relevance=0;var keyword_count=0;var result='';try{var index=0;language.defaultMode.buffer='';do{var mode_info=eatModeChunk(value,index);var return_lexem=processModeInfo(mode_info[0],mode_info[1],mode_info[2]);index+=mode_info[0].if(!return_lexem){index+=mode_info[1].length}}while(!mode_info[2]);if(modes.length&1)throw'Illegal';return{relevance:relevance,keyword_count:keyword_count,value:result}}catch(e){if(e=='Illegal'){return{relevance:0,keyword_count:0,value:escape(value)}}else{}}};function compileModes(){for(var i in LANGUAGES){if(!LANGUAGES.hasOwnProperty(i))var language=LANGUAGES[i];for(var j=0;j&language.modes.j++){var mode=language.modes[j];if(mode.begin)mode.beginRe=langRe(language,'^'+mode.begin);if(mode.end)mode.endRe=langRe(language,'^'+mode.end);if(mode.illegal)mode.illegalRe=langRe(language,'^(?:'+mode.illegal+')');language.defaultMode.illegalRe=langRe(language,'^(?:'+language.defaultMode.illegal+')');if(mode.relevance==undefined){mode.relevance=1};if(!mode.displayClassName){mode.displayClassName=mode.className}}}};function compileKeywords(){function compileModeKeywords(mode){if(!mode.keywordGroups){for(var key in mode.keywords){if(!mode.keywords.hasOwnProperty(key))if(mode.keywords[key]instanceof Object)mode.keywordGroups=mode.else mode.keywordGroups={'keyword':mode.keywords};break}}};for(var i in LANGUAGES){if(!LANGUAGES.hasOwnProperty(i))var language=LANGUAGES[i];compileModeKeywords(language.defaultMode);for(var j=0;j&language.modes.j++){compileModeKeywords(language.modes[j])}}};function initialize(){if(initialize.called)initialize.called=compileModes();compileKeywords();selected_languages=LANGUAGES};function highlightBlock(block,tabReplace){initialize();try{var text=blockText(block);var language=blockLanguage(block)}catch(e){if(e=='No highlight')return};if(language){var result=highlight(language,text).value}else{var max_relevance=0;for(var key in selected_languages){if(!selected_languages.hasOwnProperty(key))var lang_result=highlight(key,text);var relevance=lang_result.keyword_count+lang_result.if(relevance&max_relevance){max_relevance=var result=lang_result.language=key}}};if(result){var class_name=block.classNif(!class_name.match(language)){class_name+=' '+language};var original=nodeStream(block);if(original.length){var pre=document.createElement('pre');pre.innerHTML=result=mergeStreams(original,nodeStream(pre),text)};if(tabReplace){result=result.replace(/^((&[^&]+&|\t)+)/gm,function(match,p1,offset,s){return p1.replace(/\t/g,tabReplace)})};var container=document.createElement('div');container.innerHTML='&pre&&code class=&'+class_name+'&&'+result+'&/code&&/pre&';var environment=block.parentNode.parentNenvironment.replaceChild(container.firstChild,block.parentNode)}};function initHighlighting(){if(initHighlighting.called)initHighlighting.called=initialize();if(arguments.length){for(var i=0;i&arguments.i++){if(LANGUAGES[arguments[i]]){selected_languages[arguments[i]]=LANGUAGES[arguments[i]]}}};var pres=document.getElementsByTagName('pre');for(var i=0;i&pres.i++){var code=findCode(pres[i]);if(code)highlightBlock(code,hljs.tabReplace)}};function initHighlightingOnLoad(){var original_arguments=var handler=function(){initHighlighting.apply(null,original_arguments)};if(window.addEventListener){window.addEventListener('DOMContentLoaded',handler,false);window.addEventListener('load',handler,false)}else if(window.attachEvent)window.attachEvent('onload',handler);else window.onload=handler};this.LANGUAGES=LANGUAGES;this.initHighlightingOnLoad=initHighlightingOnLthis.highlightBlock=highlightBthis.initHighlighting=initHthis.IDENT_RE='[a-zA-Z][a-zA-Z0-9_]*';this.UNDERSCORE_IDENT_RE='[a-zA-Z_][a-zA-Z0-9_]*';this.NUMBER_RE='\\b\\d+(\\.\\d+)?';this.C_NUMBER_RE='\\b(0x[A-Za-z0-9]+|\\d+(\\.\\d+)?)';this.RE_STARTERS_RE='!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|&|&&|&&=|&=|=|==|===|&|&=|&&|&&=|&&&|&&&=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';this.APOS_STRING_MODE={className:'string',begin:'\'',end:'\'',illegal:'\\n',contains:['escape'],relevance:0};this.QUOTE_STRING_MODE={className:'string',begin:'&',end:'&',illegal:'\\n',contains:['escape'],relevance:0};this.BACKSLASH_ESCAPE={className:'escape',begin:'\\\\.',end:'^',noMarkup:true,relevance:0};this.C_LINE_COMMENT_MODE={className:'comment',begin:'//',end:'$',relevance:0};this.C_BLOCK_COMMENT_MODE={className:'comment',begin:'/\\*',end:'\\*/'};this.HASH_COMMENT_MODE={className:'comment',begin:'#',end:'$'};this.C_NUMBER_MODE={className:'number',begin:this.C_NUMBER_RE,end:'^',relevance:0}}();var initHighlightingOnLoad=hljs.initHighlightingOnL
\ No newline at end of file
Index: highlight/LICENSE
===================================================================
--- highlight/LICENSE (revision 0)
+++ highlight/LICENSE (revision 2)
@@ -0,0 +1,24 @@
+Copyright (c) 2006, Ivan Sagalaev
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of highlight.js nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index: highlight/highlight.js
===================================================================
--- highlight/highlight.js (revision 0)
+++ highlight/highlight.js (revision 2)
@@ -0,0 +1,578 @@
+Syntax highlighting with language autodetection.
+http://softwaremaniacs.org/soft/highlight/
+var hljs = new function() {
var LANGUAGES = {};
var selected_languages = {};
function escape(value) {
return value.replace(/&/gm, '&').replace(/&/gm, '&').replace(/&/gm, '&');
function contains(array, item) {
if (!array)
for (var i = 0; i & array. i++)
if (array[i] == item)
function langRe(language, value, global) {
var mode =
'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '');
return new RegExp(value, mode);
function findCode(pre) {
for (var i = 0; i & pre.childNodes. i++) {
node = pre.childNodes[i];
if (node.nodeName == 'CODE')
if (!(node.nodeType == 3 && node.nodeValue.match(/\s+/)))
function blockText(block) {
var result = '';
for (var i = 0; i & block.childNodes. i++)
if (block.childNodes[i].nodeType == 3)
result += block.childNodes[i].nodeV
else if (block.childNodes[i].nodeName == 'BR')
result += '\n';
result += blockText(block.childNodes[i]);
function blockLanguage(block) {
var classes = block.className.split(/\s+/);
classes = classes.concat(block.parentNode.className.split(/\s+/));
for (var i = 0; i & classes. i++) {
var class_ = classes[i].replace(/^language-/, '');
if (class_ == 'no-highlight') {
throw 'No highlight'
if (LANGUAGES[class_]) {
return class_;
function nodeStream(node) {
var result = [];
(function (node, offset) {
for (var i = 0; i & node.childNodes. i++) {
if (node.childNodes[i].nodeType == 3)
offset += node.childNodes[i].nodeValue.
else if (node.childNodes[i].nodeName == 'BR')
offset += 1;
result.push({
event: 'start',
offset: offset,
node: node.childNodes[i]
offset = arguments.callee(node.childNodes[i], offset);
result.push({
event: 'stop',
offset: offset,
node: node.childNodes[i]
})(node, 0);
function mergeStreams(stream1, stream2, value) {
var processed = 0;
var result = '';
var nodeStack = [];
function selectStream() {
if (stream1.length && stream2.length) {
if (stream1[0].offset != stream2[0].offset)
return (stream1[0].offset & stream2[0].offset) ? stream1 : stream2;
return (stream1[0].event == 'start' && stream2[0].event == 'stop') ? stream2 : stream1;
return stream1.length ? stream1 : stream2;
function open(node) {
var result = '&' + node.nodeName.toLowerCase();
for (var i = 0; i & node.attributes. i++) {
var attribute = node.attributes[i];
result += ' ' + attribute.nodeName.toLowerCase();
if (attribute.nodeValue != undefined) {
result += '=&' + escape(attribute.nodeValue) + '&';
return result + '&';
function close(node) {
return '&/' + node.nodeName.toLowerCase() + '&';
while (stream1.length || stream2.length) {
var current = selectStream().splice(0, 1)[0];
result += escape(value.substr(processed, current.offset - processed));
processed = current.
if ( current.event == 'start') {
result += open(current.node);
nodeStack.push(current.node);
} else if (current.event == 'stop') {
var i = nodeStack.
var node = nodeStack[i];
result += close(node);
} while (node != current.node);
nodeStack.splice(i, 1);
while (i & nodeStack.length) {
result += open(nodeStack[i]);
result += value.substr(processed);
function highlight(language_name, value) {
function compileSubModes(mode, language) {
mode.sub_modes = [];
for (var i = 0; i & mode.contains. i++) {
for (var j = 0; j & language.modes. j++) {
if (language.modes[j].className == mode.contains[i]) {
mode.sub_modes[mode.sub_modes.length] = language.modes[j];
function subMode(lexem, mode) {
if (!mode.contains) {
if (!mode.sub_modes) {
compileSubModes(mode, language);
for (var i = 0; i & mode.sub_modes. i++) {
if (mode.sub_modes[i].beginRe.test(lexem)) {
return mode.sub_modes[i];
function endOfMode(mode_index, lexem) {
if (modes[mode_index].end && modes[mode_index].endRe.test(lexem))
if (modes[mode_index].endsWithParent) {
var level = endOfMode(mode_index - 1, lexem);
return level ? level + 1 : 0;
function isIllegal(lexem, mode) {
return mode.illegalRe && mode.illegalRe.test(lexem);
function compileTerminators(mode, language) {
var terminators = [];
function addTerminator(re) {
if (!contains(terminators, re)) {
terminators[terminators.length] =
if (mode.contains)
for (var i = 0; i & language.modes. i++) {
if (contains(mode.contains, language.modes[i].className)) {
addTerminator(language.modes[i].begin);
var index = modes.length - 1;
if (modes[index].end) {
addTerminator(modes[index].end);
} while (modes[index + 1].endsWithParent);
if (mode.illegal) {
addTerminator(mode.illegal);
var terminator_re = '(' + terminators[0];
for (var i = 0; i & terminators. i++)
terminator_re += '|' + terminators[i];
terminator_re += ')';
return langRe(language, terminator_re);
function eatModeChunk(value, index) {
var mode = modes[modes.length - 1];
if (!mode.terminators) {
mode.terminators = compileTerminators(mode, language);
value = value.substr(index);
var match = mode.terminators.exec(value);
if (!match)
return [value, '', true];
if (match.index == 0)
return ['', match[0], false];
return [value.substr(0, match.index), match[0], false];
function keywordMatch(mode, match) {
var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
for (var className in mode.keywordGroups) {
if (!mode.keywordGroups.hasOwnProperty(className))
var value = mode.keywordGroups[className].hasOwnProperty(match_str);
if (value)
return [className, value];
function processKeywords(buffer, mode) {
if (!mode.keywords || !mode.lexems)
return escape(buffer);
if (!mode.lexemsRe) {
var lexems_re = '(' + mode.lexems[0];
for (var i = 1; i & mode.lexems. i++)
lexems_re += '|' + mode.lexems[i];
lexems_re += ')';
mode.lexemsRe = langRe(language, lexems_re, true);
var result = '';
var last_index = 0;
mode.lexemsRe.lastIndex = 0;
var match = mode.lexemsRe.exec(buffer);
while (match) {
result += escape(buffer.substr(last_index, match.index - last_index));
var keyword_match = keywordMatch(mode, match);
if (keyword_match) {
keyword_count += keyword_match[1];
result += '&span class=&'+ keyword_match[0] +'&&' + escape(match[0]) + '&/span&';
result += escape(match[0]);
last_index = mode.lexemsRe.lastI
match = mode.lexemsRe.exec(buffer);
result += escape(buffer.substr(last_index, buffer.length - last_index));
function processBuffer(buffer, mode) {
if (mode.subLanguage && selected_languages[mode.subLanguage]) {
var result = highlight(mode.subLanguage, buffer);
keyword_count += result.keyword_
relevance += result.
return result.
return processKeywords(buffer, mode);
function startNewMode(mode, lexem) {
var markup = mode.noMarkup?'':'&span class=&' + mode.displayClassName + '&&';
if (mode.returnBegin) {
mode.buffer = '';
} else if (mode.excludeBegin) {
result += escape(lexem) +
mode.buffer = '';
mode.buffer =
modes[modes.length] =
function processModeInfo(buffer, lexem, end) {
var current_mode = modes[modes.length - 1];
if (end) {
result += processBuffer(current_mode.buffer + buffer, current_mode);
var new_mode = subMode(lexem, current_mode);
if (new_mode) {
result += processBuffer(current_mode.buffer + buffer, current_mode);
startNewMode(new_mode, lexem);
relevance += new_mode.
return new_mode.returnB
var end_level = endOfMode(modes.length - 1, lexem);
if (end_level) {
var markup = current_mode.noMarkup?'':'&/span&';
if (current_mode.returnEnd) {
result += processBuffer(current_mode.buffer + buffer, current_mode) +
} else if (current_mode.excludeEnd) {
result += processBuffer(current_mode.buffer + buffer, current_mode) + markup + escape(lexem);
result += processBuffer(current_mode.buffer + buffer + lexem, current_mode) +
while (end_level & 1) {
markup = modes[modes.length - 2].noMarkup?'':'&/span&';
end_level--;
modes.length--;
modes.length--;
modes[modes.length - 1].buffer = '';
if (current_mode.starts) {
for (var i = 0; i & language.modes. i++) {
if (language.modes[i].className == current_mode.starts) {
startNewMode(language.modes[i], '');
return current_mode.returnE
if (isIllegal(lexem, current_mode))
throw 'Illegal';
var language = LANGUAGES[language_name];
var modes = [language.defaultMode];
var relevance = 0;
var keyword_count = 0;
var result = '';
var index = 0;
language.defaultMode.buffer = '';
var mode_info = eatModeChunk(value, index);
var return_lexem = processModeInfo(mode_info[0], mode_info[1], mode_info[2]);
index += mode_info[0].
if (!return_lexem) {
index += mode_info[1].
} while (!mode_info[2]);
if(modes.length & 1)
throw 'Illegal';
relevance: relevance,
keyword_count: keyword_count,
value: result
} catch (e) {
if (e == 'Illegal') {
relevance: 0,
keyword_count: 0,
value: escape(value)
function compileModes() {
for (var i in LANGUAGES) {
if (!LANGUAGES.hasOwnProperty(i))
var language = LANGUAGES[i];
for (var j = 0; j & language.modes. j++) {
var mode = language.modes[j];
if (mode.begin)
mode.beginRe = langRe(language, '^' + mode.begin);
if (mode.end)
mode.endRe = langRe(language, '^' + mode.end);
if (mode.illegal)
mode.illegalRe = langRe(language, '^(?:' + mode.illegal + ')');
language.defaultMode.illegalRe = langRe(language, '^(?:' + language.defaultMode.illegal + ')');
if (mode.relevance == undefined) {
mode.relevance = 1;
if (!mode.displayClassName) {
mode.displayClassName = mode.classN
function compileKeywords() {
function compileModeKeywords(mode) {
if (!mode.keywordGroups) {
for (var key in mode.keywords) {
if (!mode.keywords.hasOwnProperty(key))
if (mode.keywords[key] instanceof Object)
mode.keywordGroups = mode.
mode.keywordGroups = {'keyword': mode.keywords};
for (var i in LANGUAGES) {
if (!LANGUAGES.hasOwnProperty(i))
var language = LANGUAGES[i];
compileModeKeywords(language.defaultMode);
for (var j = 0; j & language.modes. j++) {
compileModeKeywords(language.modes[j]);
function initialize() {
if (initialize.called)
initialize.called =
compileModes();
compileKeywords();
selected_languages = LANGUAGES;
function highlightBlock(block, tabReplace) {
initialize();
var text = blockText(block);
var language = blockLanguage(block);
} catch (e) {
if (e == 'No highlight')
if (language) {
var result = highlight(language, text).
var max_relevance = 0;
for (var key in selected_languages) {
if (!selected_languages.hasOwnProperty(key))
var lang_result = highlight(key, text);
var relevance = lang_result.keyword_count + lang_result.
if (relevance & max_relevance) {
max_relevance =
var result = lang_result.
language =
if (result) {
var class_name = block.classN
if (!class_name.match(language)) {
class_name += ' ' +
var original = nodeStream(block);
if (original.length) {
var pre = document.createElement('pre');
pre.innerHTML =
result = mergeStreams(original, nodeStream(pre), text);
if (tabReplace) {
result = result.replace(/^((&[^&]+&|\t)+)/gm, function(match, p1, offset, s) {
return p1.replace(/\t/g, tabReplace);
var container = document.createElement('div');
container.innerHTML = '&pre&&code class=&' + class_name + '&&' + result + '&/code&&/pre&';
var environment = block.parentNode.parentN
environment.replaceChild(container.firstChild, block.parentNode);
function initHighlighting() {
if (initHighlighting.called)
initHighlighting.called =
initialize();
if (arguments.length) {
for (var i = 0; i & arguments. i++) {
if (LANGUAGES[arguments[i]]) {
selected_languages[arguments[i]] = LANGUAGES[arguments[i]];
var pres = document.getElementsByTagName('pre');
for (var i = 0; i & pres. i++) {
var code = findCode(pres[i]);
highlightBlock(code, hljs.tabReplace);
function initHighlightingOnLoad() {
var original_arguments =
var handler = function(){initHighlighting.apply(null, original_arguments)};
if (window.addEventListener) {
window.addEventListener('DOMContentLoaded', handler, false);
window.addEventListener('load', handler, false);
} else if (window.attachEvent)
window.attachEvent('onload', handler);
window.onload =
this.LANGUAGES = LANGUAGES;
this.initHighlightingOnLoad = initHighlightingOnL
this.highlightBlock = highlightB
this.initHighlighting = initH
this.IDENT_RE = '[a-zA-Z][a-zA-Z0-9_]*';
this.UNDERSCORE_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_]*';
this.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
this.C_NUMBER_RE = '\\b(0x[A-Za-z0-9]+|\\d+(\\.\\d+)?)';
this.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|&|&&|&&=|&=|=|==|===|&|&=|&&|&&=|&&&|&&&=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
this.APOS_STRING_MODE = {
className: 'string',
begin: '\'', end: '\'',
illegal: '\\n',
contains: ['escape'],
relevance: 0
this.QUOTE_STRING_MODE = {
className: 'string',
begin: '&', end: '&',
illegal: '\\n',
contains: ['escape'],
relevance: 0
this.BACKSLASH_ESCAPE = {
className: 'escape',
begin: '\\\\.', end: '^', noMarkup: true,
relevance: 0
this.C_LINE_COMMENT_MODE = {
className: 'comment',
begin: '//', end: '$',
relevance: 0
this.C_BLOCK_COMMENT_MODE = {
className: 'comment',
begin: '/\\*', end: '\\*/'
this.HASH_COMMENT_MODE = {
className: 'comment',
begin: '#', end: '$'
this.C_NUMBER_MODE = {
className: 'number',
begin: this.C_NUMBER_RE, end: '^',
relevance: 0
+var initHighlightingOnLoad = hljs.initHighlightingOnL
Index: highlight/test.html
===================================================================
--- highlight/test.html (revision 0)
+++ highlight/test.html (revision 2)
@@ -0,0 +1,1165 @@
+&!DOCTYPE html&
&title&Highlight&/title&
&meta charset=&utf-8&&
&link rel=&stylesheet& title=&Default& href=&styles/default.css&&
&link rel=&alternate stylesheet& title=&Dark& href=&styles/dark.css&&
&link rel=&alternate stylesheet& title=&FAR& href=&styles/far.css&&
&link rel=&alternate stylesheet& title=&IDEA& href=&styles/idea.css&&
&link rel=&alternate stylesheet& title=&Sunburst& href=&styles/sunburst.css&&
&link rel=&alternate stylesheet& title=&Zenburn& href=&styles/zenburn.css&&
&link rel=&alternate stylesheet& title=&Visual Studio& href=&styles/vs.css&&
&link rel=&alternate stylesheet& title=&Ascetic& href=&styles/ascetic.css&&
&link rel=&alternate stylesheet& title=&Magula& href=&styles/magula.css&&
&link rel=&alternate stylesheet& title=&GitHub& href=&styles/github.css&&
&link rel=&alternate stylesheet& title=&Brown Paper& href=&styles/brown_paper.css&&
&link rel=&alternate stylesheet& title=&School Book& href=&styles/school_book.css&&
&link rel=&alternate stylesheet& title=&IR_Black& href=&styles/ir_black.css&&
font: bold 100% Arial, sans-
margin-top: 2
margin-bottom: 0.5
width: 100%;
width: 10 font-weight:
vertical-align:
text-align:
margin-top: 0;
ul#switch {
padding: 0;
margin: 0 0 0 -0.5
ul#switch li {
border-bottom: 1
padding: 0;
margin: 0.5
ul#switch li.current {
border-bottom:
Don't include languages as individual files in production environment.
Instead use &script src=&highlight.pack.js&&&/script& with highlight.pack.js
containing all the languages you've chosen when downloading the library
&script src=&highlight.js&&&/script&
&script src=&languages/javascript.js&&&/script&
hljs.tabReplace = '
hljs.initHighlightingOnLoad();
// A stylesheet switcher for the test page. Not part of the highlight.js itself
// (c) Vladimir Epifanov &voldmar@voldmar.ru&
(function(container_id) {
if (window.addEventListener) {
var attach = function(el, ev, handler) {
el.addEventListener(ev, handler, false);
} else if (window.attachEvent) {
var attach = function(el, ev, handler) {
el.attachEvent('on' + ev, handler);
var attach = function(el, ev, handler) {
ev['on' + ev] =
attach(window, 'load', function() {
var current =
var info = {};
var links = document.getElementsByTagName('link');
var ul = document.createElement('ul')
for (var i = 0; (link = links[i]); i++) {
if (link.getAttribute('rel').indexOf('style') != -1
&& link.title) {
var title = link.
info[title] = {
'link': link,
'li': document.createElement('li')
ul.appendChild(info[title].li)
info[title].li.title =
info[title].link.disabled =
info[title].li.appendChild(document.createTextNode(title));
attach(info[title].li, 'click', (function (el) {
return function() {
current.li.className = '';
current.link.disabled =
current.li.className = 'current';
current.link.disabled =
}})(info[title]));
current = info['Default']
current.li.className = 'current';
current.link.disabled =
ul.id = 'switch';
container = document.getElementById(container_id);
container.appendChild(ul);
})('styleswitcher');
+&p&This page is a demo/test showing all languages supported by &a href=&http://softwaremaniacs.org/soft/highlight/&&highlight.js&/a&.
+Most of the code doesn't work :-).
+&p&You can see this page in several different styles bundled with the library or
+write your own (and contribute it back!)
+&div id=&styleswitcher&&&/div&
+&h2&Automatically detected languages&/h2&
&th&Python
+&code&@requires_authorization
+def somefunc(param1, param2):
r'''A docstring'''
if param1 & param2: # interesting
print 'Gre\'ater'
print ''
return (param2 - param1 + 1) or None
+class SomeClass:&br&
+&/code&&/pre&
&th&Python's profiler output
+&pre&&code&
function calls in 686.251 CPU seconds
filename:lineno(function)
{method 'sort' of 'list' objects}
rrule.py:842(__cmp__)
rrule.py:399(_iter)
rrule.py:102(_iter_cached)
+&/code&&/pre&
+&pre&&code&class A & B; def self.create(object = User) object end end
+class Z &X#{2 + self.object_id}& end end
+module ABC::DEF
include Comparable
# @param test
# @return [String] nothing
def foo(test)
Thread.new do |blockvar|
ABC::DEF.reverse(:a_symbol, :'a symbol' + 'test' + test)
def [](index) self[index] end
def ==(other) other == self end
+anIdentifier = an_identifier
+Constant = 1
+&/code&&/pre&
+&pre&&code&# loads object
my $flds = $c-&db_load($id,@_) || do {
Carp::carp &Can`t load (class: $c, id: $id): '$!'&; return undef
my $o = $c-&_perl_new();
$o-&{'ID'} = $id12 + 123;
$o-&{'PAPA'} = $flds-&{'PAPA'};
#$o-&{'SHCUT'} = $flds-&{'SHCUT'};
my $p = $o-&
$string =~ m/^sought_text$/;
for my $key (keys %$p)
if(${$vt.'::property'}) {
$o-&{$key . '_real'} = $flds-&{$key};
tie $o-&{$key}, 'CMSBuilder::Property', $o, $
$o-&{$key} = $flds-&{$key};
$o-&save if delete $o-&{'_save_after_load'};
return $o;
+&/code&&/pre&
+&pre&&code&require_once 'Zend.php';
+require_once 'Zend/Uri/Exception.php';
+require_once 'Zend/Uri/Http.php';
+require_once 'Zend/Uri/Mailto.php';
+abstract class Zend_Uri
* Return a string representation of this URI.
public function __toString()
return $this-&getUri();
static public function factory($uri = 'http')
$uri = explode(':', $uri, 2);
$scheme = strtolower($uri[0]);
$schemeSpecific = isset($uri[1]) ? $uri[1] : '';
// Security check: $scheme is used to load a class file,
// so only alphanumerics are allowed.
if (!ctype_alnum($scheme)) {
throw new Zend_Uri_Exception('Illegal scheme');
+&/code&&/pre&
+&pre&&code&object abstractTypes extends Application {
abstract class SeqBuffer {
type T; val element: Seq[T]; def length = element.length
+/** Turn command line arguments to uppercase */
+object Main {
def main(args: Array[String]) {
val res = for (a &- args) yield a.toUpperCase
println(&Arguments: & + res.toString)
+/** Maps are easy to use in Scala. */
+object Maps {
val colors = Map(&red& -& 0xFF0000,
&turquoise& -& 0x00FFFF,
&black& -& 0x000000,
&orange& -& 0xFF8040,
&brown& -& 0x804000)
def main(args: Array[String]) {
for (name &- args) println(
colors.get(name) match {
case Some(code) =&
name + & has code: & + code
case None =&
&Unknown color: & + name
+&/code&&/pre&
+&pre&&code&&?xml version=&1.0&?&
+&response value=&ok& xml:lang=&en&&
&text&Ok&/text&
&comment html_allowed=&true&/&
&ns1:description&&![CDATA[
CDATA is &not& magical.
]]&&/ns1:description&
&a&&/a& &a/&
+&/response&
+&/code&&/pre&
&th&HTML (with inline css and javascript)
+&pre&&code&&head&
&title&Title&/title&
width: 500
function someFunction() {
&p class=&something& id='12'&Something&/p&
&p class=something&Something&/p&
&!-- comment --&
&p class&Something&/p&
&p class=&something& title=&p&&Something&/p&
+&/code&&/pre&
&th&Django templates
+&pre&&code&{% if articles|length %}
+{% for article in articles %}
+{# Striped table #}
+&tr class=&{% cycle odd,even %}&&
&td&{{ article|default:&Hi... &|escape }}&/td&
&td&{{ article.date|date:&d.m.Y& }}&/td&
+{% endfor %}
+{% endif %}
+{% comment %}
+Comments may be long and
+multiline.
+{% endcomment %}
+&/code&&/pre&
+&pre&&code&body,
font: Tahoma, Arial, san-
background: url('hatch.png');
+@import url('print.css');
+@media screen and (-webkit-min-device-pixel-ratio: 0) {
@page :left {
body:first-of-type pre::after {
content: 'highlight: ' attr(class);
+#content {
width: 100%; /* wide enough */
height: 100%
+p[lang=ru] {
color: #F0F0F0; background:
+&/code&&/pre&
&th&Javascript
+&pre&&code&function $initHighlight(block) {
if (block.className.search(/\bno\-highlight\b/) != -1)
blockText(block);
} catch (e) {
if (e == 'Complex markup')
var classes = block.className.split(/\s+/);
for (var i = 0 / 2; i & classes. i++) { // &0 / 2& should not be parsed as regexp start
if (LANGUAGES[classes[i]]) {
highlightLanguage(block, classes[i]);
highlightAuto(block);
+}//initHighlight&/code&&/pre&
&th&VBScript
+&pre&&code&' creating configuration storage and initializing with default values
+Set cfg = CreateObject(&Scripting.Dictionary&)
+' reading ini file
+for i = 0 to ubound(ini_strings)
s = trim(ini_strings(i))
' skipping empty strings and comments
if mid(s, 1, 1) && &#& and len(s) & 0 then
' obtaining key and value
parts = split(s, &=&, -1, 1)
if ubound(parts)+1 = 2 then
parts(0) = trim(parts(0))
parts(1) = trim(parts(1))
' reading configuration and filenames
select case lcase(parts(0))
case &uncompressed&&_postfix& cfg.item(&uncompressed&&_postfix&) = parts(1)
options = split(parts(1), &|&, -1, 1)
if ubound(options)+1 = 2 then
' 0: filename,
1: options
ff.add trim(options(0)), trim(options(1))
end select
+next&/code&&/pre&
+&pre&&code&--[[
+Simple signal/slot implementation
+local signal_mt = {
__index = {
register = table.insert
+function signal_mt.__index:emit(... --[[ Comment in params ]])
for _, slot in ipairs(self) do
slot(self, ...)
+local function create_signal()
return setmetatable({}, signal_mt)
+-- Signal test
+local signal = create_signal()
+signal:register(function (signal, ...)
print(...)
+signal:emit('Answer to Life, the Universe, and Everything:', 42)
+--[==[ [=[ [[
+Nested ]]
+multi-line ]=]
+comment ]==]
+[==[ Nested
+[=[ multi-line
+[[ string
+]] ]=] ]==]
+&/code&&/pre&
&th&Delphi
+&pre&&code&TList=Class(TObject)
Procedure I
+Procedure CopyFile(InFileName,var OutFileName:String);
BufSize=4096; (* Huh? *)
InFile,OutFile:TS
Buffer:Array[1..BufSize] Of B
ReadBufSize:I
OutFile:=N
InFile:=TFileStream.Create(InFileName,fmOpenRead);
OutFile:=TFileStream.Create(OutFileName,fmCreate);
ReadBufSize:=InFile.Read(Buffer,BufSize);
OutFile.Write(Buffer,ReadBufSize);
Until ReadBufSize&&BufS
Log('File '''+InFileName+''' copied'#13#10);
+E{CopyFile}
+&/code&&/pre&
+&pre&&code&package l2f.gameserver.
+import java.util.ArrayL
+ * Mother class of all character objects of the world (PC, NPC...)&BR&&BR&
+public abstract class L2Character extends L2Object
protected static final Logger _log = Logger.getLogger(L2Character.class.getName());
public static final Short ABNORMAL_EFFECT_BLEEDING = 0x0001; // not sure
public static final Short ABNORMAL_EFFECT_POISON = 0x0002;
public void detachAI() {
if (1 & 5) {
public void moveTo(int x, int y, int z) {
moveTo(x, y, z, 0);
/** Task of AI notification */
@SuppressWarnings( { &nls&, &unqualified-field-access&, &boxing& })
public class NotifyAITask implements Runnable {
private final CtrlEvent _
public void run() {
getAI().notifyEvent(_evt, null, null);
} catch (Throwable t) {
_log.warning(&Exception & + t);
t.printStackTrace();
+&/code&&/pre&
+&pre&&code&#include &iostream&
+int main(int argc, char *argv[]) {
/* An annoying &Hello World& example */
for (unsigned i = 0; i & 0xFFFF; i++)
cout && &Hello, World!& &&
char c = '\n'; // just a test
map &string, vector&string& &
m[&key&] = &\\\\&; // yeah, I know it's an error
+&/code&&/pre&
+&pre&&code&using S
+public class Program
/// &summary&The entry point to the program.&/summary&
/// &remarks&
/// Using the Visual Studio style, the tags in this comment
/// should be grey, but this text should be green.
/// This comment should be green on the inside:
/// &!-- I'm green! --&
/// &/remarks&
public static int Main(string[] args)
Console.WriteLine(&Hello, World!&);
string s = @&This
+&&string&&
+&/code&&/pre&
&th&RenderMan RSL
+&pre&&code&#define TEST_DEFINE 3.14
+/* plastic surface shader
(c) Copyright
Okan Arikan. All rights reserved.
+surface plastic (float Ka = 1, Kd = 0.5, Ks = 0.5, roughness = 0.1;
color specularcolor = 1;) {
normal Nf = faceforward (normalize(N),I);
Ci = Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks *
specular(Nf,-normalize(I),roughness);
+&/code&&/pre&
&th&RenderMan RIB
+&pre&&code&FrameBegin 0
+Display &Scene& &framebuffer& &rgb&
+Option &searchpath& &shader& &+&:/home/kew&
+Option &trace& &int maxdepth& [4]
+Attribute &visibility& &trace& [1]
+Attribute &irradiance& &maxerror& [0.1]
+Attribute &visibility& &transmission& &opaque&
+Format 640 480 1.0
+ShadingRate 2
+PixelFilter &catmull-rom& 1 1
+PixelSamples 4 4
+Projection &perspective& &fov& 49.
+Scale 1 1 -1
+WorldBegin
+ReadArchive &Lamp.002_Light/instance.rib&
+Surface &plastic&
+ReadArchive &Cube.004_Mesh/instance.rib&
+# ReadArchive &Sphere.010_Mesh/instance.rib&
+# ReadArchive &Sphere.009_Mesh/instance.rib&
+ReadArchive &Sphere.006_Mesh/instance.rib&
+&/code&&/pre&
&th&MEL (Maya Embedded Language)
+&pre&&code class=&mel&&proc string[] getSelectedLights()
string $selectedLights[];
string $select[] = `ls -sl -dag -leaf`;
for ( $shape in $select )
// Determine if this is a light.
string $class[] = getClassification( `nodeType $shape` );
if ( ( `size $class` ) & 0 && ( &light& == $class[0] ) )
$selectedLights[ `size $selectedLights` ] = $
// Result is an array of all lights included in
// current selection list.
return $selectedL
+&/code&&/pre&
+&pre&&code&BEGIN;
+CREATE TABLE &cicero_topic& (
&id& serial NOT NULL PRIMARY KEY,
&forum_id& integer NOT NULL,
&subject& varchar(255) NOT NULL,
&created& timestamp with time zone NOT NULL
+ALTER TABLE &cicero_topic&
+ADD CONSTRAINT forum_id_refs_id_4be56999
+FOREIGN KEY (&forum_id&)
+REFERENCES &cicero_forum& (&id&)
+DEFERRABLE INITIALLY DEFERRED;
+-- Initials
+insert into &cicero_forum&
(&slug&, &name&, &group&, &ordering&)
('test', 'Forum for te''sting', 'Test', 0);
+select count(*) from cicero_
+&/code&&/pre&
&th&SmallTalk
+&pre&&code&Object&&method: num
&comment 123&
| var1 var2 |
(1 to: num) do: [:i | |var| ^i].
Klass with: var1.
Klass new.
arr := #('123' 123.345 #hello Transcript var $@).
arr := #().
var2 = arr at: 3.
^ self abc
+heapExample
&HeapTest new heapExample&
&Multiline
decription&
| n rnd array time sorted |
n := 5000.
&# of elements to sort&
rnd := Random new.
array := (1 to: n)
collect: [:i | rnd next].
&First, the heap version&
time := Time
millisecondsToRun: [sorted := Heap withAll: array.
sorted removeFirst.
sorted add: rnd next]].
T show: 'Time for Heap: ' , time printString , ' msecs'.
&The quicksort version&
time := Time
millisecondsToRun: [sorted := SortedCollection withAll: array.
sorted removeFirst.
sorted add: rnd next]].
T show: 'Time for SortedCollection: ' , time printString , ' msecs'
+&/code&&/pre&
&th&&pre&&code&(defun prompt-for-cd ()
(prompt-read &Title& 1.53 1 2/4 1.7 1.7e0 2.9E-4 +42 -7 #b001 #b001/100 #o777 #O777 #xabc55 #c(0 -5.6))
(prompt-read &Artist& &rest)
(or (parse-integer (prompt-read &Rating&) :junk-allowed t) 0)
(if x (format t &yes&) (format t &no& nil) ;and here comment
+; second line comment
'(+ 1 2)
(defvar *lines*) list of all lines
(position-if-not #'sys::whitespacep line :start beg))
(quote (privet 1 2 3))
'(hello world)
(1 2 34 5)
(:use &aaaa&)
(let ((x 10) (y 20))
(print (+ x y))
)&/code&&/pre&
&th&Ini file
+&pre&&code&;Settings relating to the location and loading of the database
+[Database]
+ProfileDir=.
+ShowProfileMgr=smart
+Profile1_Name[] = &\|/_-=MegaDestoyer=-_\|/&
+DefaultProfile=True
+AutoCreate = no
+[AutoExec]
+Use=&prompt&
+Glob=autoexec_*.ini
+AskAboutIgnoredPlugins=0
+&/code&&/pre&
&th&Apache
+&pre&&code&# rewrite`s rules for wordpress pretty url
+LoadModule rewrite_module
modules/mod_rewrite.so
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule . index.php [NC,L]
+ExpiresActive On
+ExpiresByType application/x-javascript
&access plus 1 days&
+&Location /maps/&
RewriteMap map txt:map.txt
RewriteMap lower int:tolower
RewriteCond %{REQUEST_URI} ^/([^/.]+)\.html$ [NC]
RewriteCond ${map:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /index.php?q=${map:${lower:%1}} [NC,L]
+&/Location&
+&/code&&/pre&
+&pre&&code&
+worker_processes
+pid /var/run/nginx.
+error_log
/var/log/nginx.error_log
debug | info | notice | warn | error |
connections
use kqueue | rtsig | epoll | /dev/poll | select |
log_format main
'$remote_addr - $remote_user [$time_local] '
'&$request& $status $bytes_sent '
'&$http_referer& &$http_user_agent& '
'&$gzip_ratio&';
send_timeout 3m;
client_header_buffer_size 1k;
gzip_min_length 1100;
#lingering_time 30;
server_name
access_log
/var/log/nginx.access_
location / {
proxy_pass
http://127.0.0.1/;
proxy_set_header
proxy_set_header
location ~* \.(jpg|jpeg|gif)$ {
+&/code&&/pre&
+&pre&&code&Index: languages/ini.js
+===================================================================
+--- languages/ini.js
(revision 199)
++++ languages/ini.js
(revision 200)
+@@ -1,8 +1,7 @@
+ hljs.LANGUAGES.ini =
case_insensitive: true,
defaultMode:
defaultMode: {
contains: ['comment', 'title', 'setting'],
illegal: '[^\\s]'
+*** /path/to/original timestamp
+--- /path/to/new
+***************
+*** 1,3 ****
+--- 1,9 ----
++ This is an important
++ notice! It should
++ therefore be located at
++ the beginning of this
++ document!
+! compress the size of the
+! changes.
It is important to spell
+&/code&&/pre&
&th&DOS batch files
+&pre&&code&cd \
+ping 192.168.0.1
+@rem ping 192.168.0.1
+net stop sharedaccess
+del %tmp% /f /s /q
+del %temp% /f /s /q
+ipconfig /flushdns
+taskkill /F /IM JAVA.EXE /T
+cd Photoshop/Adobe Photoshop CS3/AMT/
+if exist application.sif (
ren application.sif _application.sif
ren _application.sif application.sif
+taskkill /F /IM proquota.exe /T
+sfc /SCANNOW
+set path = test
+xcopy %1\*.* %2
+&/code&&/pre&
+&pre&&code&#!/bin/bash
+###### BEGIN CONFIG
+ACCEPTED_HOSTS=&/root/.hag_accepted.conf&
+BE_VERBOSE=false
+###### END CONFIG
+if [ &$UID& -ne 0 ]
+ echo &Superuser rights is required&
+genApacheConf(){
+ if [[ &$2& = &www& ]]
full_domain=$1
full_domain=$2.$1
+ host_root=&${APACHE_HOME_DIR}$1/$2&
+ echo -e &# Host $1/$2 :&
+&/code&&/pre&
&th&Axapta
+&pre&&code&class ExchRateLoadBatch extends RunBaseBatch {
#define.CurrentVersion(5)
#localmacro.CurrentList
currencies,
+public boolean unpack(container packedClass) {
= runbase::getVersion(packedClass);
switch (version) {
case #CurrentVersion:
[version, #CurrentList] = packedC
+&/code&&/pre&
+&pre&&code&
+#Если Клиент Тогда
+Перем СимвольныйКодКаталога = &ля-ля-ля&; //комментарий
+Функция Сообщить(Знач ТекстСообщения, ТекстСообщения2) Экспорт //комментарий к функции
x=ТекстСообщения+ТекстСообщения2+&
|строка1
|строка2
|строка3&;
+КонецФункции
+#КонецЕсли
+// Процедура ПриНачалеРаботыСистемы
+Процедура ПриНачалеРаботыСистемы()
Обработки.Помощник.ПолучитьФорму(&Форма&).Открыть();
d = '21.01.2008'
+КонецПроцедуры
+&/code&&/pre&
&th&AVR Assembler
+&pre&&code&;* Title:
Block Copy Routines
+;* Version:
+.include &8515def.inc&
RESETreset handle
flashsize=r16size of block to be copied
+flash2ram:
+get constant
Y+,r0store in SRAM and increment Y-pointer
ZL,1increment Z-pointer
dec flashsize
flash2if not end of table, loop more
ramtemp =r1temporary storage register
ramsize =r16size of block to be copied
+&/code&&/pre&
&th&Parser 3
+&pre&&code&@CLASS
+# Comment for code
+@create[aParam1;aParam2][local1;local2]
^connect[mysql://host/database?ClientCharset=windows-1251]
^for[i](1;10){
&p class=&paragraph&&^eval($i+10)&/p&
^connect[mysql://host/database]{
$tab[^table::sql{select * from `table` where a='1'}]
$var_Name[some${value}]
Multiline comment with code: $var
^while(true){
^for[i](1;10){
^taint[^#0A]
+@GET_base[]
+## Comment for code
# Isn't comment
$result[$.hash_item1[one] $.hash_item2[two]]
+&/code&&/pre&
+&code&\documentclass{article}
+\usepackage[koi8-r]{inputenc}
+\hoffset=0pt
+\voffset=.3em
+\tolerance=400
+\newcommand{\eTiX}{\TeX}
+\begin{document}
+\section*{Highlight.js}
+\begin{table}[c|c]
+$\frac 12\, + \, \frac 1{x^3}\text{Hello \! world}$ & \textbf{Goodbye\~ world} \\\eTiX $ \pi=400 $
+\end{table}
+Ch\'erie, \c{c}a ne me pla\^\i t pas! % comment \b
+G\&otterd\&ammerung~45\%=34.
\int\limits_{0}^{\pi}\frac{4}{x-7}=3
+\end{document}
+&/code&&/pre&
+&h2&Special tests&/h2&
&th&Explicit Python highlighting
+&pre&&code class=&python&&for x in [1, 2, 3]:
+&/code&&/pre&
&th&Language set on &pre&
+&pre class=&python&&&code&for x in [1, 2, 3]:
+&/code&&/pre&
&th&HTML5-style language class (language-python)
+&pre class=&python&&&code&for x in [1, 2, 3]:
+&/code&&/pre&
&th&Replacing TAB with 4 spaces
+&pre&&code class=&python&&for x in [1, 2, 3]:
+ count(x)
+&/code&&/pre&
&th&Custom markup
+&pre&&code&&&a href=&http://dev.w3.org/html5/spec/Overview.html#the-div-element&&div&/a& id=&contents&&
&del&&p&Hello, World!&/del&
+&/code&&/pre&
&th&Custom markup + TAB replacement
+&pre&&code class=&python&&for x in [1, 2, 3]:
+&span style=&background:yellow&& &/span&count(x)
+ if x == 3:
+ &span style=&background:yellow&& &/span&count(x + 1)
+&/code&&/pre&
&th&Disabled highlighting
+&pre&&code class=&no-highlight&&&div id=&contents&&
&p&Hello, World!
+&/code&&/pre&
Index: highlight/readme.eng.txt
===================================================================
--- highlight/readme.eng.txt (revision 0)
+++ highlight/readme.eng.txt (revision 2)
@@ -0,0 +1,486 @@
+# Highlight.js
+Highlight.js highlights syntax in code examples on blogs, forums and
+in fact on any web pages. It's very easy to use because it works
+automatically: finds blocks of code, detects a language, highlights it.
+Autodetection can be fine tuned when it fails by itself (see &Heuristics&).
+## Installation and usage
+Downloaded package includes file &highlight.pack.js& which is a full compressed
+version of the library intended to use in production. All uncompressed source
+files are also available, feel free to look into them!
+The script is installed by linking to a single file and making a single
+initialization call:
&script type=&text/javascript& src=&highlight.pack.js&&&/script&
&script type=&text/javascript&&
hljs.initHighlightingOnLoad();
+Also you can replaces TAB ('\x09') characters used for indentation in your code
+with some fixed number of spaces or with a `&span&` to set them special styling:
&script type=&text/javascript&&
hljs.tabReplace = '
'; // 4 spaces
hljs.tabReplace = '&span class=&indent&&\t&/span&';
hljs.initHighlightingOnLoad();
+Then the script looks in your page for fragments `&pre&&code&...&/code&&/pre&`
+that are used traditionally to mark up code examples. Their content is
+marked up by logical pieces with defined class names.
+### Custom initialization
+If you use different markup for code blocks you can initialize them manually
+with `highlightBlock(code, tabReplace)` function. It takes a DOM element
+containing the code to highlight and optionally a string with which to replace
+TAB characters.
+Initialization using for example jQuery might look like this:
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e, '
+### Styling
+Elements of code marked up with classes can be styled as desired:
.comment {
.keyword {
font-weight:
.python .string {
.html .atribute .value {
+Highligt.js comes with several style themes located in &styles& directory that
+can be used directly or as a base for your own experiments.
+A full list of available classes is below (&Languages&).
+## Export
+File export.html contains a little program that shows and allows to copy and paste
+an HTML code generated by the highlighter for any code snippet. This can be useful
+in situations when one can't use the script itself on a site.
+## Languages
+This is a full list of available classes corresponding to languages'
+syntactic structures. In parentheses after language names are identifiers
+used as class names in `&code&` element.
+Python (&python&):
built-in objects (None, False, True and Ellipsis)
string (of any type)
@-decorator for functions
function header &def some_name(...):&
class header &class SomeName(...):&
name of a function or a class inside a header
everything inside parentheses in a function's or class' header
+Python profiler results (&profile&):
builtin function entry
filename in an entry
profiling summary
header of table of results
column header
function name in an entry (including parentheses)
actual name of a function in an entry (excluding parentheses)
+Ruby (&ruby&):
in-string substitution (#{...})
function header &def some_name(...):&
class header &class SomeName(...):&
name of a function or a class inside a header
name of a parent class
instancevar
instance variable
+Perl (&perl&):
regular expression
subroutine header (from &sub& till &{&)
variable starting with &$&, &%&, &@&
plain old doc
+PHP (&php&):
string (of any type)
phpdoc params in comments
variable starting with &$&
preprocessor
preprocessor marks: &&?php& and &?&&
+Scala (&scala&):
annotation
javadoc comment
javadoctag
@-tag in javadoc
class header
class name inside a header
everything in parentheses inside a class header
inheritance
keywords &extends& and &with& inside class header
+XML (&xml&):
any tag from &&& till &&&
processing instruction (&? ... ?&)
CDATA section
attribute's value
+HTML (&html&):
any tag from &&& till &&&
&!DOCTYPE ... & declaration
tag's attribute with or without value
attribute's value
+CSS (&css&):
HTML tag when in selectors, CSS keyword when in rules
#some_name in selectors
.some_name in selectors
@-rule till first &{& or &;&
attr_selector
attribute selector (square brackets in a[href^=http://])
pseudo classes and elemens (:after, ::after etc.)
everything from &{& till &}&
property's value inside a rule, from &:& till &;& or
till the end of rule block
number within a value
string within a value
hex color (#FFFFFF) within a value
CSS function within a value
everything between &(& and &)& within a function
+Django (&django&):
HTML tag in HTML, default tags and default filters in templates
any tag from &&& till &&&
&!DOCTYPE ... & declaration
tag's attribute with or withou value
attribute's value
template_tag
template tag {% .. %}
template variable {{ .. }}
template_comment template comment, both {# .. #} and {% comment %}
filter from &|& till the next filter or the end of tag
filter argument
+Javascript (&javascript&):
special literal: &true&, &false& and &null&
regular expression
header of a function
name of a function inside a header
everything inside parentheses in a function's header
+VBScript (&vbscript&):
built-in function
+Lua (&lua&):
built-in operator
header of a function
name of a function inside a header
everything inside parentheses in a function's header
long_brackets
multiline string in [=[ .. ]=]
+Delphi (&delphi&):
comment (of any type)
header of a function, procedure, constructor and destructor
name of a function, procedure, constructor or destructor
inside a header
everything inside parentheses in a function's header
class' body from &= class& till &&
+Java (&java&):
annotation
javadoc comment
class header from &class& till &{&
class name inside a header
everything in parentheses inside a class header
inheritance
keywords &extends& and &implements& ins

我要回帖

更多关于 html lt gt 的文章

 

随机推荐