Browse Source

initial commit

master
commit
2843c77720
  1. 51
      boilerplate.html
  2. 1
      css/cmu.css
  3. 1
      css/cmufontface.css
  4. 1
      css/darkmodern.css
  5. 1
      css/dynamic.css
  6. BIN
      css/fonts/cmunorm.eot
  7. BIN
      css/fonts/cmunorm.otf
  8. BIN
      css/fonts/cmunorm.svg
  9. BIN
      css/fonts/cmunorm.ttf
  10. BIN
      css/fonts/cmunorm.woff
  11. BIN
      css/fonts/cmunrb.eot
  12. BIN
      css/fonts/cmunrb.svg
  13. BIN
      css/fonts/cmunrb.ttf
  14. BIN
      css/fonts/cmunrm.eot
  15. BIN
      css/fonts/cmunrm.otf
  16. BIN
      css/fonts/cmunrm.svg
  17. BIN
      css/fonts/cmunrm.ttf
  18. BIN
      css/fonts/cmunrm.woff
  19. BIN
      css/fonts/cmunsl.eot
  20. BIN
      css/fonts/cmunsl.svg
  21. BIN
      css/fonts/cmunsl.ttf
  22. BIN
      css/fonts/cmuntt.eot
  23. BIN
      css/fonts/cmuntt.otf
  24. BIN
      css/fonts/cmuntt.svg
  25. BIN
      css/fonts/cmuntt.ttf
  26. BIN
      css/fonts/cmuntt.woff
  27. BIN
      css/fonts/social_font.ttf
  28. 1
      css/modern.css
  29. 1
      css/scientific.css
  30. 1
      css/solarized.css
  31. BIN
      img/favicon.ico
  32. 3
      js/article.js
  33. 33
      js/become_hidden.html
  34. 33
      js/become_visible.html
  35. 23
      js/genericCommentWrapperV2.js
  36. 55
      js/highlight/AUTHORS.en.txt
  37. 55
      js/highlight/AUTHORS.ru.txt
  38. 24
      js/highlight/LICENSE
  39. 140
      js/highlight/README.md
  40. 145
      js/highlight/README.ru.md
  41. 497
      js/highlight/classref.txt
  42. 88
      js/highlight/export.html
  43. 643
      js/highlight/highlight.js
  44. 1
      js/highlight/highlight.pack.js
  45. 98
      js/highlight/languages/1c.js
  46. 94
      js/highlight/languages/actionscript.js
  47. 434
      js/highlight/languages/apache.js
  48. 75
      js/highlight/languages/avrasm.js
  49. 48
      js/highlight/languages/axapta.js
  50. 65
      js/highlight/languages/bash.js
  51. 42
      js/highlight/languages/cmake.js
  52. 112
      js/highlight/languages/coffeescript.js
  53. 66
      js/highlight/languages/cpp.js
  54. 58
      js/highlight/languages/cs.js
  55. 101
      js/highlight/languages/css.js
  56. 88
      js/highlight/languages/delphi.js
  57. 64
      js/highlight/languages/diff.js
  58. 81
      js/highlight/languages/django.js
  59. 35
      js/highlight/languages/dos.js
  60. 85
      js/highlight/languages/erlang-repl.js
  61. 206
      js/highlight/languages/erlang.js
  62. 59
      js/highlight/languages/go.js
  63. 77
      js/highlight/languages/haskell.js
  64. 32
      js/highlight/languages/ini.js
  65. 53
      js/highlight/languages/java.js
  66. 57
      js/highlight/languages/javascript.js
  67. 88
      js/highlight/languages/lisp.js
  68. 75
      js/highlight/languages/lua.js
  69. 79
      js/highlight/languages/markdown.js
  70. 74
      js/highlight/languages/matlab.js
  71. 45
      js/highlight/languages/mel.js
  72. 220
      js/highlight/languages/nginx.js
  73. 94
      js/highlight/languages/objectivec.js
  74. 50
      js/highlight/languages/parser3.js
  75. 181
      js/highlight/languages/perl.js
  76. 77
      js/highlight/languages/php.js
  77. 49
      js/highlight/languages/profile.js
  78. 90
      js/highlight/languages/python.js
  79. 230
      js/highlight/languages/renderman.js
  80. 253
      js/highlight/languages/ruby.js
  81. 80
      js/highlight/languages/rust.js
  82. 66
      js/highlight/languages/scala.js
  83. 55
      js/highlight/languages/smalltalk.js
  84. 90
      js/highlight/languages/sql.js
  85. 62
      js/highlight/languages/tex.js
  86. 74
      js/highlight/languages/vala.js
  87. 54
      js/highlight/languages/vbscript.js
  88. 46
      js/highlight/languages/vhdl.js
  89. 110
      js/highlight/languages/xml.js
  90. 152
      js/highlight/styles/arta.css
  91. 45
      js/highlight/styles/ascetic.css
  92. 106
      js/highlight/styles/brown_paper.css
  93. BIN
      js/highlight/styles/brown_papersq.png
  94. 104
      js/highlight/styles/dark.css
  95. 129
      js/highlight/styles/default.css
  96. 118
      js/highlight/styles/far.css
  97. 129
      js/highlight/styles/github.css
  98. 142
      js/highlight/styles/googlecode.css
  99. 118
      js/highlight/styles/idea.css
  100. 103
      js/highlight/styles/ir_black.css

51
boilerplate.html

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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="$language$" lang="$language$">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>$title$</title>
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="css/scientific.css" />
<link rel="stylesheet" type="text/css" href="css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocom$language$"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="$language$">
<div id="content">
<div id="titre">
<h1>$title$</h1>
</div>
<div id="afterheader" class="article">
<div class="corps">
$body$
</div>
<div id="bottom">
<div>
Published on $date$
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
<a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US">Yann Esposito©</a>
</div>
<div>
Done with static-pandoc-template
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="js/article.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

1
css/cmu.css

@ -0,0 +1 @@
pre, code, a.cut{font-family:"cmuntt", Incosolata, Monaco, monospace}body{font-family:"ComputerModern", Georgia, Palatino, "Century Schoolbook L", "Times New Roman", Times, serif}

