mirror of
https://github.com/ethauvin/kobalt-doc.git
synced 2025-04-25 20:07:11 -07:00
Syntax highlighting.
This commit is contained in:
parent
c11be25ff8
commit
6b7427454a
105 changed files with 17571 additions and 91 deletions
1
sh/tests/.rvmrc
Normal file
1
sh/tests/.rvmrc
Normal file
|
@ -0,0 +1 @@
|
|||
rvm 1.8.7-p249@copydeca
|
204
sh/tests/brushes/sass.html
Normal file
204
sh/tests/brushes/sass.html
Normal file
|
@ -0,0 +1,204 @@
|
|||
<script class="brush: sass;" type="syntaxhighlighter">
|
||||
@mixin round_corners_custom($top, $right, $bottom, $left) {
|
||||
-moz-border-radius: $top $right $bottom $left !important;
|
||||
-webkit-border-radius: $top $right $bottom $left !important;
|
||||
}
|
||||
|
||||
@mixin round_corners($radius) {
|
||||
@include round_corners_custom($radius, $radius, $radius, $radius);
|
||||
}
|
||||
|
||||
.syntaxhighlighter {
|
||||
a,
|
||||
div,
|
||||
code,
|
||||
table,
|
||||
table td,
|
||||
table tr,
|
||||
table tbody,
|
||||
table thead,
|
||||
table caption,
|
||||
textarea {
|
||||
@include round_corners(0);
|
||||
|
||||
background: none !important;
|
||||
border: 0 !important;
|
||||
bottom: auto !important;
|
||||
float: none !important;
|
||||
height: auto !important;
|
||||
left: auto !important;
|
||||
line-height: 1.1em !important;
|
||||
margin: 0 !important;
|
||||
outline: 0 !important;
|
||||
overflow: visible !important;
|
||||
padding: 0 !important;
|
||||
position: static !important;
|
||||
right: auto !important;
|
||||
text-align: left !important;
|
||||
top: auto !important;
|
||||
vertical-align: baseline !important;
|
||||
width: auto !important;
|
||||
font: {
|
||||
family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important;
|
||||
weight: normal !important;
|
||||
style: normal !important;
|
||||
size: 1em !important;
|
||||
}
|
||||
min: {
|
||||
// For IE8, FF & WebKit
|
||||
height: inherit !important;
|
||||
// For IE7
|
||||
height: auto !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.syntaxhighlighter {
|
||||
width: 100% !important;
|
||||
margin: 1em 0 1em 0 !important;
|
||||
|
||||
position: relative !important;
|
||||
overflow: auto !important;
|
||||
font-size: 1em !important;
|
||||
|
||||
&.source { overflow: hidden !important; }
|
||||
|
||||
// set up bold and italic
|
||||
.bold { font-weight: bold !important; }
|
||||
.italic { font-style: italic !important; }
|
||||
|
||||
.line { white-space: pre !important; }
|
||||
|
||||
// main table and columns
|
||||
table {
|
||||
width: 100% !important;
|
||||
caption {
|
||||
text-align: left !important;
|
||||
padding: .5em 0 0.5em 1em !important;
|
||||
}
|
||||
|
||||
td.code {
|
||||
width: 100% !important;
|
||||
|
||||
.container {
|
||||
position: relative !important;
|
||||
|
||||
textarea {
|
||||
position: absolute !important;
|
||||
left: 0 !important;
|
||||
top: 0 !important;
|
||||
width: 100% !important;
|
||||
height: 120% !important;
|
||||
border: none !important;
|
||||
background: white !important;
|
||||
padding-left: 1em !important;
|
||||
overflow: hidden !important;
|
||||
white-space: pre !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// middle spacing between line numbers and lines
|
||||
td.gutter .line {
|
||||
text-align: right !important;
|
||||
padding: 0 0.5em 0 1em !important;
|
||||
}
|
||||
|
||||
td.code .line {
|
||||
padding: 0 1em !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.nogutter {
|
||||
td.code {
|
||||
.container textarea, .line { padding-left: 0em !important; }
|
||||
}
|
||||
}
|
||||
|
||||
&.show { display: block !important; }
|
||||
|
||||
// Adjust some properties when collapsed
|
||||
&.collapsed {
|
||||
table { display: none !important; }
|
||||
|
||||
.toolbar {
|
||||
padding: 0.1em 0.8em 0em 0.8em !important;
|
||||
font-size: 1em !important;
|
||||
position: static !important;
|
||||
width: auto !important;
|
||||
height: auto !important;
|
||||
|
||||
span {
|
||||
display: inline !important;
|
||||
margin-right: 1em !important;
|
||||
|
||||
a {
|
||||
padding: 0 !important;
|
||||
display: none !important;
|
||||
&.expandSource, &.help { display: inline !important; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Styles for the toolbar
|
||||
.toolbar {
|
||||
position: absolute !important;
|
||||
right: 1px !important;
|
||||
top: 1px !important;
|
||||
width: 11px !important;
|
||||
height: 11px !important;
|
||||
font-size: 10px !important;
|
||||
z-index: 10 !important;
|
||||
|
||||
span.title { display: inline !important; }
|
||||
|
||||
a {
|
||||
display: block !important;
|
||||
text-align: center !important;
|
||||
text-decoration: none !important;
|
||||
padding-top: 1px !important;
|
||||
|
||||
&.expandSource { display: none !important; }
|
||||
}
|
||||
}
|
||||
|
||||
// Print view.
|
||||
// Colors are based on the default theme without background.
|
||||
&.printing {
|
||||
.line.alt1 .content,
|
||||
.line.alt2 .content,
|
||||
.line.highlighted .number,
|
||||
.line.highlighted.alt1 .content,
|
||||
.line.highlighted.alt2 .content { background: none !important; }
|
||||
|
||||
// Gutter line numbers
|
||||
.line {
|
||||
.number { color: #bbbbbb !important; }
|
||||
// Add border to the lines
|
||||
.content { color: black !important; }
|
||||
}
|
||||
|
||||
// Toolbar when visible
|
||||
.toolbar { display: none !important; }
|
||||
a { text-decoration: none !important; }
|
||||
.plain, .plain a { color: black !important; }
|
||||
.comments, .comments a { color: #008200 !important; }
|
||||
.string, .string a { color: blue !important; }
|
||||
.keyword {
|
||||
color: #006699 !important;
|
||||
font-weight: bold !important;
|
||||
}
|
||||
.preprocessor { color: gray !important; }
|
||||
.variable { color: #aa7700 !important; }
|
||||
.value { color: #009900 !important; }
|
||||
.functions { color: #ff1493 !important; }
|
||||
.constants { color: #0066cc !important; }
|
||||
.script { font-weight: bold !important; }
|
||||
.color1, .color1 a { color: gray !important; }
|
||||
.color2, .color2 a { color: #ff1493 !important; }
|
||||
.color3, .color3 a { color: red !important; }
|
||||
.break, .break a { color: black !important; }
|
||||
}
|
||||
}
|
||||
</script>
|
136
sh/tests/brushes_tests.html
Normal file
136
sh/tests/brushes_tests.html
Normal file
|
@ -0,0 +1,136 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>SyntaxHighlighter Brushes Tests</title>
|
||||
<script type="text/javascript" src="/js/jquery-1.4.2.js"></script>
|
||||
|
||||
<!-- SyntaxHighlighter -->
|
||||
<script type="text/javascript" src="/sh/scripts/XRegExp.js"></script> <!-- XRegExp is bundled with the final shCore.js during build -->
|
||||
<script type="text/javascript" src="/sh/scripts/shCore.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shAutoloader.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushAppleScript.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushAS3.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushBash.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushColdFusion.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushCpp.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushCSharp.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushCss.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushDelphi.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushDiff.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushErlang.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushGroovy.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushJava.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushJavaFx.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushJScript.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPerl.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPhp.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPlain.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPowerShell.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPython.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushRuby.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushSass.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushScala.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushSql.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushVb.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushXml.js"></script>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/sh/styles/shCoreDefault.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="output"></div>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: white;
|
||||
font-family: Helvetica;
|
||||
}
|
||||
|
||||
.test-wrap {
|
||||
width: 100%;
|
||||
height: 800px;
|
||||
overflow: auto;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
var brushes = [
|
||||
'AS3',
|
||||
'AppleScript',
|
||||
'Bash',
|
||||
'CSharp',
|
||||
'ColdFusion',
|
||||
'Cpp',
|
||||
'Css',
|
||||
'Delphi',
|
||||
'Diff',
|
||||
'Erlang',
|
||||
'Groovy',
|
||||
'JScript',
|
||||
'Java',
|
||||
'JavaFX',
|
||||
'Perl',
|
||||
'Php',
|
||||
'Plain',
|
||||
'PowerShell',
|
||||
'Python',
|
||||
'Ruby',
|
||||
'Sass',
|
||||
'Scala',
|
||||
'Sql',
|
||||
'Vb',
|
||||
'Xml'
|
||||
];
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
var html = '';
|
||||
|
||||
$.each(brushes, function(index)
|
||||
{
|
||||
var name = this;
|
||||
|
||||
html += ''
|
||||
+ '<div class="test-wrap">'
|
||||
+ '<h1>'
|
||||
+ '<a href="#theme' + (index + 1) + '">next</a> '
|
||||
+ '<a name="theme' + index + '">'
|
||||
+ name
|
||||
+ '</a>'
|
||||
+ '</h1>'
|
||||
;
|
||||
|
||||
$.ajax({
|
||||
url: 'brushes/' + name.toLowerCase() + '.html',
|
||||
type: 'GET',
|
||||
dataType: 'text',
|
||||
async: false,
|
||||
success: function(data)
|
||||
{
|
||||
html += data;
|
||||
},
|
||||
error: function()
|
||||
{
|
||||
html += '<p>Not found...</p>';
|
||||
}
|
||||
});
|
||||
|
||||
html += '</div>\n';
|
||||
|
||||
if (index % 2 != 0)
|
||||
html += '<div style="clear:both"></div>\n';
|
||||
});
|
||||
|
||||
$('#output')[0].innerHTML = html;
|
||||
$('#output a[name]:first').attr('name', 'top');
|
||||
$('#output a[href]:last').attr('href', '#top').html('top');
|
||||
|
||||
SyntaxHighlighter.highlight();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
42
sh/tests/cases/001_basic.html
Normal file
42
sh/tests/cases/001_basic.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<pre id="sh_001_basic" class="brush: js;" title="Title/caption should render">
|
||||
/**
|
||||
* multiline comment
|
||||
*/
|
||||
|
||||
text
|
||||
|
||||
// single line comment
|
||||
|
||||
text
|
||||
|
||||
"string" text 'string' text "string"
|
||||
"string with \" escape" text 'string with \' escape' text "string with \" escape"
|
||||
|
||||
var code = '\
|
||||
function helloWorld()\
|
||||
{\
|
||||
// this is great!\
|
||||
for(var i = 0; i <= 1; i++)\
|
||||
alert("yay");\
|
||||
}\
|
||||
';
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('001_basic');
|
||||
|
||||
test('basic html check of default elements', function()
|
||||
{
|
||||
$sh = $('#sh_001_basic');
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_caption($sh, 'Title/caption should render');
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
});
|
||||
});
|
||||
</script>
|
50
sh/tests/cases/002_brushes.html
Normal file
50
sh/tests/cases/002_brushes.html
Normal file
|
@ -0,0 +1,50 @@
|
|||
<div id="sh_002_brushes">
|
||||
<pre class="brush: applescript;">test</pre>
|
||||
<pre class="brush: as3;">test</pre>
|
||||
<pre class="brush: bash;">test</pre>
|
||||
<pre class="brush: cf;">test</pre>
|
||||
<pre class="brush: cpp;">test</pre>
|
||||
<pre class="brush: csharp;">test</pre>
|
||||
<pre class="brush: css;">test</pre>
|
||||
<pre class="brush: delphi;">test</pre>
|
||||
<pre class="brush: diff;">test</pre>
|
||||
<pre class="brush: erlang;">test</pre>
|
||||
<pre class="brush: groovy;">test</pre>
|
||||
<pre class="brush: java;">test</pre>
|
||||
<pre class="brush: javafx;">test</pre>
|
||||
<pre class="brush: jscript;">test</pre>
|
||||
<pre class="brush: perl;">test</pre>
|
||||
<pre class="brush: php;">test</pre>
|
||||
<pre class="brush: plain;">test</pre>
|
||||
<pre class="brush: powershell;">test</pre>
|
||||
<pre class="brush: python;">test</pre>
|
||||
<pre class="brush: ruby;">test</pre>
|
||||
<pre class="brush: sass;">test</pre>
|
||||
<pre class="brush: scala;">test</pre>
|
||||
<pre class="brush: sql;">test</pre>
|
||||
<pre class="brush: vb;">test</pre>
|
||||
<pre class="brush: xml;">test</pre>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('002_brushes');
|
||||
|
||||
test('check that all brushes loaded and rendered', function()
|
||||
{
|
||||
$sh = $('#sh_002_brushes');
|
||||
|
||||
$sh.find('> div > .syntaxhighlighter').each(function()
|
||||
{
|
||||
var $sh = $(this).parent();
|
||||
ok_sh($sh);
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
42
sh/tests/cases/003_script_tag.html
Normal file
42
sh/tests/cases/003_script_tag.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<div>
|
||||
<script id="sh_003_script_tag" type="syntaxhighlighter" class="brush: csharp" title="Title/caption should render"><![CDATA[
|
||||
partial class Foo
|
||||
{
|
||||
function test()
|
||||
{
|
||||
yield return;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
function foo()
|
||||
{
|
||||
var vector:Vector.<Vector.<String>> = new Vector<Vector.String>>();
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
/* comments */
|
||||
}
|
||||
}
|
||||
]]></script>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('003_script_tag');
|
||||
|
||||
test('basic html check of default elements', function()
|
||||
{
|
||||
$sh = $('#sh_003_script_tag');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_caption($sh, 'Title/caption should render');
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
});
|
||||
});
|
||||
</script>
|
43
sh/tests/cases/004_url_parsing.html
Normal file
43
sh/tests/cases/004_url_parsing.html
Normal file
|
@ -0,0 +1,43 @@
|
|||
<pre id="sh_004_url_parsing" class="brush: as3;">
|
||||
/**
|
||||
* Please see <http://www.alexgorbatchev.come/?test=1&y=2>
|
||||
*/
|
||||
var home = "http://www.alexgorbatchev.come/?test=1&y=2;test/1/2/3;";
|
||||
// < http://www.gnu.org/licenses/?test=1&y=2 >.
|
||||
|
||||
// Test embedded URLs that terminate at a left angle bracket.
|
||||
// See bug #28: http://bitbucket.org/alexg/syntaxhighlighter/issue/28/
|
||||
"<location>http://www.example.com/song2.mp3</location>";
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('004_url_parsing');
|
||||
|
||||
test('check that urls are present', function()
|
||||
{
|
||||
$sh = $('#sh_004_url_parsing');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
|
||||
var expected = [
|
||||
'http://www.alexgorbatchev.come/?test=1&y=2',
|
||||
'http://www.alexgorbatchev.come/?test=1&y=2;test/1/2/3;',
|
||||
'http://www.gnu.org/licenses/?test=1&y=2',
|
||||
'http://bitbucket.org/alexg/syntaxhighlighter/issue/28/',
|
||||
'http://www.example.com/song2.mp3'
|
||||
];
|
||||
|
||||
$sh.find('td.code a').each(function(index)
|
||||
{
|
||||
equal($(this).attr('href'), expected[index], 'href');
|
||||
equal($(this).text(), expected[index], 'text');
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
33
sh/tests/cases/005_no_gutter.html
Normal file
33
sh/tests/cases/005_no_gutter.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
<pre id="sh_005_no_gutter" class="brush: java; gutter: false;">
|
||||
public Image getImage(URL url, String name) {
|
||||
try {
|
||||
/*
|
||||
Regular multiline comment.
|
||||
*/
|
||||
return getImage(new URL(url, name));
|
||||
} catch (MalformedURLException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('005_no_gutter');
|
||||
|
||||
test('check that there is no gutter', function()
|
||||
{
|
||||
$sh = $('#sh_005_no_gutter');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
|
||||
ok($sh.find('> .syntaxhighlighter.nogutter').length == 1, '.nogutter present');
|
||||
ok($sh.find('> .syntaxhighlighter > table > tbody > tr > .gutter').length == 0, 'Gutter not present');
|
||||
});
|
||||
});
|
||||
</script>
|
39
sh/tests/cases/006_pad_line_numbers.html
Normal file
39
sh/tests/cases/006_pad_line_numbers.html
Normal file
|
@ -0,0 +1,39 @@
|
|||
<pre id="sh_006_pad_line_numbers" class="brush: java; pad-line-numbers: true">
|
||||
/**
|
||||
* Returns an Image object that can then be painted on the screen.
|
||||
* The url argument must specify an absolute {@link URL}. The name
|
||||
* argument is a specifier that is relative to the url argument.
|
||||
*
|
||||
* @param url an absolute URL giving the base location of the image
|
||||
* @param name the location of the image, relative to the url argument
|
||||
* @return the image at the specified URL
|
||||
* @see Image
|
||||
*/
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('006_pad_line_numbers');
|
||||
|
||||
test('check that line numbers are padded with zeroes', function()
|
||||
{
|
||||
$sh = $('#sh_006_pad_line_numbers');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
|
||||
$sh.find('.gutter > .line').each(function(index)
|
||||
{
|
||||
var text = $(this).text();
|
||||
|
||||
if (parseInt(text) < 10)
|
||||
ok(text.charAt(0) == '0', 'Line ' + index + ' has leading zero: ' + text);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
60
sh/tests/cases/007_collapse.html
Normal file
60
sh/tests/cases/007_collapse.html
Normal file
|
@ -0,0 +1,60 @@
|
|||
<pre id="sh_007_collapse_a" class="brush: groovy; collapse: true" title="This is a title for collapsed block">
|
||||
/**
|
||||
* Returns an Image object that can then be painted on the screen.
|
||||
* The url argument must specify an absolute {@link URL}. The name
|
||||
* argument is a specifier that is relative to the url argument.
|
||||
*
|
||||
* @param url an absolute URL giving the base location of the image
|
||||
* @param name the location of the image, relative to the url argument
|
||||
* @return the image at the specified URL
|
||||
* @see Image
|
||||
*/
|
||||
</pre>
|
||||
|
||||
<pre id="sh_007_collapse_b" class="brush: groovy; collapse: true">
|
||||
/**
|
||||
* Returns an Image object that can then be painted on the screen.
|
||||
* The url argument must specify an absolute {@link URL}. The name
|
||||
* argument is a specifier that is relative to the url argument.
|
||||
*
|
||||
* @param url an absolute URL giving the base location of the image
|
||||
* @param name the location of the image, relative to the url argument
|
||||
* @return the image at the specified URL
|
||||
* @see Image
|
||||
*/
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('007_collapse');
|
||||
|
||||
test('collapsed block with title', function()
|
||||
{
|
||||
$sh = $('#sh_007_collapse_a');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_collapsed($sh);
|
||||
|
||||
var $title = $sh.find('.toolbar a.toolbar_item.command_expandSource');
|
||||
ok($title.length == 1, 'Expand present');
|
||||
equal($title.text(), 'This is a title for collapsed block', 'Expand text');
|
||||
});
|
||||
|
||||
test('collapsed block without title', function()
|
||||
{
|
||||
$sh = $('#sh_007_collapse_b');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_collapsed($sh);
|
||||
|
||||
var $title = $sh.find('.toolbar a.toolbar_item.command_expandSource');
|
||||
ok($title.length == 1, 'Expand present');
|
||||
equal($title.text(), SyntaxHighlighter.config.strings.expandSource, 'Expand text');
|
||||
});
|
||||
});
|
||||
</script>
|
44
sh/tests/cases/007_collapse_interaction.html
Normal file
44
sh/tests/cases/007_collapse_interaction.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('007_collapse_interaction');
|
||||
|
||||
function clickA($a)
|
||||
{
|
||||
SyntaxHighlighter.toolbar.handler({
|
||||
target: $a[0],
|
||||
preventDefault: function() {}
|
||||
});
|
||||
};
|
||||
|
||||
test('expand collapsed block with title', function()
|
||||
{
|
||||
$sh = $('#sh_007_collapse_a');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_collapsed($sh);
|
||||
|
||||
var $a = $sh.find('.toolbar a.toolbar_item.command_expandSource');
|
||||
clickA($a);
|
||||
ok($a.not(':visible'), 'Expand not visible');
|
||||
ok_code($sh);
|
||||
});
|
||||
|
||||
test('expand collapsed block without title', function()
|
||||
{
|
||||
$sh = $('#sh_007_collapse_b');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_collapsed($sh);
|
||||
|
||||
var $a = $sh.find('.toolbar a.toolbar_item.command_expandSource');
|
||||
clickA($a);
|
||||
ok($a.not(':visible'), 'Expand not visible');
|
||||
ok_code($sh);
|
||||
});
|
||||
});
|
||||
</script>
|
29
sh/tests/cases/008_first_line.html
Normal file
29
sh/tests/cases/008_first_line.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<pre id="sh_008_first_line" class="brush: java; first-line: 10">
|
||||
partial class Foo
|
||||
{
|
||||
function test()
|
||||
{
|
||||
yield return;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('008_first_line');
|
||||
|
||||
test('check the first line', function()
|
||||
{
|
||||
$sh = $('#sh_008_first_line');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
equals($sh.find('.gutter .index0').text(), '10', 'First line');
|
||||
});
|
||||
});
|
||||
</script>
|
32
sh/tests/cases/009_class_name.html
Normal file
32
sh/tests/cases/009_class_name.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<pre id="sh_009_class_name" class="brush: java; class-name: 'custom class here'">
|
||||
public Image getImage(URL url, String name) {
|
||||
try {
|
||||
/*
|
||||
Regular multiline comment.
|
||||
*/
|
||||
return getImage(new URL(url, name));
|
||||
} catch (MalformedURLException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('009_class_name');
|
||||
|
||||
test('check custom classes', function()
|
||||
{
|
||||
$sh = $('#sh_009_class_name');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
ok($sh.find('.syntaxhighlighter').is('.custom.class.here'), 'Check custom classes');
|
||||
});
|
||||
});
|
||||
</script>
|
70
sh/tests/cases/010_highlight.html
Normal file
70
sh/tests/cases/010_highlight.html
Normal file
|
@ -0,0 +1,70 @@
|
|||
<pre id="sh_010_highlight_a" class="brush: groovy; highlight: 2">
|
||||
public function validateStrongPassword(password:String):Boolean
|
||||
{
|
||||
if (password == null || password.length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return STRONG_PASSWORD_PATTERN.test(password);
|
||||
}
|
||||
</pre>
|
||||
<script id="sh_010_highlight_b" type="syntaxhighlighter" class="brush: as3; highlight: [2, 4, 12]"><![CDATA[
|
||||
/**
|
||||
* Checks a password and returns a value indicating whether the password is a "strong"
|
||||
* password. The criteria for a strong password are:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Minimum 8 characters</li>
|
||||
* <li>Maxmium 32 characters</li>
|
||||
* <li>Contains at least one lowercase letter</li>
|
||||
* <li>Contains at least one uppercase letter</li>
|
||||
* <li>Contains at least one number or symbol character</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param password The password to check
|
||||
*
|
||||
* @return A value indicating whether the password is a strong password (<code>true</code>)
|
||||
* or not (<code>false</code>).
|
||||
*/
|
||||
public function validateStrongPassword(password:String):Boolean
|
||||
{
|
||||
if (password == null || password.length <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return STRONG_PASSWORD_PATTERN.test(password);
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('010_highlight');
|
||||
|
||||
test('one highlighted line', function()
|
||||
{
|
||||
$sh = $('#sh_010_highlight_a');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
ok($sh.find('.gutter .number2').is('.highlighted'), 'Line 2 is highlighted');
|
||||
});
|
||||
|
||||
test('multiple highlighted lines', function()
|
||||
{
|
||||
$sh = $('#sh_010_highlight_b');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
ok($sh.find('.gutter .number2').is('.highlighted'), 'Line 2 is highlighted');
|
||||
ok($sh.find('.gutter .number4').is('.highlighted'), 'Line 4 is highlighted');
|
||||
ok($sh.find('.gutter .number12').is('.highlighted'), 'Line 12 is highlighted');
|
||||
});
|
||||
});
|
||||
</script>
|
98
sh/tests/cases/011_smart_tabs.html
Normal file
98
sh/tests/cases/011_smart_tabs.html
Normal file
|
@ -0,0 +1,98 @@
|
|||
<pre id="sh_011_smart_tabs_a" class="brush: plain;">
|
||||
the words in this paragraph
|
||||
should look like they are
|
||||
evenly spaced between columns
|
||||
</pre>
|
||||
|
||||
<pre id="sh_011_smart_tabs_b" class="brush: plain; tab-size: 8;">
|
||||
the words in this paragraph
|
||||
should look like they are
|
||||
evenly spaced between columns
|
||||
</pre>
|
||||
|
||||
<pre id="sh_011_smart_tabs_c" class="brush: plain; smart-tabs: false">
|
||||
the words in this paragraph
|
||||
should look out of whack
|
||||
because smart tabs are disabled
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('011_smart_tabs');
|
||||
|
||||
var evenLines = [
|
||||
'the words in this paragraph',
|
||||
'should look like they are',
|
||||
'evenly spaced between columns'
|
||||
],
|
||||
unevenLines = [
|
||||
'the words in this paragraph',
|
||||
'should look out of whack',
|
||||
'because smart tabs are disabled'
|
||||
]
|
||||
;
|
||||
|
||||
function fixSpaces(s)
|
||||
{
|
||||
s = encodeURIComponent(s).replace(/%C2%A0/g, '%20');
|
||||
return unescape(s).replace(/\s+$/g, '');
|
||||
};
|
||||
|
||||
test('default tab size is 4', function()
|
||||
{
|
||||
$sh = $('#sh_011_smart_tabs_a');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
|
||||
$sh.find('.code .line').each(function(index)
|
||||
{
|
||||
var s1 = fixSpaces($(this).text()),
|
||||
s2 = fixSpaces(evenLines[index])
|
||||
;
|
||||
|
||||
equal(s1, s2, 'Line ' + index);
|
||||
});
|
||||
});
|
||||
|
||||
test('tab size changed to 8', function()
|
||||
{
|
||||
$sh = $('#sh_011_smart_tabs_b');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
|
||||
$sh.find('.code .line').each(function(index)
|
||||
{
|
||||
var s1 = fixSpaces($(this).text()),
|
||||
s2 = fixSpaces(evenLines[index])
|
||||
;
|
||||
|
||||
equal(s1, s2, 'Line ' + index);
|
||||
});
|
||||
});
|
||||
|
||||
test('smart tabs are off', function()
|
||||
{
|
||||
$sh = $('#sh_011_smart_tabs_c');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
|
||||
$sh.find('.code .line').each(function(index)
|
||||
{
|
||||
var s1 = fixSpaces($(this).text()),
|
||||
s2 = fixSpaces(unevenLines[index])
|
||||
;
|
||||
|
||||
equal(s1, s2, 'Line ' + index);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
35
sh/tests/cases/012_server_side.html
Normal file
35
sh/tests/cases/012_server_side.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<script id="sh_012_server_side_input" type="text/plain">
|
||||
function helloWorld()
|
||||
{
|
||||
// this is great!
|
||||
for(var i = 0; i <= 1; i++)
|
||||
alert("yay");
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="sh_012_server_side_output">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('012_server_side');
|
||||
|
||||
test('generate markup', function()
|
||||
{
|
||||
var brush = new SyntaxHighlighter.brushes.JScript(),
|
||||
code = $('#sh_012_server_side_input').html()
|
||||
;
|
||||
|
||||
brush.init({ toolbar: false });
|
||||
$sh = $('#sh_012_server_side_output');
|
||||
$sh.html(brush.getHtml(code));
|
||||
|
||||
ok_sh($sh);
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
});
|
||||
});
|
||||
</script>
|
34
sh/tests/cases/013_html_script.html
Normal file
34
sh/tests/cases/013_html_script.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<pre id="sh_013_html_script" class="brush: groovy; html-script: true">
|
||||
<hello>
|
||||
<%
|
||||
package free.cafekiwi.gotapi;
|
||||
%>
|
||||
</hello>
|
||||
|
||||
<!--
|
||||
Comments here
|
||||
-->
|
||||
<%= print(); %>
|
||||
</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
module('013_html_script');
|
||||
|
||||
test('check markup', function()
|
||||
{
|
||||
$sh = $('#sh_013_html_script');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
|
||||
ok($sh.find('.code .number1 > .htmlscript').length > 0, 'Has .htmlscript on line 1');
|
||||
ok($sh.find('.code .number3 > .groovy').length > 0, 'Has .groovy on line 3');
|
||||
ok($sh.find('.code .number10 > .groovy').length > 0, 'Has .groovy on line 10');
|
||||
});
|
||||
});
|
||||
</script>
|
70
sh/tests/cases/014_legacy.html
Normal file
70
sh/tests/cases/014_legacy.html
Normal file
|
@ -0,0 +1,70 @@
|
|||
<pre id="sh_014_legacy_a" name="code" class="plain">basic check</pre>
|
||||
<pre id="sh_014_legacy_b" name="code" class="plain:nocontrols">no toolbar</pre>
|
||||
<pre id="sh_014_legacy_c" name="code" class="plain:nogutter">no gutter</pre>
|
||||
<pre id="sh_014_legacy_d" name="code" class="plain:collapse">collapsed</pre>
|
||||
<pre id="sh_014_legacy_e" name="code" class="plain:firstline[10]">first line</pre>
|
||||
|
||||
<script type="text/javascript">
|
||||
queue(function()
|
||||
{
|
||||
var $sh;
|
||||
|
||||
dp.SyntaxHighlighter.HighlightAll('code');
|
||||
|
||||
module('014_legacy');
|
||||
|
||||
test('basic check', function()
|
||||
{
|
||||
$sh = $('#sh_014_legacy_a');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
});
|
||||
|
||||
test('no toolbar', function()
|
||||
{
|
||||
$sh = $('#sh_014_legacy_b');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_code($sh);
|
||||
ok($sh.find('> .syntaxhighlighter > .toolbar').length == 0, 'Toolbar not present');
|
||||
});
|
||||
|
||||
test('no gutter', function()
|
||||
{
|
||||
$sh = $('#sh_014_legacy_c');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_code($sh);
|
||||
|
||||
ok($sh.find('> .syntaxhighlighter.nogutter').length == 1, '.nogutter present');
|
||||
ok($sh.find('> .syntaxhighlighter > table > tbody > tr > .gutter').length == 0, 'Gutter not present');
|
||||
});
|
||||
|
||||
test('collapsed check', function()
|
||||
{
|
||||
$sh = $('#sh_014_legacy_d');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_collapsed($sh);
|
||||
|
||||
var $title = $sh.find('.toolbar a.toolbar_item.command_expandSource');
|
||||
ok($title.length == 1, 'Expand present');
|
||||
equal($title.text(), SyntaxHighlighter.config.strings.expandSource, 'Expand text');
|
||||
});
|
||||
|
||||
test('first line check', function()
|
||||
{
|
||||
$sh = $('#sh_014_legacy_e');
|
||||
|
||||
ok_sh($sh);
|
||||
ok_toolbar($sh);
|
||||
ok_gutter($sh);
|
||||
ok_code($sh);
|
||||
equals($sh.find('.gutter .index0').text(), '10', 'First line');
|
||||
});
|
||||
});
|
||||
</script>
|
52
sh/tests/commonjs_tests.js
Normal file
52
sh/tests/commonjs_tests.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* This is a CommonJS compatibility test. You can run this file with node.
|
||||
*/
|
||||
require.paths.unshift(__dirname + '/../scripts');
|
||||
|
||||
var sys = require('sys'),
|
||||
shSyntaxHighlighter = require('shCore').SyntaxHighlighter,
|
||||
code = 'test',
|
||||
brushes = [
|
||||
'AS3',
|
||||
'AppleScript',
|
||||
'Bash',
|
||||
'CSharp',
|
||||
'ColdFusion',
|
||||
'Cpp',
|
||||
'Css',
|
||||
'Delphi',
|
||||
'Diff',
|
||||
'Erlang',
|
||||
'Groovy',
|
||||
'JScript',
|
||||
'Java',
|
||||
'JavaFX',
|
||||
'Perl',
|
||||
'Php',
|
||||
'Plain',
|
||||
'PowerShell',
|
||||
'Python',
|
||||
'Ruby',
|
||||
'Sass',
|
||||
'Scala',
|
||||
'Sql',
|
||||
'Vb',
|
||||
'Xml'
|
||||
]
|
||||
;
|
||||
|
||||
brushes.sort();
|
||||
|
||||
for (var i = 0; i < brushes.length; i++)
|
||||
{
|
||||
var name = brushes[i],
|
||||
brush = require('shBrush' + name).Brush
|
||||
;
|
||||
|
||||
brush = new brush();
|
||||
brush.init({ toolbar: false });
|
||||
|
||||
var result = brush.getHtml(code);
|
||||
|
||||
sys.puts(name + (result != null ? ': ok' : ': NOT OK'));
|
||||
}
|
6240
sh/tests/js/jquery-1.4.2.js
vendored
Normal file
6240
sh/tests/js/jquery-1.4.2.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
135
sh/tests/js/qunit.css
Normal file
135
sh/tests/js/qunit.css
Normal file
|
@ -0,0 +1,135 @@
|
|||
/**
|
||||
* SyntaxHighlighter
|
||||
* http://alexgorbatchev.com/SyntaxHighlighter
|
||||
*
|
||||
* SyntaxHighlighter is donationware. If you are using it, please donate.
|
||||
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
|
||||
*
|
||||
* @version
|
||||
* 3.0.83 (July 02 2010)
|
||||
*
|
||||
* @copyright
|
||||
* Copyright (C) 2004-2010 Alex Gorbatchev.
|
||||
*
|
||||
* @license
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
*/
|
||||
|
||||
ol#qunit-tests {
|
||||
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
margin:0;
|
||||
padding:0;
|
||||
list-style-position:inside;
|
||||
|
||||
font-size: smaller;
|
||||
}
|
||||
ol#qunit-tests li{
|
||||
padding:0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom:1px solid #fff;
|
||||
font-size:small;
|
||||
list-style-position:inside;
|
||||
}
|
||||
ol#qunit-tests li ol{
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
margin-top:0.5em;
|
||||
margin-left:0;
|
||||
padding:0.5em;
|
||||
background-color:#fff;
|
||||
border-radius:15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
}
|
||||
ol#qunit-tests li li{
|
||||
border-bottom:none;
|
||||
margin:0.5em;
|
||||
background-color:#fff;
|
||||
list-style-position: inside;
|
||||
padding:0.4em 0.5em 0.4em 0.5em;
|
||||
}
|
||||
|
||||
ol#qunit-tests li li.pass{
|
||||
border-left:26px solid #C6E746;
|
||||
background-color:#fff;
|
||||
color:#5E740B;
|
||||
}
|
||||
ol#qunit-tests li li.fail{
|
||||
border-left:26px solid #EE5757;
|
||||
background-color:#fff;
|
||||
color:#710909;
|
||||
}
|
||||
ol#qunit-tests li.pass{
|
||||
background-color:#D2E0E6;
|
||||
color:#528CE0;
|
||||
}
|
||||
ol#qunit-tests li.fail{
|
||||
background-color:#EE5757;
|
||||
color:#000;
|
||||
}
|
||||
ol#qunit-tests li strong {
|
||||
cursor:pointer;
|
||||
}
|
||||
h1#qunit-header{
|
||||
background-color:#0d3349;
|
||||
margin:0;
|
||||
padding:0.5em 0 0.5em 1em;
|
||||
color:#fff;
|
||||
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
border-top-right-radius:15px;
|
||||
border-top-left-radius:15px;
|
||||
-moz-border-radius-topright:15px;
|
||||
-moz-border-radius-topleft:15px;
|
||||
-webkit-border-top-right-radius:15px;
|
||||
-webkit-border-top-left-radius:15px;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
|
||||
}
|
||||
h2#qunit-banner{
|
||||
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
height:5px;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
h2#qunit-banner.qunit-pass{
|
||||
background-color:#C6E746;
|
||||
}
|
||||
h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar {
|
||||
background-color:#EE5757;
|
||||
}
|
||||
#qunit-testrunner-toolbar {
|
||||
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
padding:0;
|
||||
/*width:80%;*/
|
||||
padding:0em 0 0.5em 2em;
|
||||
font-size: small;
|
||||
}
|
||||
h2#qunit-userAgent {
|
||||
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
background-color:#2b81af;
|
||||
margin:0;
|
||||
padding:0;
|
||||
color:#fff;
|
||||
font-size: small;
|
||||
padding:0.5em 0 0.5em 2.5em;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
p#qunit-testresult{
|
||||
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
margin:0;
|
||||
font-size: small;
|
||||
color:#2b81af;
|
||||
border-bottom-right-radius:15px;
|
||||
border-bottom-left-radius:15px;
|
||||
-moz-border-radius-bottomright:15px;
|
||||
-moz-border-radius-bottomleft:15px;
|
||||
-webkit-border-bottom-right-radius:15px;
|
||||
-webkit-border-bottom-left-radius:15px;
|
||||
background-color:#D2E0E6;
|
||||
padding:0.5em 0.5em 0.5em 2.5em;
|
||||
}
|
||||
strong b.fail{
|
||||
color:#710909;
|
||||
}
|
||||
strong b.pass{
|
||||
color:#5E740B;
|
||||
}
|
1069
sh/tests/js/qunit.js
Normal file
1069
sh/tests/js/qunit.js
Normal file
File diff suppressed because it is too large
Load diff
242
sh/tests/syntaxhighlighter_tests.html
Normal file
242
sh/tests/syntaxhighlighter_tests.html
Normal file
|
@ -0,0 +1,242 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>SyntaxHighlighter Highlight Tests</title>
|
||||
|
||||
<!-- jQuery & QUnit -->
|
||||
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
|
||||
<script type="text/javascript" src="js/qunit.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="js/qunit.css"/>
|
||||
|
||||
<!-- SyntaxHighlighter -->
|
||||
<script type="text/javascript" src="/sh/scripts/XRegExp.js"></script> <!-- XRegExp is bundled with the final shCore.js during build -->
|
||||
<script type="text/javascript" src="/sh/scripts/shCore.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shLegacy.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushAppleScript.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushAS3.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushBash.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushColdFusion.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushCpp.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushCSharp.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushCss.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushDelphi.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushDiff.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushErlang.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushGroovy.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushJava.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushJavaFx.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushJScript.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPerl.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPhp.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPlain.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPowerShell.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushPython.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushRuby.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushSass.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushScala.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushSql.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushVb.js"></script>
|
||||
<script type="text/javascript" src="/sh/scripts/shBrushXml.js"></script>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/sh/styles/shCoreDefault.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1 id="qunit-header">SyntaxHighlighter Highlight Lines Test</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
|
||||
<button id="interaction">Run interaction tests</button>
|
||||
|
||||
<div id="output">
|
||||
</div>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: white;
|
||||
}
|
||||
|
||||
#interaction {
|
||||
margin-top: 1em;
|
||||
padding: 1em;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.test-wrap {
|
||||
width: 45%;
|
||||
height: 400px;
|
||||
overflow: auto;
|
||||
float: left;
|
||||
margin: 1em 1em 0 0;
|
||||
border: 5px solid silver;
|
||||
background: gray;
|
||||
font-family: Helvetica;
|
||||
}
|
||||
|
||||
.test-wrap h3 {
|
||||
margin: 1em 0 0 1em;
|
||||
color: white;
|
||||
font-size: 1em;
|
||||
font-weight: normal;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
var testQueue = [],
|
||||
renderTests = [
|
||||
'001_basic',
|
||||
'002_brushes',
|
||||
'003_script_tag',
|
||||
'004_url_parsing',
|
||||
'005_no_gutter',
|
||||
'006_pad_line_numbers',
|
||||
'007_collapse',
|
||||
'008_first_line',
|
||||
'009_class_name',
|
||||
'010_highlight',
|
||||
'011_smart_tabs',
|
||||
'012_server_side',
|
||||
'013_html_script',
|
||||
'014_legacy'
|
||||
],
|
||||
interactionTests = [
|
||||
'007_collapse_interaction'
|
||||
]
|
||||
;
|
||||
|
||||
function queue(func)
|
||||
{
|
||||
testQueue.push(func);
|
||||
};
|
||||
|
||||
function ok_sh($sh)
|
||||
{
|
||||
ok($sh.length > 0, 'Element present');
|
||||
ok($sh.is('div'), 'Element is DIV');
|
||||
ok($sh.find('> div').is('.syntaxhighlighter'), 'Nested DIV is a .syntaxhighlighter');
|
||||
};
|
||||
|
||||
function ok_toolbar($sh)
|
||||
{
|
||||
var $target = $sh.find('> .syntaxhighlighter > .toolbar');
|
||||
ok($target.length > 0, 'Toolbar present');
|
||||
ok($target.is(':visible'), 'Toolbar visible');
|
||||
};
|
||||
|
||||
function ok_caption($sh, value)
|
||||
{
|
||||
var $target = $sh.find('> .syntaxhighlighter > table > caption');
|
||||
ok($target.length > 0, 'Caption present');
|
||||
ok($target.is(':visible'), 'Caption visible');
|
||||
|
||||
if (value != null)
|
||||
equals($target.text(), value, 'Caption text');
|
||||
};
|
||||
|
||||
function ok_gutter($sh)
|
||||
{
|
||||
var $target = $sh.find('> .syntaxhighlighter > table > tbody > tr > .gutter');
|
||||
ok($target.length > 0, 'Gutter present');
|
||||
ok($target.is(':visible'), 'Gutter visible');
|
||||
};
|
||||
|
||||
function ok_code($sh)
|
||||
{
|
||||
var $target = $sh.find('> .syntaxhighlighter > table > tbody > tr > .code');
|
||||
ok($target.length > 0, 'Code present');
|
||||
ok($target.is(':visible'), 'Code visible');
|
||||
};
|
||||
|
||||
function ok_collapsed($sh)
|
||||
{
|
||||
ok($sh.find('> .syntaxhighlighter.collapsed').length == 1, '.collapsed present');
|
||||
};
|
||||
|
||||
function loadTests(tests, addHtml)
|
||||
{
|
||||
var html = '';
|
||||
|
||||
$.each(tests, function(index)
|
||||
{
|
||||
var name = this;
|
||||
|
||||
if (addHtml != false)
|
||||
{
|
||||
html += '<div class="test-wrap">\n'
|
||||
html += '<h3>' + name + '</h3>\n';
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: 'cases/' + name + '.html',
|
||||
type: 'GET',
|
||||
dataType: 'text',
|
||||
async: false,
|
||||
success: function(data)
|
||||
{
|
||||
html += data;
|
||||
},
|
||||
error: function()
|
||||
{
|
||||
html += '<p>Not found...</p>';
|
||||
}
|
||||
});
|
||||
|
||||
if (addHtml != false)
|
||||
{
|
||||
html += '</div>\n';
|
||||
|
||||
if (index % 2 != 0)
|
||||
html += '<div style="clear:both"></div>\n';
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Looks like .html() is producing different results when it comes to
|
||||
// content that has <script /> which type is NOT "text/javascript".
|
||||
// $('#output').html(html);
|
||||
//
|
||||
$('#output')[0].innerHTML += html;
|
||||
|
||||
//
|
||||
// However, if HTML assigned to to .innerHTML container <script/> tags,
|
||||
// they are not executed, so we have to manually walk all of them and
|
||||
// eval() the content.
|
||||
//
|
||||
$('#output script[type="text/javascript"][class!="executed"]').each(function()
|
||||
{
|
||||
eval($(this).text() || $(this).html());
|
||||
$(this).addClass('executed')
|
||||
});
|
||||
};
|
||||
|
||||
function runTestQueue()
|
||||
{
|
||||
|
||||
$.each(testQueue, function()
|
||||
{
|
||||
this.apply(null);
|
||||
});
|
||||
|
||||
testQueue = [];
|
||||
};
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
loadTests(renderTests);
|
||||
SyntaxHighlighter.highlight();
|
||||
runTestQueue();
|
||||
|
||||
$('#interaction').click(function()
|
||||
{
|
||||
loadTests(interactionTests, false /* addHtml */);
|
||||
runTestQueue();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
134
sh/tests/theme_tests.html
Normal file
134
sh/tests/theme_tests.html
Normal file
|
@ -0,0 +1,134 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>SyntaxHighlighter Theme Tests</title>
|
||||
<script type="text/javascript" src="/js/jquery-1.4.2.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="output"></div>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: white;
|
||||
font-family: Helvetica;
|
||||
}
|
||||
|
||||
.test-wrap {
|
||||
width: 100%;
|
||||
height: 800px;
|
||||
overflow: auto;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script id="sample" type="text/plain">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>SyntaxHighlighter Theme Tests</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
/**
|
||||
* Looks for a child or parent node which has specified classname.
|
||||
* Equivalent to jQuery's $(container).find(".className")
|
||||
* @param {Element} target Target element.
|
||||
* @param {String} search Class name or node name to look for.
|
||||
* @param {Boolean} reverse If set to true, will go up the node tree instead of down.
|
||||
* @return {Element} Returns found child or parent element on null.
|
||||
*/
|
||||
function findElement(target, search, reverse /* optional */)
|
||||
{
|
||||
if (target == null)
|
||||
return null;
|
||||
|
||||
var nodes = reverse != true ? target.childNodes : [ target.parentNode ],
|
||||
propertyToFind = { '#' : 'id', '.' : 'className' }[search.substr(0, 1)] || 'nodeName',
|
||||
expectedValue,
|
||||
found
|
||||
;
|
||||
|
||||
// main return of the found node
|
||||
if ((target[propertyToFind] || '').indexOf(expectedValue) != -1)
|
||||
return target;
|
||||
|
||||
return found;
|
||||
};
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var themes = [
|
||||
['#fff', 'Default'],
|
||||
['#000', 'Django'],
|
||||
['#fff', 'Eclipse'],
|
||||
['#000', 'Emacs'],
|
||||
['#000', 'FadeToGrey'],
|
||||
['#000', 'MDUltra'],
|
||||
['#000', 'Midnight'],
|
||||
['#000', 'RDark']
|
||||
];
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
var sample = $('#sample').text().replace(/</g, '<');
|
||||
|
||||
$.each(themes, function(index)
|
||||
{
|
||||
var $iframe = $('<iframe class="test-wrap" src="about:blank" />'),
|
||||
background = this[0],
|
||||
themeName = this[1]
|
||||
;
|
||||
|
||||
$('#output')
|
||||
.append(''
|
||||
+ '<h1>'
|
||||
+ '<a href="#theme' + (index + 1) + '">next</a> '
|
||||
+ '<a name="theme' + index + '">'
|
||||
+ themeName
|
||||
+ '</a>'
|
||||
+ '</h1>'
|
||||
)
|
||||
.append($iframe)
|
||||
;
|
||||
|
||||
$iframe.ready(function()
|
||||
{
|
||||
var doc = $iframe[0].contentDocument;
|
||||
$iframe.css('background', background);
|
||||
|
||||
doc.write(''
|
||||
+ '<scr' + 'ipt type="text/javascript" src="/sh/scripts/XRegExp.js"></scr' + 'ipt>'
|
||||
+ '<scr' + 'ipt type="text/javascript" src="/sh/scripts/shCore.js"></scr' + 'ipt>'
|
||||
+ '<scr' + 'ipt type="text/javascript" src="/sh/scripts/shBrushXml.js"></scr' + 'ipt>'
|
||||
+ '<scr' + 'ipt type="text/javascript" src="/sh/scripts/shBrushJScript.js"></scr' + 'ipt>'
|
||||
+ '<link type="text/css" rel="stylesheet" href="/sh/styles/shCore' + themeName + '.css"/>'
|
||||
+ '<pre type="syntaxhighlighter" class="brush: js; html-script: true; highlight: [5, 20]" title="This is SyntaxHighlighter theme ' + themeName + ' in action!">'
|
||||
+ sample
|
||||
+ '</pre>'
|
||||
+ '<pre type="syntaxhighlighter" class="brush: js; html-script: true; collapse: true">'
|
||||
+ sample
|
||||
+ '</pre>'
|
||||
+ '<scr' + 'ipt type="text/javascript">'
|
||||
+ 'SyntaxHighlighter.highlight();'
|
||||
+ '</scr' + 'ipt>'
|
||||
);
|
||||
doc.close();
|
||||
});
|
||||
});
|
||||
|
||||
$('#output a[name]:first').attr('name', 'top');
|
||||
$('#output a[href]:last').attr('href', '#top').html('top');
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
11
sh/tests/webrick.rb
Normal file
11
sh/tests/webrick.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require 'webrick'
|
||||
include WEBrick
|
||||
|
||||
s = HTTPServer.new(
|
||||
:Port => 2010,
|
||||
:DocumentRoot => Dir::pwd
|
||||
)
|
||||
s.mount('/sh/scripts', WEBrick::HTTPServlet::FileHandler, '../scripts')
|
||||
s.mount('/sh/styles', WEBrick::HTTPServlet::FileHandler, '../styles')
|
||||
trap('INT') { s.stop }
|
||||
s.start
|
2
sh/tests/webrick.sh
Normal file
2
sh/tests/webrick.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
ruby webrick.rb
|
Loading…
Add table
Add a link
Reference in a new issue