PageRenderTime 226ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/samples/scalate-presentation/src/highlight/test.html

http://github.com/scalate/scalate
HTML | 1196 lines | 1117 code | 74 blank | 5 comment | 0 complexity | 9d3363be7f460f1c845f89ed79075e7d MD5 | raw file
  1. <!DOCTYPE html>
  2. <head>
  3. <title>Highlight</title>
  4. <meta charset="utf-8">
  5. <link rel="stylesheet" title="Default" href="styles/default.css">
  6. <link rel="alternate stylesheet" title="Dark" href="styles/dark.css">
  7. <link rel="alternate stylesheet" title="FAR" href="styles/far.css">
  8. <link rel="alternate stylesheet" title="IDEA" href="styles/idea.css">
  9. <link rel="alternate stylesheet" title="Sunburst" href="styles/sunburst.css">
  10. <link rel="alternate stylesheet" title="Zenburn" href="styles/zenburn.css">
  11. <link rel="alternate stylesheet" title="Visual Studio" href="styles/vs.css">
  12. <link rel="alternate stylesheet" title="Ascetic" href="styles/ascetic.css">
  13. <link rel="alternate stylesheet" title="Magula" href="styles/magula.css">
  14. <link rel="alternate stylesheet" title="GitHub" href="styles/github.css">
  15. <link rel="alternate stylesheet" title="Brown Paper" href="styles/brown_paper.css">
  16. <link rel="alternate stylesheet" title="School Book" href="styles/school_book.css">
  17. <link rel="alternate stylesheet" title="IR_Black" href="styles/ir_black.css">
  18. <style>
  19. h2 {
  20. font: bold 100% Arial, sans-serif;
  21. margin-top: 2em;
  22. margin-bottom: 0.5em;
  23. }
  24. table {
  25. width: 100%;
  26. }
  27. th {
  28. width: 10em; font-weight: normal;
  29. }
  30. td, th {
  31. vertical-align: top;
  32. text-align: left;
  33. }
  34. pre {
  35. margin-top: 0;
  36. }
  37. ul#switch {
  38. padding: 0;
  39. margin: 0 0 0 -0.5em;
  40. }
  41. ul#switch li {
  42. border-bottom: 1px dashed blue;
  43. display: inline;
  44. padding: 0;
  45. margin: 0.5em;
  46. cursor: pointer;
  47. }
  48. ul#switch li.current {
  49. border-bottom: none;
  50. cursor: default;
  51. }
  52. </style>
  53. <!--
  54. Don't include languages as individual files in production environment.
  55. Instead use <script src="highlight.pack.js"></script> with highlight.pack.js
  56. containing all the languages you've chosen when downloading the library
  57. -->
  58. <script src="highlight.js"></script>
  59. <script src="languages/cs.js"></script>
  60. <script src="languages/python.js"></script>
  61. <script src="languages/mel.js"></script>
  62. <script src="languages/perl.js"></script>
  63. <script src="languages/axapta.js"></script>
  64. <script src="languages/cpp.js"></script>
  65. <script src="languages/sql.js"></script>
  66. <script src="languages/smalltalk.js"></script>
  67. <script src="languages/profile.js"></script>
  68. <script src="languages/bash.js"></script>
  69. <script src="languages/lua.js"></script>
  70. <script src="languages/html-xml.js"></script>
  71. <script src="languages/renderman.js"></script>
  72. <script src="languages/1c.js"></script>
  73. <script src="languages/delphi.js"></script>
  74. <script src="languages/dos.js"></script>
  75. <script src="languages/django.js"></script>
  76. <script src="languages/vbscript.js"></script>
  77. <script src="languages/ini.js"></script>
  78. <script src="languages/apache.js"></script>
  79. <script src="languages/nginx.js"></script>
  80. <script src="languages/ruby.js"></script>
  81. <script src="languages/css.js"></script>
  82. <script src="languages/lisp.js"></script>
  83. <script src="languages/java.js"></script>
  84. <script src="languages/javascript.js"></script>
  85. <script src="languages/php.js"></script>
  86. <script src="languages/diff.js"></script>
  87. <script src="languages/avrasm.js"></script>
  88. <script src="languages/parser3.js"></script>
  89. <script src="languages/scala.js"></script>
  90. <script src="languages/tex.js"></script>
  91. <script>
  92. hljs.tabReplace = ' ';
  93. hljs.initHighlightingOnLoad();
  94. </script>
  95. <script>
  96. // A stylesheet switcher for the test page. Not part of the highlight.js itself
  97. // (c) Vladimir Epifanov <voldmar@voldmar.ru>
  98. (function(container_id) {
  99. if (window.addEventListener) {
  100. var attach = function(el, ev, handler) {
  101. el.addEventListener(ev, handler, false);
  102. }
  103. } else if (window.attachEvent) {
  104. var attach = function(el, ev, handler) {
  105. el.attachEvent('on' + ev, handler);
  106. }
  107. } else {
  108. var attach = function(el, ev, handler) {
  109. ev['on' + ev] = handler;
  110. }
  111. }
  112. attach(window, 'load', function() {
  113. var current = null;
  114. var info = {};
  115. var links = document.getElementsByTagName('link');
  116. var ul = document.createElement('ul')
  117. for (var i = 0; (link = links[i]); i++) {
  118. if (link.getAttribute('rel').indexOf('style') != -1
  119. && link.title) {
  120. var title = link.title;
  121. info[title] = {
  122. 'link': link,
  123. 'li': document.createElement('li')
  124. }
  125. ul.appendChild(info[title].li)
  126. info[title].li.title = title;
  127. info[title].link.disabled = true;
  128. info[title].li.appendChild(document.createTextNode(title));
  129. attach(info[title].li, 'click', (function (el) {
  130. return function() {
  131. current.li.className = '';
  132. current.link.disabled = true;
  133. current = el;
  134. current.li.className = 'current';
  135. current.link.disabled = false;
  136. }})(info[title]));
  137. }
  138. }
  139. current = info['Default']
  140. current.li.className = 'current';
  141. current.link.disabled = false;
  142. ul.id = 'switch';
  143. container = document.getElementById(container_id);
  144. container.appendChild(ul);
  145. });
  146. })('styleswitcher');
  147. </script>
  148. <body>
  149. <p>This page is a demo/test showing all languages supported by <a href="http://softwaremaniacs.org/soft/highlight/">highlight.js</a>.
  150. Most of the code doesn't work :-).
  151. <p>You can see this page in several different styles bundled with the library or
  152. write your own (and contribute it back!)
  153. <div id="styleswitcher"></div>
  154. <h2>Automatically detected languages</h2>
  155. <table>
  156. <tr>
  157. <th>Python
  158. <td>
  159. <pre>
  160. <code>@requires_authorization
  161. def somefunc(param1, param2):
  162. r'''A docstring'''
  163. if param1 > param2: # interesting
  164. print 'Gre\'ater'
  165. print ''
  166. return (param2 - param1 + 1) or None
  167. class SomeClass:<br> pass
  168. </code></pre>
  169. <tr>
  170. <th>Python's profiler output
  171. <td>
  172. <pre><code> 261917242 function calls in 686.251 CPU seconds
  173. ncalls tottime filename:lineno(function)
  174. 152824 513.894 {method 'sort' of 'list' objects}
  175. 129590630 83.894 rrule.py:842(__cmp__)
  176. 129590630 82.439 {cmp}
  177. 153900 1.296 rrule.py:399(_iter)
  178. 304393/151570 0.963 rrule.py:102(_iter_cached)
  179. </code></pre>
  180. <tr>
  181. <th>Ruby
  182. <td>
  183. <pre><code>class A &lt; B; def self.create(object = User) object end end
  184. class Zebra; def inspect; "X#{2 + self.object_id}" end end
  185. module ABC::DEF
  186. include Comparable
  187. # @param test
  188. # @return [String] nothing
  189. def foo(test)
  190. Thread.new do |blockvar|
  191. ABC::DEF.reverse(:a_symbol, :'a symbol' + 'test' + test)
  192. end.join
  193. end
  194. def [](index) self[index] end
  195. def ==(other) other == self end
  196. end
  197. anIdentifier = an_identifier
  198. Constant = 1
  199. </code></pre>
  200. <tr>
  201. <th>Perl
  202. <td>
  203. <pre><code># loads object
  204. sub load
  205. {
  206. my $flds = $c-&gt;db_load($id,@_) || do {
  207. Carp::carp "Can`t load (class: $c, id: $id): '$!'"; return undef
  208. };
  209. my $o = $c-&gt;_perl_new();
  210. $id12 = $id;
  211. $o-&gt;{'ID'} = $id12 + 123;
  212. $o-&gt;{'PAPA'} = $flds-&gt;{'PAPA'};
  213. #$o-&gt;{'SHCUT'} = $flds-&gt;{'SHCUT'};
  214. my $p = $o-&gt;props;
  215. my $vt;
  216. $string =~ m/^sought_text$/;
  217. for my $key (keys %$p)
  218. {
  219. if(${$vt.'::property'}) {
  220. $o-&gt;{$key . '_real'} = $flds-&gt;{$key};
  221. tie $o-&gt;{$key}, 'CMSBuilder::Property', $o, $key;
  222. } else {
  223. $o-&gt;{$key} = $flds-&gt;{$key};
  224. }
  225. }
  226. $o-&gt;save if delete $o-&gt;{'_save_after_load'};
  227. return $o;
  228. }
  229. </code></pre>
  230. <tr>
  231. <th>PHP
  232. <td>
  233. <pre><code>require_once 'Zend.php';
  234. require_once 'Zend/Uri/Exception.php';
  235. require_once 'Zend/Uri/Http.php';
  236. require_once 'Zend/Uri/Mailto.php';
  237. abstract class Zend_Uri
  238. {
  239. /**
  240. * Return a string representation of this URI.
  241. *
  242. * @see getUri()
  243. * @return string
  244. */
  245. public function __toString()
  246. {
  247. return $this-&gt;getUri();
  248. }
  249. static public function factory($uri = 'http')
  250. {
  251. $uri = explode(':', $uri, 2);
  252. $scheme = strtolower($uri[0]);
  253. $schemeSpecific = isset($uri[1]) ? $uri[1] : '';
  254. // Security check: $scheme is used to load a class file,
  255. // so only alphanumerics are allowed.
  256. if (!ctype_alnum($scheme)) {
  257. throw new Zend_Uri_Exception('Illegal scheme');
  258. }
  259. }
  260. }
  261. </code></pre>
  262. <tr>
  263. <th>Scala
  264. <td>
  265. <pre><code>object abstractTypes extends Application {
  266. abstract class SeqBuffer {
  267. type T; val element: Seq[T]; def length = element.length
  268. }
  269. }
  270. /** Turn command line arguments to uppercase */
  271. object Main {
  272. def main(args: Array[String]) {
  273. val res = for (a &lt;- args) yield a.toUpperCase
  274. println("Arguments: " + res.toString)
  275. }
  276. }
  277. /** Maps are easy to use in Scala. */
  278. object Maps {
  279. val colors = Map("red" -> 0xFF0000,
  280. "turquoise" -> 0x00FFFF,
  281. "black" -> 0x000000,
  282. "orange" -> 0xFF8040,
  283. "brown" -> 0x804000)
  284. def main(args: Array[String]) {
  285. for (name &lt;- args) println(
  286. colors.get(name) match {
  287. case Some(code) =>
  288. name + " has code: " + code
  289. case None =&gt;
  290. "Unknown color: " + name
  291. }
  292. )
  293. }
  294. }
  295. </code></pre>
  296. <tr>
  297. <th>XML
  298. <td>
  299. <pre><code>&lt;?xml version="1.0"?&gt;
  300. &lt;response value="ok" xml:lang="en"&gt;
  301. &lt;text&gt;Ok&lt;/text&gt;
  302. &lt;comment html_allowed="true"/&gt;
  303. &lt;ns1:description&gt;&lt;![CDATA[
  304. CDATA is &lt;not&gt; magical.
  305. ]]&gt;&lt;/ns1:description&gt;
  306. &lt;a&gt;&lt;/a&gt; &lt;a/&gt;
  307. &lt;/response&gt;
  308. </code></pre>
  309. <tr>
  310. <th>HTML (with inline css and javascript)
  311. <td>
  312. <pre><code>&lt;head&gt;
  313. &lt;title&gt;Title&lt;/title&gt;
  314. &lt;style&gt;
  315. body {
  316. width: 500px;
  317. }
  318. &lt;/style&gt;
  319. &lt;script&gt;
  320. function someFunction() {
  321. return true;
  322. }
  323. &lt;/script&gt;
  324. &lt;body&gt;
  325. &lt;p class="something" id='12'&gt;Something&lt;/p&gt;
  326. &lt;p class=something&gt;Something&lt;/p&gt;
  327. &lt;!-- comment --&gt;
  328. &lt;p class&gt;Something&lt;/p&gt;
  329. &lt;p class="something" title="p"&gt;Something&lt;/p&gt;
  330. &lt;/body&gt;
  331. </code></pre>
  332. <tr>
  333. <th>Django templates
  334. <td>
  335. <pre><code>{% if articles|length %}
  336. {% for article in articles %}
  337. {# Striped table #}
  338. &lt;tr class="{% cycle odd,even %}"&gt;
  339. &lt;td&gt;{{ article|default:"Hi... "|escape }}&lt;/td&gt;
  340. &lt;td&gt;{{ article.date|date:"d.m.Y" }}&lt;/td&gt;
  341. &lt;/tr&gt;
  342. {% endfor %}
  343. {% endif %}
  344. {% comment %}
  345. Comments may be long and
  346. multiline.
  347. {% endcomment %}
  348. </code></pre>
  349. <tr>
  350. <th>CSS
  351. <td>
  352. <pre><code>body,
  353. html {
  354. font: Tahoma, Arial, san-serif;
  355. background: url('hatch.png');
  356. }
  357. @import url('print.css');
  358. @media screen and (-webkit-min-device-pixel-ratio: 0) {
  359. @page :left {
  360. body:first-of-type pre::after {
  361. content: 'highlight: ' attr(class);
  362. }
  363. }
  364. #content {
  365. width: 100%; /* wide enough */
  366. height: 100%
  367. }
  368. p[lang=ru] {
  369. color: #F0F0F0; background: white;
  370. }
  371. </code></pre>
  372. <tr>
  373. <th>Javascript
  374. <td>
  375. <pre><code>function $initHighlight(block) {
  376. if (block.className.search(/\bno\-highlight\b/) != -1)
  377. return false;
  378. try {
  379. blockText(block);
  380. } catch (e) {
  381. if (e == 'Complex markup')
  382. return;
  383. }//try
  384. var classes = block.className.split(/\s+/);
  385. for (var i = 0 / 2; i &lt; classes.length; i++) { // "0 / 2" should not be parsed as regexp start
  386. if (LANGUAGES[classes[i]]) {
  387. highlightLanguage(block, classes[i]);
  388. return;
  389. }//if
  390. }//for
  391. highlightAuto(block);
  392. }//initHighlight</code></pre>
  393. <tr>
  394. <th>VBScript
  395. <td>
  396. <pre><code>' creating configuration storage and initializing with default values
  397. Set cfg = CreateObject("Scripting.Dictionary")
  398. ' reading ini file
  399. for i = 0 to ubound(ini_strings)
  400. s = trim(ini_strings(i))
  401. ' skipping empty strings and comments
  402. if mid(s, 1, 1) &lt;&gt; "#" and len(s) > 0 then
  403. ' obtaining key and value
  404. parts = split(s, "=", -1, 1)
  405. if ubound(parts)+1 = 2 then
  406. parts(0) = trim(parts(0))
  407. parts(1) = trim(parts(1))
  408. ' reading configuration and filenames
  409. select case lcase(parts(0))
  410. case "uncompressed""_postfix" cfg.item("uncompressed""_postfix") = parts(1)
  411. case "f"
  412. options = split(parts(1), "|", -1, 1)
  413. if ubound(options)+1 = 2 then
  414. ' 0: filename, 1: options
  415. ff.add trim(options(0)), trim(options(1))
  416. end if
  417. end select
  418. end if
  419. end if
  420. next</code></pre>
  421. <tr>
  422. <th>Lua
  423. <td>
  424. <pre><code>--[[
  425. Simple signal/slot implementation
  426. ]]
  427. local signal_mt = {
  428. __index = {
  429. register = table.insert
  430. }
  431. }
  432. function signal_mt.__index:emit(... --[[ Comment in params ]])
  433. for _, slot in ipairs(self) do
  434. slot(self, ...)
  435. end
  436. end
  437. local function create_signal()
  438. return setmetatable({}, signal_mt)
  439. end
  440. -- Signal test
  441. local signal = create_signal()
  442. signal:register(function (signal, ...)
  443. print(...)
  444. end)
  445. signal:emit('Answer to Life, the Universe, and Everything:', 42)
  446. --[==[ [=[ [[
  447. Nested ]]
  448. multi-line ]=]
  449. comment ]==]
  450. [==[ Nested
  451. [=[ multi-line
  452. [[ string
  453. ]] ]=] ]==]
  454. </code></pre>
  455. <tr>
  456. <th>Delphi
  457. <td>
  458. <pre><code>TList=Class(TObject)
  459. Private
  460. Some: String;
  461. Public
  462. Procedure Inside;
  463. End;{TList}
  464. Procedure CopyFile(InFileName,var OutFileName:String);
  465. Const
  466. BufSize=4096; (* Huh? *)
  467. Var
  468. InFile,OutFile:TStream;
  469. Buffer:Array[1..BufSize] Of Byte;
  470. ReadBufSize:Integer;
  471. Begin
  472. InFile:=Nil;
  473. OutFile:=Nil;
  474. Try
  475. InFile:=TFileStream.Create(InFileName,fmOpenRead);
  476. OutFile:=TFileStream.Create(OutFileName,fmCreate);
  477. Repeat
  478. ReadBufSize:=InFile.Read(Buffer,BufSize);
  479. OutFile.Write(Buffer,ReadBufSize);
  480. Until ReadBufSize&lt;&gt;BufSize;
  481. Log('File '''+InFileName+''' copied'#13#10);
  482. Finally
  483. InFile.Free;
  484. OutFile.Free;
  485. End;{Try}
  486. End;{CopyFile}
  487. </code></pre>
  488. <tr>
  489. <th>Java
  490. <td>
  491. <pre><code>package l2f.gameserver.model;
  492. import java.util.ArrayList;
  493. /**
  494. * Mother class of all character objects of the world (PC, NPC...)&lt;BR&gt;&lt;BR&gt;
  495. *
  496. */
  497. public abstract class L2Character extends L2Object
  498. {
  499. protected static final Logger _log = Logger.getLogger(L2Character.class.getName());
  500. public static final Short ABNORMAL_EFFECT_BLEEDING = 0x0001; // not sure
  501. public static final Short ABNORMAL_EFFECT_POISON = 0x0002;
  502. public void detachAI() {
  503. _ai = null;
  504. //jbf = null;
  505. if (1 > 5) {
  506. return;
  507. }
  508. }
  509. public void moveTo(int x, int y, int z) {
  510. moveTo(x, y, z, 0);
  511. }
  512. /** Task of AI notification */
  513. @SuppressWarnings( { "nls", "unqualified-field-access", "boxing" })
  514. public class NotifyAITask implements Runnable {
  515. private final CtrlEvent _evt;
  516. public void run() {
  517. try {
  518. getAI().notifyEvent(_evt, null, null);
  519. } catch (Throwable t) {
  520. _log.warning("Exception " + t);
  521. t.printStackTrace();
  522. }
  523. }
  524. }
  525. }
  526. </code></pre>
  527. <tr>
  528. <th>C++
  529. <td>
  530. <pre><code>#include &lt;iostream&gt;
  531. int main(int argc, char *argv[]) {
  532. /* An annoying "Hello World" example */
  533. for (unsigned i = 0; i &lt; 0xFFFF; i++)
  534. cout &lt;&lt; "Hello, World!" &lt;&lt; endl;
  535. char c = '\n'; // just a test
  536. map &lt;string, vector&lt;string&gt; &gt; m;
  537. m["key"] = "\\\\"; // yeah, I know it's an error
  538. }
  539. </code></pre>
  540. <tr>
  541. <th>C#
  542. <td>
  543. <pre><code>using System;
  544. public class Program
  545. {
  546. /// &lt;summary&gt;The entry point to the program.&lt;/summary&gt;
  547. /// &lt;remarks&gt;
  548. /// Using the Visual Studio style, the tags in this comment
  549. /// should be grey, but this text should be green.
  550. /// This comment should be green on the inside:
  551. /// &lt;!-- I'm green! --&gt;
  552. /// &lt;/remarks&gt;
  553. public static int Main(string[] args)
  554. {
  555. Console.WriteLine("Hello, World!");
  556. string s = @"This
  557. ""string""
  558. spans
  559. multiple
  560. lines!";
  561. return 0;
  562. }
  563. }
  564. </code></pre>
  565. <tr>
  566. <th>RenderMan RSL
  567. <td>
  568. <pre><code>#define TEST_DEFINE 3.14
  569. /* plastic surface shader
  570. *
  571. * Pixie is:
  572. * (c) Copyright 1999-2003 Okan Arikan. All rights reserved.
  573. */
  574. surface plastic (float Ka = 1, Kd = 0.5, Ks = 0.5, roughness = 0.1;
  575. color specularcolor = 1;) {
  576. normal Nf = faceforward (normalize(N),I);
  577. Ci = Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks *
  578. specular(Nf,-normalize(I),roughness);
  579. Oi = Os;
  580. Ci *= Oi;
  581. }
  582. </code></pre>
  583. <tr>
  584. <th>RenderMan RIB
  585. <td>
  586. <pre><code>FrameBegin 0
  587. Display "Scene" "framebuffer" "rgb"
  588. Option "searchpath" "shader" "+&:/home/kew"
  589. Option "trace" "int maxdepth" [4]
  590. Attribute "visibility" "trace" [1]
  591. Attribute "irradiance" "maxerror" [0.1]
  592. Attribute "visibility" "transmission" "opaque"
  593. Format 640 480 1.0
  594. ShadingRate 2
  595. PixelFilter "catmull-rom" 1 1
  596. PixelSamples 4 4
  597. Projection "perspective" "fov" 49.5502811377
  598. Scale 1 1 -1
  599. WorldBegin
  600. ReadArchive "Lamp.002_Light/instance.rib"
  601. Surface "plastic"
  602. ReadArchive "Cube.004_Mesh/instance.rib"
  603. # ReadArchive "Sphere.010_Mesh/instance.rib"
  604. # ReadArchive "Sphere.009_Mesh/instance.rib"
  605. ReadArchive "Sphere.006_Mesh/instance.rib"
  606. WorldEnd
  607. FrameEnd
  608. </code></pre>
  609. <tr>
  610. <th>MEL (Maya Embedded Language)
  611. <td>
  612. <pre><code class="mel">proc string[] getSelectedLights()
  613. {
  614. string $selectedLights[];
  615. string $select[] = `ls -sl -dag -leaf`;
  616. for ( $shape in $select )
  617. {
  618. // Determine if this is a light.
  619. //
  620. string $class[] = getClassification( `nodeType $shape` );
  621. if ( ( `size $class` ) > 0 &amp;&amp; ( "light" == $class[0] ) )
  622. {
  623. $selectedLights[ `size $selectedLights` ] = $shape;
  624. }
  625. }
  626. // Result is an array of all lights included in
  627. // current selection list.
  628. return $selectedLights;
  629. }
  630. </code></pre>
  631. <tr>
  632. <th>SQL
  633. <td>
  634. <pre><code>BEGIN;
  635. CREATE TABLE "cicero_topic" (
  636. "id" serial NOT NULL PRIMARY KEY,
  637. "forum_id" integer NOT NULL,
  638. "subject" varchar(255) NOT NULL,
  639. "created" timestamp with time zone NOT NULL
  640. );
  641. ALTER TABLE "cicero_topic"
  642. ADD CONSTRAINT forum_id_refs_id_4be56999
  643. FOREIGN KEY ("forum_id")
  644. REFERENCES "cicero_forum" ("id")
  645. DEFERRABLE INITIALLY DEFERRED;
  646. -- Initials
  647. insert into "cicero_forum"
  648. ("slug", "name", "group", "ordering")
  649. values
  650. ('test', 'Forum for te''sting', 'Test', 0);
  651. -- Test
  652. select count(*) from cicero_forum;
  653. COMMIT;
  654. </code></pre>
  655. <tr>
  656. <th>SmallTalk
  657. <td>
  658. <pre><code>Object>>method: num
  659. "comment 123"
  660. | var1 var2 |
  661. (1 to: num) do: [:i | |var| ^i].
  662. Klass with: var1.
  663. Klass new.
  664. arr := #('123' 123.345 #hello Transcript var $@).
  665. arr := #().
  666. var2 = arr at: 3.
  667. ^ self abc
  668. heapExample
  669. "HeapTest new heapExample"
  670. "Multiline
  671. decription"
  672. | n rnd array time sorted |
  673. n := 5000.
  674. "# of elements to sort"
  675. rnd := Random new.
  676. array := (1 to: n)
  677. collect: [:i | rnd next].
  678. "First, the heap version"
  679. time := Time
  680. millisecondsToRun: [sorted := Heap withAll: array.
  681. 1
  682. to: n
  683. do: [:i |
  684. sorted removeFirst.
  685. sorted add: rnd next]].
  686. Transcript cr; show: 'Time for Heap: ' , time printString , ' msecs'.
  687. "The quicksort version"
  688. time := Time
  689. millisecondsToRun: [sorted := SortedCollection withAll: array.
  690. 1
  691. to: n
  692. do: [:i |
  693. sorted removeFirst.
  694. sorted add: rnd next]].
  695. Transcript cr; show: 'Time for SortedCollection: ' , time printString , ' msecs'
  696. </code></pre>
  697. <tr>
  698. <th>Lisp
  699. <th><pre><code>(defun prompt-for-cd ()
  700. "Prompts
  701. for CD"
  702. (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))
  703. (prompt-read "Artist" &amp;rest)
  704. (or (parse-integer (prompt-read "Rating") :junk-allowed t) 0)
  705. (if x (format t "yes") (format t "no" nil) ;and here comment
  706. )
  707. ;; second line comment
  708. '(+ 1 2)
  709. (defvar *lines*) ; list of all lines
  710. (position-if-not #'sys::whitespacep line :start beg))
  711. (quote (privet 1 2 3))
  712. '(hello world)
  713. (* 5 7)
  714. (1 2 34 5)
  715. (:use "aaaa")
  716. (let ((x 10) (y 20))
  717. (print (+ x y))
  718. )</code></pre>
  719. <tr>
  720. <th>Ini file
  721. <td>
  722. <pre><code>;Settings relating to the location and loading of the database
  723. [Database]
  724. ProfileDir=.
  725. ShowProfileMgr=smart
  726. Profile1_Name[] = "\|/_-=MegaDestoyer=-_\|/"
  727. DefaultProfile=True
  728. AutoCreate = no
  729. [AutoExec]
  730. Use="prompt"
  731. Glob=autoexec_*.ini
  732. AskAboutIgnoredPlugins=0
  733. </code></pre>
  734. <tr>
  735. <th>Apache
  736. <td>
  737. <pre><code># rewrite`s rules for wordpress pretty url
  738. LoadModule rewrite_module modules/mod_rewrite.so
  739. RewriteCond %{REQUEST_FILENAME} !-f
  740. RewriteCond %{REQUEST_FILENAME} !-d
  741. RewriteRule . index.php [NC,L]
  742. ExpiresActive On
  743. ExpiresByType application/x-javascript "access plus 1 days"
  744. &lt;Location /maps/&gt;
  745. RewriteMap map txt:map.txt
  746. RewriteMap lower int:tolower
  747. RewriteCond %{REQUEST_URI} ^/([^/.]+)\.html$ [NC]
  748. RewriteCond ${map:${lower:%1}|NOT_FOUND} !NOT_FOUND
  749. RewriteRule .? /index.php?q=${map:${lower:%1}} [NC,L]
  750. &lt;/Location&gt;
  751. </code></pre>
  752. <tr>
  753. <th>nginx
  754. <td>
  755. <pre><code>user www www;
  756. worker_processes 2;
  757. pid /var/run/nginx.pid;
  758. error_log /var/log/nginx.error_log debug | info | notice | warn | error | crit;
  759. events {
  760. connections 2000;
  761. use kqueue | rtsig | epoll | /dev/poll | select | poll;
  762. }
  763. http {
  764. log_format main '$remote_addr - $remote_user [$time_local] '
  765. '"$request" $status $bytes_sent '
  766. '"$http_referer" "$http_user_agent" '
  767. '"$gzip_ratio"';
  768. send_timeout 3m;
  769. client_header_buffer_size 1k;
  770. gzip on;
  771. gzip_min_length 1100;
  772. #lingering_time 30;
  773. server {
  774. listen one.example.com;
  775. server_name one.example.com www.one.example.com;
  776. access_log /var/log/nginx.access_log main;
  777. location / {
  778. proxy_pass http://127.0.0.1/;
  779. proxy_redirect off;
  780. proxy_set_header Host $host;
  781. proxy_set_header X-Real-IP $remote_addr;
  782. charset koi8-r;
  783. }
  784. location ~* \.(jpg|jpeg|gif)$ {
  785. root /spool/www;
  786. }
  787. }
  788. }
  789. </code></pre>
  790. <tr>
  791. <th>Diff
  792. <td>
  793. <pre><code>Index: languages/ini.js
  794. ===================================================================
  795. --- languages/ini.js (revision 199)
  796. +++ languages/ini.js (revision 200)
  797. @@ -1,8 +1,7 @@
  798. hljs.LANGUAGES.ini =
  799. {
  800. case_insensitive: true,
  801. - defaultMode:
  802. - {
  803. + defaultMode: {
  804. contains: ['comment', 'title', 'setting'],
  805. illegal: '[^\\s]'
  806. },
  807. *** /path/to/original timestamp
  808. --- /path/to/new timestamp
  809. ***************
  810. *** 1,3 ****
  811. --- 1,9 ----
  812. + This is an important
  813. + notice! It should
  814. + therefore be located at
  815. + the beginning of this
  816. + document!
  817. ! compress the size of the
  818. ! changes.
  819. It is important to spell
  820. </code></pre>
  821. <tr>
  822. <th>DOS batch files
  823. <td>
  824. <pre><code>cd \
  825. copy a b
  826. ping 192.168.0.1
  827. @rem ping 192.168.0.1
  828. net stop sharedaccess
  829. del %tmp% /f /s /q
  830. del %temp% /f /s /q
  831. ipconfig /flushdns
  832. taskkill /F /IM JAVA.EXE /T
  833. cd Photoshop/Adobe Photoshop CS3/AMT/
  834. if exist application.sif (
  835. ren application.sif _application.sif
  836. ) else (
  837. ren _application.sif application.sif
  838. )
  839. taskkill /F /IM proquota.exe /T
  840. sfc /SCANNOW
  841. set path = test
  842. xcopy %1\*.* %2
  843. </code></pre>
  844. <tr>
  845. <th>Bash
  846. <td>
  847. <pre><code>#!/bin/bash
  848. ###### BEGIN CONFIG
  849. ACCEPTED_HOSTS="/root/.hag_accepted.conf"
  850. BE_VERBOSE=false
  851. ###### END CONFIG
  852. if [ "$UID" -ne 0 ]
  853. then
  854. echo "Superuser rights is required"
  855. exit 2
  856. fi
  857. genApacheConf(){
  858. if [[ "$2" = "www" ]]
  859. then
  860. full_domain=$1
  861. else
  862. full_domain=$2.$1
  863. fi
  864. host_root="${APACHE_HOME_DIR}$1/$2"
  865. echo -e "# Host $1/$2 :"
  866. }
  867. </code></pre>
  868. <tr>
  869. <th>Axapta
  870. <td>
  871. <pre><code>class ExchRateLoadBatch extends RunBaseBatch {
  872. ExchRateLoad rbc;
  873. container currencies;
  874. boolean actual;
  875. boolean overwrite;
  876. date beg;
  877. date end;
  878. #define.CurrentVersion(5)
  879. #localmacro.CurrentList
  880. currencies,
  881. actual,
  882. beg,
  883. end
  884. #endmacro
  885. }
  886. public boolean unpack(container packedClass) {
  887. container base;
  888. boolean ret;
  889. Integer version = runbase::getVersion(packedClass);
  890. switch (version) {
  891. case #CurrentVersion:
  892. [version, #CurrentList] = packedClass;
  893. return true;
  894. default:
  895. return false;
  896. }
  897. return ret;
  898. }
  899. </code></pre>
  900. <tr>
  901. <th>1С
  902. <td>
  903. <pre><code>
  904. #Если Клиент Тогда
  905. Перем СимвольныйКодКаталога = "ля-ля-ля"; //комментарий
  906. Функция Сообщить(Знач ТекстСообщения, ТекстСообщения2) Экспорт //комментарий к функции
  907. x=ТекстСообщения+ТекстСообщения2+"
  908. |строка1
  909. |строка2
  910. |строка3";
  911. КонецФункции
  912. #КонецЕсли
  913. // Процедура ПриНачалеРаботыСистемы
  914. //
  915. Процедура ПриНачалеРаботыСистемы()
  916. Обработки.Помощник.ПолучитьФорму("Форма").Открыть();
  917. d = '21.01.2008'
  918. КонецПроцедуры
  919. </code></pre>
  920. <tr>
  921. <th>AVR Assembler
  922. <td>
  923. <pre><code>;* Title: Block Copy Routines
  924. ;* Version: 1.1
  925. .include "8515def.inc"
  926. rjmp RESET ;reset handle
  927. .def flashsize=r16 ;size of block to be copied
  928. flash2ram:
  929. lpm ;get constant
  930. st Y+,r0 ;store in SRAM and increment Y-pointer
  931. adiw ZL,1 ;increment Z-pointer
  932. dec flashsize
  933. brne flash2ram ;if not end of table, loop more
  934. ret
  935. .def ramtemp =r1 ;temporary storage register
  936. .def ramsize =r16 ;size of block to be copied
  937. </code></pre>
  938. <tr>
  939. <th>Parser 3
  940. <td>
  941. <pre><code>@CLASS
  942. base
  943. @USE
  944. module.p
  945. @BASE
  946. class
  947. # Comment for code
  948. @create[aParam1;aParam2][local1;local2]
  949. ^connect[mysql://host/database?ClientCharset=windows-1251]
  950. ^for[i](1;10){
  951. &lt;p class=&quot;paragraph&quot;&gt;^eval($i+10)&lt;/p&gt;
  952. ^connect[mysql://host/database]{
  953. $tab[^table::sql{select * from `table` where a='1'}]
  954. $var_Name[some${value}]
  955. }
  956. }
  957. ^rem{
  958. Multiline comment with code: $var
  959. ^while(true){
  960. ^for[i](1;10){
  961. ^sleep[]
  962. }
  963. }
  964. }
  965. ^taint[^#0A]
  966. @GET_base[]
  967. ## Comment for code
  968. # Isn't comment
  969. $result[$.hash_item1[one] $.hash_item2[two]]
  970. </code></pre>
  971. <tr>
  972. <th>TeX
  973. <td>
  974. <pre>
  975. <code>\documentclass{article}
  976. \usepackage[koi8-r]{inputenc}
  977. \hoffset=0pt
  978. \voffset=.3em
  979. \tolerance=400
  980. \newcommand{\eTiX}{\TeX}
  981. \begin{document}
  982. \section*{Highlight.js}
  983. \begin{table}[c|c]
  984. $\frac 12\, + \, \frac 1{x^3}\text{Hello \! world}$ & \textbf{Goodbye\~ world} \\\eTiX $ \pi=400 $
  985. \end{table}
  986. Ch\'erie, \c{c}a ne me pla\^\i t pas! % comment \b
  987. G\"otterd\"ammerung~45\%=34.
  988. $$
  989. \int\limits_{0}^{\pi}\frac{4}{x-7}=3
  990. $$
  991. \end{document}
  992. </code></pre>
  993. </table>
  994. <h2>Special tests</h2>
  995. <table>
  996. <tr>
  997. <th>Explicit Python highlighting
  998. <td>
  999. <pre><code class="python">for x in [1, 2, 3]:
  1000. count(x)
  1001. </code></pre>
  1002. <tr>
  1003. <th>Language set on &lt;pre&gt;
  1004. <td>
  1005. <pre class="python"><code>for x in [1, 2, 3]:
  1006. count(x)
  1007. </code></pre>
  1008. <tr>
  1009. <th>HTML5-style language class (language-python)
  1010. <td>
  1011. <pre class="python"><code>for x in [1, 2, 3]:
  1012. count(x)
  1013. </code></pre>
  1014. <tr>
  1015. <th>Replacing TAB with 4 spaces
  1016. <td>
  1017. <pre><code class="python">for x in [1, 2, 3]:
  1018. count(x)
  1019. </code></pre>
  1020. <tr>
  1021. <th>Custom markup
  1022. <td>
  1023. <pre><code>&lt;<a href="http://dev.w3.org/html5/spec/Overview.html#the-div-element">div</a> id="contents"&gt;
  1024. <del>&lt;p&gt;Hello, World!</del>
  1025. &lt;/div&gt;
  1026. </code></pre>
  1027. <tr>
  1028. <th>Custom markup + TAB replacement
  1029. <td>
  1030. <pre><code class="python">for x in [1, 2, 3]:
  1031. <span style="background:yellow"> </span>count(x)
  1032. if x == 3:
  1033. <span style="background:yellow"> </span>count(x + 1)
  1034. </code></pre>
  1035. <tr>
  1036. <th>Disabled highlighting
  1037. <td>
  1038. <pre><code class="no-highlight">&lt;div id="contents"&gt;
  1039. &lt;p&gt;Hello, World!
  1040. &lt;/div&gt;
  1041. </code></pre>
  1042. </table>