1
css/cmufontface.css

@ -0,0 +1 @@
@font-face{font-family:"cmuntt";src:url("fonts/cmuntt.eot");src:local("☺"), url("fonts/cmuntt.svg") format("svg"), url("fonts/cmuntt.ttf") format("truetype");font-weight:normal;font-style:normal}@font-face{font-family:"ComputerModern";src:url("fonts/cmunrb.eot");src:local("☺"), url("fonts/cmunrb.svg") format("svg"), url("fonts/cmunrb.ttf") format("truetype");font-weight:bold}@font-face{font-family:"ComputerModern";src:url("fonts/cmunsl.eot");src:local("☺"), url("fonts/cmunsl.svg") format("svg"), url("fonts/cmunsl.ttf") format("truetype");font-style:italic, oblique}@font-face{font-family:"ComputerModern";src:url("fonts/cmunrm.eot");src:local("☺"), url("fonts/cmunrm.svg") format("svg"), url("fonts/cmunrm.ttf") format("truetype");font-weight:normal;font-style:normal}

1
css/darkmodern.css

File diff suppressed because one or more lines are too long

1
css/dynamic.css

@ -0,0 +1 @@
*{transition-property:all;transition-duration:0.5s;-moz-transition-property:all;-moz-transition-duration:0.5s;-webkit-transition-property:all;-webkit-transition-duration:0.5s;-o-transition-property:all;-o-transition-duration:0.5s}#social *, #comment *{transition-property:all;transition-duration:0s;-moz-transition-property:all;-moz-transition-duration:0s;-webkit-transition-property:all;-webkit-transition-duration:0s;-o-transition-property:all;-o-transition-duration:0s}

BIN
css/fonts/cmunorm.eot

Binary file not shown.

BIN
css/fonts/cmunorm.otf

Binary file not shown.

BIN
css/fonts/cmunorm.svg

Binary file not shown.

BIN
css/fonts/cmunorm.ttf

Binary file not shown.

BIN
css/fonts/cmunorm.woff

Binary file not shown.

BIN
css/fonts/cmunrb.eot

Binary file not shown.

BIN
css/fonts/cmunrb.svg

Binary file not shown.

BIN
css/fonts/cmunrb.ttf

Binary file not shown.

BIN
css/fonts/cmunrm.eot

Binary file not shown.

BIN
css/fonts/cmunrm.otf

Binary file not shown.

BIN
css/fonts/cmunrm.svg

Binary file not shown.

BIN
css/fonts/cmunrm.ttf

Binary file not shown.

BIN
css/fonts/cmunrm.woff

Binary file not shown.

BIN
css/fonts/cmunsl.eot

Binary file not shown.

BIN
css/fonts/cmunsl.svg

Binary file not shown.

BIN
css/fonts/cmunsl.ttf

Binary file not shown.

BIN
css/fonts/cmuntt.eot

Binary file not shown.

BIN
css/fonts/cmuntt.otf

Binary file not shown.

BIN
css/fonts/cmuntt.svg

Binary file not shown.

BIN
css/fonts/cmuntt.ttf

Binary file not shown.

BIN
css/fonts/cmuntt.woff

Binary file not shown.

BIN
css/fonts/social_font.ttf

Binary file not shown.

1
css/modern.css

File diff suppressed because one or more lines are too long

1
css/scientific.css

File diff suppressed because one or more lines are too long

1
css/solarized.css

@ -0,0 +1 @@
pre{padding:0.8em;background:#f3f4f5;color:#657b83;color:#839496;display:block}pre .high0{color:#586e75}pre .high, pre .high1{color:#073642}pre .high2{color:#002b36}pre .DiffInserted, pre .DiffChanged, pre .DiffHeader, pre .DiffDeleted, pre .EmbeddedSource, pre .EmbeddedSourceBright{color:#839496}pre .DiffHeader{font-style:italic}pre .EmbeddedSource, pre .EmbeddedSourceBright{background-color:#073642}pre .low, pre .line-numbers, pre .DoctypeXmlProcessing{color:#586e75}pre .Comment{color:#586e75;font-style:italic}pre .yellow, pre .CssClass, pre .CssPropertyName, pre .Entity, pre .MarkupList{color:#b58900}pre .EntityInheritedClass{color:#b58900;font-style:italic}pre .orange, pre .String, pre .StringRegexp, pre .StringEmbeddedSource, pre .StringConstant, pre .MetaTagAll{color:#cb4b16}pre .red{color:#dc322f}pre .InvalidIllegal, pre .CssAtRule, pre .InvalidDeprecated{color:#dc322f;font-style:italic}pre .magenta, pre .CCCPreprocessorLine, pre .CCCPreprocessorDirective{color:#d33682}pre .violet, pre .Constant{color:#6c71c4}pre .blue, pre .Storage, pre .Variable, pre .CssId, pre .SupportFunction, pre .MetaTagInline, pre .StringRegexpSpecial, pre .CssTagName, pre .StringVariable, pre .Support{color:#268bd2}pre .cyan, pre .MarkupHeading, pre .CssAdditionalConstants, pre .CssPropertyValue, pre .SupportConstant{color:#2aa198}pre .green, pre .CssPseudoClass, pre .Keyword, pre .CssConstructorArgument{color:#859900}pre code{color:#657b83;background-color:#f3f4f5}pre .comment, pre .template_comment, pre .diff .header, pre .doctype, pre .lisp .string, pre .javadoc{color:#93a1a1;font-style:italic}pre .keyword, pre .css .rule .keyword, pre .winutils, pre .javascript .title, pre .method, pre .addition, pre .css .tag, pre .lisp .title{color:#859900}pre .number, pre .command, pre .string, pre .tag .value, pre .phpdoc, pre .tex .formula, pre .regexp, pre .hexcolor{color:#2aa198}pre .title, pre .localvars, pre .function .title, pre .chunk, pre .decorator, pre .builtin, pre .built_in, pre .lisp .title, pre .identifier, pre .title .keymethods, pre .id{color:#268bd2}pre .attribute, pre .variable, pre .instancevar, pre .lisp .body, pre .smalltalk .number, pre .constant, pre .class .title, pre .parent, pre .haskell .label{color:#b58900}pre .preprocessor, pre .pi, pre .shebang, pre .symbol, pre .diff .change, pre .special, pre .keymethods, pre .attr_selector, pre .important, pre .subst, pre .cdata{color:#cb4b16}pre .deletion{color:#dc322f}pre .tex .formula{background:#eee8d5}

BIN
img/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

3
js/article.js

@ -0,0 +1,3 @@
$(document).ready( function() {
hljs.initHighlighting();
});

33
js/become_hidden.html

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
theme: scientific
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script>
$(document).ready(function(){
$.cookie('admin',1, { path: '/Scratch'});
$('#info').html('Analytics can no more see you.')
});
</script>
<title>Hide to analytics</title>
</head>
<body lang="fr">
<div id="content">
<div id="titre">
<h1>
Hide to Analytics
</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<div id="info">
</div>
</div>
</div>
</div>
</body>
</html>

33
js/become_visible.html

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
theme: scientific
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script>
$(document).ready(function(){
$.cookie('admin',null, { path: '/Scratch'});
$('#info').html('Analytics can see you.')
});
</script>
<title>Be visible to analytics</title>
</head>
<body lang="fr">
<div id="content">
<div id="titre">
<h1>
Be visible to Analytics
</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<div id="info">
</div>
</div>
</div>
</div>
</body>
</html>

23
js/genericCommentWrapperV2.js

@ -0,0 +1,23 @@
if(document.getElementById("IDCommentsPostTitle") && document.getElementById("IDCommentsPostTitle").innerHTML.length>0)
idcomments_post_title = document.getElementById("IDCommentsPostTitle").innerHTML;
else
idcomments_post_title = document.title;
if(idcomments_post_title.length==0)
idcomments_post_title = "Post";
idcomments_post_title = idcomments_post_title.replace(/#/, "%23");
if(null==idcomments_post_url || idcomments_post_url==='')
idcomments_post_url = window.location.href;
if(null==idcomments_post_id)
idcomments_post_id = window.location.href;
idcomments_post_id = encodeURIComponent(idcomments_post_id);
idcomments_post_url = encodeURIComponent(idcomments_post_url);
idcomments_post_title = encodeURIComponent(idcomments_post_title);
var commentScript = document.createElement("script");
commentScript.type = "text/javascript";
commentScript.src = "http://intensedebate.com/js/genericCommentWrapper2.php?acct="+idcomments_acct+"&postid="+idcomments_post_id+"&title="+idcomments_post_title+"&url="+idcomments_post_url;
$(document).ready( function() {
document.getElementsByTagName("head")[0].appendChild(commentScript);
});

55
js/highlight/AUTHORS.en.txt

@ -0,0 +1,55 @@
Syntax highlighting with language autodetection.
URL: http://softwaremaniacs.org/soft/highlight/en/
Original author and current maintainer:
Ivan Sagalaev <maniac@softwaremaniacs.org>
Contributors:
- Peter Leonov <gojpeg@gmail.com>
- Victor Karamzin <Victor.Karamzin@enterra-inc.com>
- Vsevolod Solovyov <vsevolod.solovyov@gmail.com>
- Anton Kovalyov <anton@kovalyov.net>
- Nikita Ledyaev <lenikita@yandex.ru>
- Konstantin Evdokimenko <qewerty@gmail.com>
- Dmitri Roudakov <dmitri@roudakov.ru>
- Yuri Ivanov <ivanov@supersoft.ru>
- Vladimir Ermakov <vooon341@mail.ru>
- Vladimir Gubarkov <xonixx@gmail.com>
- Brian Beck <exogen@gmail.com>
- MajestiC <majestic2k@gmail.com>
- Vasily Polovnyov <vast@whiteants.net>
- Vladimir Epifanov <voldmar@voldmar.ru>
- Alexander Makarov (http://rmcreative.ru/)
- Vah <vahtenberg@gmail.com>
- Shuen-Huei Guan <drake.guan@gmail.com>
- Jason Diamond <jason@diamond.name>
- Michal Gabrukiewicz <mgabru@gmail.com>
- Ruslan Keba <rukeba@gmail.com>
- Sergey Baranov <segyrn@yandex.ru>
- Zaripov Yura <yur4ik7@ukr.net>
- Oleg Volchkov <oleg@volchkov.net>
- Vasily Mikhailitchenko <vaskas@programica.ru>
- Jan Berkel <jan.berkel@gmail.com>
- Vladimir Moskva <vladmos@gmail.com>
- Loren Segal <lsegal@soen.ca>
- Andrew Fedorov <dmmdrs@mail.ru>
- Igor Kalnitsky <igor.kalnitsky@gmail.com>
- Jeremy Hull <sourdrums@gmail.com>
- Valerii Hiora <valerii.hiora@gmail.com>
- Nikolay Zakharov <nikolay.desh@gmail.com>
- Dmitry Kovega <arhibot@gmail.com>
- Sergey Ignatov <sergey@ignatov.spb.su>
- Antono Vasiljev <self@antono.info>
- Stephan Kountso <steplg@gmail.com>
- pumbur <pumbur@pumbur.net>
- John Crepezzi <john.crepezzi@gmail.com>
- Andrey Vlasovskikh <andrey.vlasovskikh@gmail.com>
- Alexander Myadzel <myadzel@gmail.com>
- Evgeny Stepanischev <imbolk@gmail.com>
- Dmytrii Nagirniak <dnagir@gmail.com>
- Oleg Efimov <efimovov@gmail.com>
- Luigi Maselli <grigio.org@gmail.com>
- Denis Bardadym <bardadymchik@gmail.com>
- Aahan Krish <geekpanth3r@gmail.com>

55
js/highlight/AUTHORS.ru.txt

@ -0,0 +1,55 @@
Подсветка синтаксиса с автоопределением языка.
URL: http://softwaremaniacs.org/soft/highlight/
Первоначальный автор и ведущий проекта:
Иван Сагалаев <maniac@softwaremaniacs.org>
Внесли свой вклад:
- Петр Леонов <gojpeg@gmail.com>
- Виктор Карамзин <Victor.Karamzin@enterra-inc.com>
- Всеволод Соловьёв <vsevolod.solovyov@gmail.com>
- Антон Ковалёв <anton@kovalyov.net>
- Никита Ледяев <lenikita@yandex.ru>
- Константин Евдокименко <qewerty@gmail.com>
- Дмитрий Рудаков <dmitri@roudakov.ru>
- Юрий Иванов <ivanov@supersoft.ru>
- Владимир Ермаков <vooon341@mail.ru>
- Владимир Губарьков <xonixx@gmail.com>
- Брайан Бек <exogen@gmail.com>
- MajestiC <majestic2k@gmail.com>
- Василий Половнёв <vast@whiteants.net>
- Владимир Епифанов <voldmar@voldmar.ru>
- Александр Макаров (http://rmcreative.ru/)
- Vah <vahtenberg@gmail.com>
- Шуэн-Хуэй Гуан <drake.guan@gmail.com>
- Джейсон Даймонд <jason@diamond.name>
- Михал Габрукевич <mgabru@gmail.com>
- Руслан Кеба <rukeba@gmail.com>
- Сергей Баранов <segyrn@yandex.ru>
- Зарипов Юра <yur4ik7@ukr.net>
- Олег Волчков <oleg@volchkov.net>
- Василий Михайличенко <vaskas@programica.ru>
- Ян Беркель <jan.berkel@gmail.com>
- Владимир Москва <vladmos@gmail.com>
- Лорен Сегал <lsegal@soen.ca>
- Андрей Фёдоров <dmmdrs@mail.ru>
- Игорь Кальницкий <igor.kalnitsky@gmail.com>
- Джереми Халл <sourdrums@gmail.com>
- Валерий Хиора <valerii.hiora@gmail.com>
- Николай Захаров <nikolay.desh@gmail.com>
- Дмитрий Ковега <arhibot@gmail.com>
- Сергей Игнатов <sergey@ignatov.spb.su>
- Антоно Васильев <self@antono.info>
- Степан Кунцьо <steplg@gmail.com>
- pumbur <pumbur@pumbur.net>
- Джон Крепецци <john.crepezzi@gmail.com>
- Андрей Власовских <andrey.vlasovskikh@gmail.com>
- Александр Мядзель <myadzel@gmail.com>
- Евгений Степанищев <imbolk@gmail.com>
- Дмитрий Нагирняк <dnagir@gmail.com>
- Олег Ефимов <efimovov@gmail.com>
- Луиджи Мазелли <grigio.org@gmail.com>
- Денис Бардадым <bardadymchik@gmail.com>
- Аахан Криш <geekpanth3r@gmail.com>

24
js/highlight/LICENSE

@ -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.

140
js/highlight/README.md

@ -0,0 +1,140 @@
# Highlight.js
theme: scientific
Highlight.js highlights syntax in code examples on blogs, forums and,
in fact, on any web page. 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
The download package includes the file "highlight.pack.js" which is a full
compressed version of the library intended for 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:
```html
<script type="text/javascript" src="highlight.pack.js"></script>
<script type="text/javascript">
hljs.initHighlightingOnLoad();
</script>
```
Also you can replace TAB ('\x09') characters used for indentation in your code
with some fixed number of spaces or with a `<span>` to give them special
styling:
```html
<script type="text/javascript">
hljs.tabReplace = ' '; // 4 spaces
// ... or
hljs.tabReplace = '<span class="indent">\t</span>';
hljs.initHighlightingOnLoad();
</script>
```
The script looks in your page for fragments `<pre><code>...</code></pre>`
that are traditionally used 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:
```javascript
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
});
```
If your code container relies on `<br>` tags instead of line breaks (i.e. if
it's not `<pre>`) pass `true` into third parameter of `highlightBlock`:
```javascript
$('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)});
```
### Styling
Elements of code marked up with classes can be styled as desired:
```css
.comment {
color: gray;
}
.keyword {
font-weight: bold;
}
.python .string {
color: blue;
}
.html .atribute .value {
color: green;
}
```
Highlight.js comes with several style themes located in "styles" directory that
can be used directly or as a base for your own experiments.
**Note**: provided styles work for code defined inside `<pre>` blocks. If you use
custom markup you should modify styles accordingly.
For full reference list of classes see [classref.txt][cr].
[cr]: http://github.com/isagalaev/highlight.js/blob/master/classref.txt
## Export
File export.html contains a little program that allows you to paste in a code
snippet and then copy and paste the resulting HTML code generated by the
highlighter. This is useful in situations when you can't use the script itself
on a site.
## Heuristics
Autodetection of a code's language is done using a simple heuristic:
the program tries to highlight a fragment with all available languages and
counts all syntactic structures that it finds along the way. The language
with greatest count wins.
This means that in short fragments the probability of an error is high
(and it really happens sometimes). In this cases you can set the fragment's
language explicitly by assigning a class to the `<code>` element:
```html
<pre><code class="html">...</code></pre>
```
You can use class names recommended in HTML5: "language-html",
"language-php". Classes also can be assigned to the `<pre>` element.
To disable highlighting of a fragment altogether use "no-highlight" class:
```html
<pre><code class="no-highlight">...</code></pre>
```
## Meta
- Version: 6.2
- URL: http://softwaremaniacs.org/soft/highlight/en/
- Author: Ivan Sagalaev (<maniac@softwaremaniacs.org>)
For the license terms see LICENSE files.
For the list of contributors see AUTHORS.en.txt file.

145
js/highlight/README.ru.md

@ -0,0 +1,145 @@
# Highlight.js
theme: scientific
Highlight.js нужен для подсветки синтаксиса в примерах кода в блогах,
форумах и вообще на любых веб-страницах. Пользоваться им очень просто,
потому что работает он автоматически: сам находит блоки кода, сам
определяет язык, сам подсвечивает.
Автоопределением языка можно управлять, когда оно не справляется само (см.
дальше "Эвристика").
## Подключение и использование
В загруженном архиве лежит файл "highlight.pack.js" -- полная сжатая версия
библиотеки для работы. Все несжатые исходные файлы также есть в пакете, поэтому
не стесняйтесь в них смотреть!
Скрипт подключается одним файлом и одним вызовом инициализирующей
функции:
```html
<script type="text/javascript" src="highlight.pack.js"></script>
<script type="text/javascript">
hljs.initHighlightingOnLoad();
</script>
```
Также вы можете заменить символы TAB ('\x09'), используемые для отступов, на
фиксированное количество пробелов или на отдельный `<span>`, чтобы задать ему
какой-нибудь специальный стиль:
```html
<script type="text/javascript">
hljs.tabReplace = ' '; // 4 spaces
// ... or
hljs.tabReplace = '<span class="indent">\t</span>';
hljs.initHighlightingOnLoad();
</script>
```
Дальше скрипт ищет на странице конструкции `<pre><code>...</code></pre>`,
которые традиционно используются для написания кода, и код в них
размечается на куски, помеченные разными значениями классов.
### Инициализация вручную
Если вы используете другие теги для блоков кода, вы можете инициализировать их
явно с помощью функции `highlightBlock(code, tabReplace)`. Она принимает
DOM-элемент с текстом расцвечиваемого кода и опционально - строчку для замены
символов TAB.
Например с использованием jQuery код инициализации может выглядеть так:
```javascript
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
});
```
Если ваш блок кода использует `<br>` вместо переводов строки (т.е. если это не
`<pre>`), передайте `true` третьим параметром в `highlightBlock`:
```javascript
$('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)});
```
### Выбор стилей
Размеченным классами элементам кода можно задать желаемые стили например так:
```css
.comment {
color: gray;
}
.keyword {
font-weight: bold;
}
.python .string {
color: blue;
}
.html .atribute .value {
color: green;
}
```
В комплекте с highlight.js идут несколько стилевых тем в директории styles,
которые можно использовать напрямую или как основу для собственных экспериментов.
**Внимание**: приложенные стили работают для кода, определённого внутри блоков
`<pre>`. Если вы используете собственную разметку, стили нужно исправить
соответствующим образом.
Полный список классов приведён в файле [crossref.txt][cr].
[cr]: http://github.com/isagalaev/highlight.js/blob/master/classref.txt
## Экспорт
В файле export.html находится небольшая программка, которая показывает и дает
скопировать непосредственно HTML-код подсветки для любого заданного фрагмента кода.
Это может понадобится например на сайте, на котором нельзя подключить сам скрипт
highlight.js.
## Эвристика
Определение языка, на котором написан фрагмент, делается с помощью
довольно простой эвристики: программа пытается расцветить фрагмент всеми
языками подряд, и для каждого языка считает количество подошедших
синтаксически конструкций и ключевых слов. Для какого языка нашлось больше,
тот и выбирается.
Это означает, что в коротких фрагментах высока вероятность ошибки, что
периодически и случается. Чтобы указать язык фрагмента явно, надо написать
его название в виде класса к элементу `<code>`:
```html
<pre><code class="html">...</code></pre>
```
Можно использовать рекомендованные в HTML5 названия классов:
"language-html", "language-php". Также можно назначать классы на элемент
`<pre>`.
Чтобы запретить расцветку фрагмента вообще, используется класс "no-highlight":
```html
<pre><code class="no-highlight">...</code></pre>
```
## Координаты
- Версия: 6.2
- URL: http://softwaremaniacs.org/soft/highlight/
- Автор: Иван Сагалаев (<maniac@softwaremaniacs.org>)
Лицензионное соглашение читайте в файле LICENSE.
Список соавторов читайте в файле AUTHORS.ru.txt

497
js/highlight/classref.txt

@ -0,0 +1,497 @@
This is a full list of available classes corresponding to languages'
syntactic structures. The parentheses after language name contain identifiers
used as class names in `<code>` element.
Python ("python"):
keyword keyword
built_in built-in objects (None, False, True and Ellipsis)
number number
string string (of any type)
comment comment
decorator @-decorator for functions
function function header "def some_name(...):"
class class header "class SomeName(...):"
title name of a function or a class inside a header
params everything inside parentheses in a function's or class' header
Python profiler results ("profile"):
number number
string string
builtin builtin function entry
filename filename in an entry
summary profiling summary
header header of table of results
keyword column header
function function name in an entry (including parentheses)
title actual name of a function in an entry (excluding parentheses)
Ruby ("ruby"):
keyword keyword
string string
subst in-string substitution (#{...})
comment comment
yardoctag YARD tag
function function header "def some_name(...):"
class class header "class SomeName(...):"
title name of a function or a class inside a header
parent name of a parent class
symbol symbol
instancevar instance variable
Perl ("perl"):
keyword keyword
comment comment
number number
string string
regexp regular expression
sub subroutine header (from "sub" till "{")
variable variable starting with "$", "%", "@"
operator operator
pod plain old doc
PHP ("php"):
keyword keyword
number number
string string (of any type)
comment comment
phpdoc phpdoc params in comments
variable variable starting with "$"
preprocessor preprocessor marks: "<?php" and "?>"
Scala ("scala"):
keyword keyword
number number
string string
comment comment
annotaion annotation
javadoc javadoc comment
javadoctag @-tag in javadoc
class class header
title class name inside a header
params everything in parentheses inside a class header
inheritance keywords "extends" and "with" inside class header
Go language ("go"):
comment comment
string string constant
number number
keyword language keywords
constant true false nil iota
typename built-in plain types (int, string etc.)
built_in built-in functions
XML ("xml"):
tag any tag from "<" till ">"
comment comment
pi processing instruction (<? ... ?>)
cdata CDATA section
attribute attribute
value attribute's value
HTML ("html"):
keyword HTML tag
tag any tag from "<" till ">"
comment comment
doctype <!DOCTYPE ... > declaration
attribute tag's attribute with or without value
value attribute's value
CSS ("css"):
tag HTML tag in selectors
id #some_name in selectors
class .some_name in selectors
at_rule @-rule till first "{" or ";"
attr_selector attribute selector (square brackets in a[href^=http://])
pseudo pseudo classes and elemens (:after, ::after etc.)
comment comment
rules everything from "{" till "}"
property property name inside a rule
value property value inside a rule, from ":" till ";" or
till the end of rule block
number number within a value
string string within a value
hexcolor hex color (#FFFFFF) within a value
function CSS function within a value
params everything between "(" and ")" within a function
important "!important" symbol
Markdown ("markdown"):
header header
bullet list bullet
emphasis emphasis
strong strong emphasis
blockquote blockquote
code code
horizontal_rule horizontal rule
link_label link label
link_url link url
Django ("django"):
keyword HTML tag in HTML, default tags and default filters in templates
tag any tag from "<" till ">"
comment comment
doctype <!DOCTYPE ... > declaration
attribute tag's attribute with or withou value
value attribute's value
template_tag template tag {% .. %}
variable template variable {{ .. }}
template_comment template comment, both {# .. #} and {% comment %}
filter filter from "|" till the next filter or the end of tag
argument filter argument
JavaScript ("javascript"):
keyword keyword
comment comment
number number
literal special literal: "true", "false" and "null"
string string
regexp regular expression
function header of a function
title name of a function inside a header
params parentheses and everything inside them in a function's header
CoffeeScript ("coffeescript"):
keyword keyword
comment comment
number number
literal special literal: "true", "false" and "null"
string string
regexp regular expression
function header of a function
title name of a function variable inside a header
params parentheses and everything inside them in a function's header
VBScript ("vbscript"):
keyword keyword
number number
string string
comment comment
built_in built-in function
Lua ("lua"):
keyword keyword
number number
string string
comment comment
built_in built-in operator
function header of a function
title name of a function inside a header
params everything inside parentheses in a function's header
long_brackets multiline string in [=[ .. ]=]
Delphi ("delphi"):
keyword keyword
comment comment (of any type)
number number
string string
function header of a function, procedure, constructor and destructor
title name of a function, procedure, constructor or destructor
inside a header
params everything inside parentheses in a function's header
class class' body from "= class" till "end;"
Java ("java"):
keyword keyword
number number
string string
comment commment
annotaion annotation
javadoc javadoc comment
class class header from "class" till "{"
title class name inside a header
params everything in parentheses inside a class header
inheritance keywords "extends" and "implements" inside class header
C++ ("cpp"):
keyword keyword
number number
string string and character
comment comment
preprocessor preprocessor directive
stl_container instantiation of STL containers ("vector<...>")
Objective C ("objectivec"):
keyword keyword
built_in Cocoa/Cocoa Touch constants and classes
number number
string string
comment comment
preprocessor preprocessor directive
class interface/implementation, protocol and forward class declaration
Vala ("vala"):
keyword keyword
number number
string string
comment comment
class class definitions
title in class definition
constant ALL_UPPER_CASE
C# ("cs"):
keyword keyword
number number
string string
comment commment
xmlDocTag xmldoc tag ("///", "<!--", "-->", "<..>")
RenderMan RSL ("rsl"):
keyword keyword
number number
string string (including @"..")
comment comment
preprocessor preprocessor directive
shader sahder keywords
shading shading keywords
built_in built-in function
RenderMan RIB ("rib"):
keyword keyword
number number
string string
comment comment
commands command
Maya Embedded Language ("mel"):
keyword keyword
number number
string string
comment comment
variable variable
SQL ("sql"):
keyword keyword (mostly SQL'92 and SQL'99)
number number
string string (of any type: "..", '..', `..`)
comment comment
aggregate aggregate function
Smalltalk ("smalltalk"):
keyword keyword
number number
string string
comment commment
symbol symbol
array array
class name of a class
char char
localvars block of local variables
Lisp ("lisp"):
keyword keyword
number number
string string
comment commment
variable variable
literal b, t and nil
list non-quoted list
title first symbol in a non-quoted list
body remainder of the non-quoted list
quoted quoted list, both "(quote .. )" and "'(..)"
Ini ("ini"):
title title of a section
value value of a setting of any type
string string
number number
keyword boolean value keyword
Apache ("apache"):
keyword keyword
number number
comment commment
literal On and Off
sqbracket variables in rewrites "%{..}"
cbracket options in rewrites "[..]"
tag begin and end of a configuration section
Nginx ("nginx"):
keyword keyword
string string
number number
comment comment
built_in built-in constant
variable $-variable
Diff ("diff"):
header file header
chunk chunk header within a file
addition added lines
deletion deleted lines
change changed lines
DOS ("dos"):
keyword keyword
flow batch control keyword
stream DOS special files ("con", "prn", ...)
winutils some commands (see dos.js specifically)
envvar environment variables
Bash ("bash"):
keyword keyword
string string
number number
comment comment
literal special literal: "true" и "false"
variable variable
shebang script interpreter header
CMake ("cmake")
keyword keyword
number number
string string
comment commment
envvar $-variable
Axapta ("axapta"):
keyword keyword
number number
string string
comment commment
class class header from "class" till "{"
title class name inside a header
params everything in parentheses inside a class header
inheritance keywords "extends" and "implements" inside class header
preprocessor preprocessor directive
1C ("1c"):
keyword keyword
number number
date date
string string
comment commment
function header of function or procudure
title function name inside a header
params everything in parentheses inside a function header
preprocessor preprocessor directive
AVR assembler ("avrasm"):
keyword keyword
built_in pre-defined register
number number
string string
comment commment
label label
preprocessor preprocessor directive
localvars substitution in .macro
VHDL ("vhdl")
keyword keyword
number number
string string
comment commment
literal signal logical value
Parser3 ("parser3"):
keyword keyword
number number
comment commment
variable variable starting with "$"
preprocessor preprocessor directive
title user-defined name starting with "@"
TeX ("tex"):
comment comment
number number
command command
parameter parameter
formula formula
special special symbol
Haskell ("haskell"):
keyword keyword
built_in built-in typeclass/functions (Bool, Int)
number number
string string
comment comment
class type classes and other data types
title function name
label type class name
Erlang ("erlang"):
comment comment
string string
number number
keyword keyword
record_name record access (#record_name)
title name of declaration function
variable variable (starts with capital letter or with _)
pp.keywords module's attribute (-attribute)
function_name atom or atom:atom in case of function call
Rust ("rust"):
comment comment
string string
number number
keyword keyword
title name of declaration
preprocessor preprocessor directive
ActionScript ("actionscript"):
comment comment
string string
number number
keyword keywords
literal literal
reserved reserved keyword
title name of declaration (package, class or function)
preprocessor preprocessor directive (import, include)
type type of returned value (for functions)
package package (named or not)
class class/interface
function function
param params of function
rest_arg rest argument of function
Matlab ("matlab"):
comment comment
string string
number number
keyword keyword
title function name
function function
param params of function

88
js/highlight/export.html

@ -0,0 +1,88 @@
<!-- saved from url=(0013)about:internet -->
<!-- ^^^ This is for IE not to show security warning for local files,
theme: scientific
see http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2brows.mspx-->
<!--
Highlighted code export
Copyright (c) Vladimir Gubarkov <xonixx@gmail.com>
-->
<html>
<head>
<title>Highlited code export</title>
<link rel="stylesheet" href="styles/default.css">
<meta charset="utf-8">
<style type="text/css">
#t1, #t2 { width: 100%;}
tr { vertical-align: top; }
address { margin-top: 4em; }
</style>
<script src="highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<script type="text/javascript">
String.prototype.escape = function() {
return this.replace(/&/gm, '&amp;').replace(/</gm, '&lt;').replace(/>/gm, '&gt;');
}
function doIt() {
var viewDiv = document.getElementById("highlight-view");
var t1 = document.getElementById("t1");
var t2 = document.getElementById("t2");
var selector = document.getElementById("langSelector");
var selectedLang = selector.options[selector.selectedIndex].value.toLowerCase();
if(selectedLang) {
viewDiv.innerHTML = '<pre><code class="'+selectedLang+'">'+t1.value.escape()+"</code></pre>";
} else { // try auto
viewDiv.innerHTML = '<pre><code>' + t1.value.escape() + "</code></pre>";
}
hljs.highlightBlock(viewDiv.firstChild.firstChild);
t2.value = viewDiv.innerHTML;
}
function copyToBuffer(textToCopy) {
if (window.clipboardData) { // IE
window.clipboardData.setData("Text", textToCopy);
} else if (window.netscape) { // FF
// from http://developer.mozilla.org/en/docs/Using_the_Clipboard
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
gClipboardHelper.copyString(textToCopy);
}
}
</script>
<script type="text/javascript">
var langSelectorHtml = '<label>Language <select id="langSelector">';
langSelectorHtml += '<option value="">Auto</option>';
for (var i in hljs.LANGUAGES) {
if (hljs.LANGUAGES.hasOwnProperty(i))
langSelectorHtml += '<option value=\"'+i+'\">'+i.charAt(0).toUpperCase()+i.substr(1)+'</option>';
}
langSelectorHtml += '</select></label>';
document.write(langSelectorHtml);
</script>
<table width="100%">
<tr>
<td><textarea rows="20" cols="50" id="t1"></textarea></td>
<td><textarea rows="20" cols="50" id="t2"></textarea></td>
</tr>
<tr>
<td>Write a code snippet</td>
<td>Get HTML to paste anywhere (for actual styles and colors see sample.css)</td>
</tr>
</table>
<table width="98%">
<tr>
<td><input type="button" value="Export &rarr;" onclick="doIt()"/></td>
<td align="right"><input type="button" value="Copy to buffer" onclick="copyToBuffer(document.getElementById('t2').value);"/></td>
</tr>
</table>
<div id="highlight-view"></div>
<address>
Export script: <a href="mailto:xonixx@gmail.com">Vladimir Gubarkov</a><br>
Highlighting: <a href="http://softwaremaniacs.org/soft/highlight/">highlight.js</a>
</address>
</body>
</html>

643
js/highlight/highlight.js

@ -0,0 +1,643 @@
/*
Syntax highlighting with language autodetection.
http://softwaremaniacs.org/soft/highlight/
*/
var hljs = new function() {
/* Utility functions */
function escape(value) {
return value.replace(/&/gm, '&amp;').replace(/</gm, '&lt;');
}
function langRe(language, value, global) {
return RegExp(
value,
'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '')
);
}
function findCode(pre) {
for (var i = 0; i < pre.childNodes.length; i++) {
var node = pre.childNodes[i];
if (node.nodeName == 'CODE')
return node;
if (!(node.nodeType == 3 && node.nodeValue.match(/\s+/)))
break;
}
}
function blockText(block, ignoreNewLines) {
var result = '';
for (var i = 0; i < block.childNodes.length; i++)
if (block.childNodes[i].nodeType == 3) {
var chunk = block.childNodes[i].nodeValue;
if (ignoreNewLines)
chunk = chunk.replace(/\n/g, '');
result += chunk;
} else if (block.childNodes[i].nodeName == 'BR')
result += '\n';
else
result += blockText(block.childNodes[i]);
// Thank you, MSIE...
if (/MSIE [678]/.test(navigator.userAgent))
result = result.replace(/\r/g, '\n');
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.length; i++) {
var class_ = classes[i].replace(/^language-/, '');
if (languages[class_] || class_ == 'no-highlight') {
return class_;
}
}
}
/* Stream merging */
function nodeStream(node) {
var result = [];
(function (node, offset) {
for (var i = 0; i < node.childNodes.length; i++) {
if (node.childNodes[i].nodeType == 3)
offset += node.childNodes[i].nodeValue.length;
else if (node.childNodes[i].nodeName == 'BR')
offset += 1;
else if (node.childNodes[i].nodeType == 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]
});
}
}
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 {
/*
To avoid starting the stream just before it should stop the order is
ensured that stream1 always starts first and closes last:
if (event1 == 'start' && event2 == 'start')
return stream1;
if (event1 == 'start' && event2 == 'stop')
return stream2;
if (event1 == 'stop' && event2 == 'start')
return stream1;
if (event1 == 'stop' && event2 == 'stop')
return stream2;
... which is collapsed to:
*/
return stream2[0].event == 'start' ? stream1 : stream2;
}
} else {
return stream1.length ? stream1 : stream2;
}
}
function open(node) {
var result = '<' + node.nodeName.toLowerCase();
for (var i = 0; i < node.attributes.length; i++) {
var attribute = node.attributes[i];
result += ' ' + attribute.nodeName.toLowerCase();
if (attribute.value !== undefined && attribute.value !== false && attribute.value !== null) {
result += '="' + escape(attribute.value) + '"';
}
}
return result + '>';
}
while (stream1.length || stream2.length) {
var current = selectStream().splice(0, 1)[0];
result += escape(value.substr(processed, current.offset - processed));
processed = current.offset;
if ( current.event == 'start') {
result += open(current.node);
nodeStack.push(current.node);
} else if (current.event == 'stop') {
var node, i = nodeStack.length;
do {
i--;
node = nodeStack[i];
result += ('</' + node.nodeName.toLowerCase() + '>');
} while (node != current.node);
nodeStack.splice(i, 1);
while (i < nodeStack.length) {
result += open(nodeStack[i]);
i++;
}
}
}
return result + escape(value.substr(processed));
}
/* Initialization */
function compileModes() {
function compileMode(mode, language, is_default) {
if (mode.compiled)
return;
var group;
if (!is_default) {
mode.beginRe = langRe(language, mode.begin ? mode.begin : '\\B|\\b');
if (!mode.end && !mode.endsWithParent)
mode.end = '\\B|\\b';
if (mode.end)
mode.endRe = langRe(language, mode.end);
}
if (mode.illegal)
mode.illegalRe = langRe(language, mode.illegal);
if (mode.relevance === undefined)
mode.relevance = 1;
if (mode.keywords) {
mode.lexemsRe = langRe(language, mode.lexems || hljs.IDENT_RE, true);
for (var className in mode.keywords) {
if (!mode.keywords.hasOwnProperty(className))
continue;
if (mode.keywords[className] instanceof Object) {
group = mode.keywords[className];
} else {
group = mode.keywords;
className = 'keyword';
}
for (var keyword in group) {
if (!group.hasOwnProperty(keyword))
continue;
mode.keywords[keyword] = [className, group[keyword]];
}
}
}
if (!mode.contains) {
mode.contains = [];
}
// compiled flag is set before compiling submodes to avoid self-recursion
// (see lisp where quoted_list contains quoted_list)
mode.compiled = true;
for (var i = 0; i < mode.contains.length; i++) {
if (mode.contains[i] == 'self') {
mode.contains[i] = mode;
}
compileMode(mode.contains[i], language, false);
}
if (mode.starts) {
compileMode(mode.starts, language, false);
}
}
for (var i in languages) {
if (!languages.hasOwnProperty(i))
continue;
compileMode(languages[i].defaultMode, languages[i], true);
}
}
/*
Core highlighting function. Accepts a language name and a string with the
code to highlight. Returns an object with the following properties:
- relevance (int)
- keyword_count (int)
- value (an HTML string with highlighting markup)
*/
function highlight(language_name, value) {
if (!compileModes.called) {
compileModes();
compileModes.called = true;
}
function subMode(lexem, mode) {
for (var i = 0; i < mode.contains.length; i++) {
if (mode.contains[i].beginRe.test(lexem)) {
return mode.contains[i];
}
}
}
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.illegal && mode.illegalRe.test(lexem);
}
function compileTerminators(mode, language) {
var terminators = [];
for (var i = 0; i < mode.contains.length; i++) {
terminators.push(mode.contains[i].begin);
}
var index = modes.length - 1;
do {
if (modes[index].end) {
terminators.push(modes[index].end);
}
index--;
} while (modes[index + 1].endsWithParent);
if (mode.illegal) {
terminators.push(mode.illegal);
}
return langRe(language, '(' + terminators.join('|') + ')', true);
}
function eatModeChunk(value, index) {
var mode = modes[modes.length - 1];
if (!mode.terminators) {
mode.terminators = compileTerminators(mode, language);
}
mode.terminators.lastIndex = index;
var match = mode.terminators.exec(value);
if (match)
return [value.substr(index, match.index - index), match[0], false];
else
return [value.substr(index), '', true];
}
function keywordMatch(mode, match) {
var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
var value = mode.keywords[match_str];
if (value && value instanceof Array)
return value;
return false;
}
function processKeywords(buffer, mode) {
buffer = escape(buffer);
if (!mode.keywords)
return buffer;
var result = '';
var last_index = 0;
mode.lexemsRe.lastIndex = 0;
var match = mode.lexemsRe.exec(buffer);
while (match) {
result += 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] +'">' + match[0] + '</span>';
} else {
result += match[0];
}
last_index = mode.lexemsRe.lastIndex;
match = mode.lexemsRe.exec(buffer);
}
return result + buffer.substr(last_index, buffer.length - last_index);
}
function processBuffer(buffer, mode) {
if (mode.subLanguage && languages[mode.subLanguage]) {
var result = highlight(mode.subLanguage, buffer);
keyword_count += result.keyword_count;
return result.value;
} else {
return processKeywords(buffer, mode);
}
}
function startNewMode(mode, lexem) {
var markup = mode.className?'<span class="' + mode.className + '">':'';
if (mode.returnBegin) {
result += markup;
mode.buffer = '';
} else if (mode.excludeBegin) {
result += escape(lexem) + markup;
mode.buffer = '';
} else {
result += markup;
mode.buffer = lexem;
}
modes.push(mode);
relevance += mode.relevance;
}
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);
return new_mode.returnBegin;
}
var end_level = endOfMode(modes.length - 1, lexem);
if (end_level) {
var markup = current_mode.className?'</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].className?'</span>':'';
result += markup;
end_level--;
modes.length--;