PageRenderTime 25ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/Presentation/libraries/highlighters/highlight.js/README.md

https://gitlab.com/zubrand/R-Tutorial
Markdown | 209 lines | 161 code | 48 blank | 0 comment | 0 complexity | 635e360d22aa8b65d9d029302bf1f2ea MD5 | raw file
  1. # Highlight.js
  2. Highlight.js highlights syntax in code examples on blogs, forums and,
  3. in fact, on any web page. It's very easy to use because it works
  4. automatically: finds blocks of code, detects a language, highlights it.
  5. Autodetection can be fine tuned when it fails by itself (see "Heuristics").
  6. ## Basic usage
  7. Link the library and a stylesheet from your page and hook highlighting to
  8. the page load event:
  9. ```html
  10. <link rel="stylesheet" href="styles/default.css">
  11. <script src="highlight.pack.js"></script>
  12. <script>hljs.initHighlightingOnLoad();</script>
  13. ```
  14. This will highlight all code on the page marked up as `<pre><code> .. </code></pre>`.
  15. If you use different markup or need to apply highlighting dynamically, read
  16. "Custom initialization" below.
  17. - You can download your own customized version of "highlight.pack.js" or
  18. use the hosted one as described on the download page:
  19. <http://softwaremaniacs.org/soft/highlight/en/download/>
  20. - Style themes are available in the download package or as hosted files.
  21. To create a custom style for your site see the class reference in the file
  22. [classref.txt][cr] from the downloaded package.
  23. [cr]: http://github.com/isagalaev/highlight.js/blob/master/classref.txt
  24. ## Tab replacement
  25. You can replace TAB ('\x09') characters used for indentation in your code
  26. with some fixed number of spaces or with a `<span>` to give them special
  27. styling:
  28. ```html
  29. <script type="text/javascript">
  30. hljs.tabReplace = ' '; // 4 spaces
  31. // ... or
  32. hljs.tabReplace = '<span class="indent">\t</span>';
  33. hljs.initHighlightingOnLoad();
  34. </script>
  35. ```
  36. ## Custom initialization
  37. If you use different markup for code blocks you can initialize them manually
  38. with `highlightBlock(code, tabReplace, useBR)` function. It takes a DOM element
  39. containing the code to highlight and optionally a string with which to replace
  40. TAB characters.
  41. Initialization using, for example, jQuery might look like this:
  42. ```javascript
  43. $(document).ready(function() {
  44. $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
  45. });
  46. ```
  47. You can use `highlightBlock` to highlight blocks dynamically inserted into
  48. the page. Just make sure you don't do it twice for already highlighted
  49. blocks.
  50. If your code container relies on `<br>` tags instead of line breaks (i.e. if
  51. it's not `<pre>`) pass `true` into the third parameter of `highlightBlock`
  52. to make highlight.js use `<br>` in the output:
  53. ```javascript
  54. $('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)});
  55. ```
  56. ## Heuristics
  57. Autodetection of a code's language is done using a simple heuristic:
  58. the program tries to highlight a fragment with all available languages and
  59. counts all syntactic structures that it finds along the way. The language
  60. with greatest count wins.
  61. This means that in short fragments the probability of an error is high
  62. (and it really happens sometimes). In this cases you can set the fragment's
  63. language explicitly by assigning a class to the `<code>` element:
  64. ```html
  65. <pre><code class="html">...</code></pre>
  66. ```
  67. You can use class names recommended in HTML5: "language-html",
  68. "language-php". Classes also can be assigned to the `<pre>` element.
  69. To disable highlighting of a fragment altogether use "no-highlight" class:
  70. ```html
  71. <pre><code class="no-highlight">...</code></pre>
  72. ```
  73. ## Export
  74. File export.html contains a little program that allows you to paste in a code
  75. snippet and then copy and paste the resulting HTML code generated by the
  76. highlighter. This is useful in situations when you can't use the script itself
  77. on a site.
  78. ## Meta
  79. - Version: 6.2
  80. - URL: http://softwaremaniacs.org/soft/highlight/en/
  81. - Author: Ivan Sagalaev (<maniac@softwaremaniacs.org>)
  82. ## License ##
  83. Copyright (c) 2006, Ivan Sagalaev
  84. All rights reserved.
  85. Redistribution and use in source and binary forms, with or without
  86. modification, are permitted provided that the following conditions are met:
  87. * Redistributions of source code must retain the above copyright
  88. notice, this list of conditions and the following disclaimer.
  89. * Redistributions in binary form must reproduce the above copyright
  90. notice, this list of conditions and the following disclaimer in the
  91. documentation and/or other materials provided with the distribution.
  92. * Neither the name of highlight.js nor the names of its contributors
  93. may be used to endorse or promote products derived from this software
  94. without specific prior written permission.
  95. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
  96. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  97. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  98. DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
  99. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  100. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  101. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  102. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  103. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  104. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  105. ## Authors ##
  106. Syntax highlighting with language autodetection.
  107. URL: http://softwaremaniacs.org/soft/highlight/en/
  108. Original author and current maintainer:
  109. Ivan Sagalaev <maniac@softwaremaniacs.org>
  110. Contributors:
  111. - Peter Leonov <gojpeg@gmail.com>
  112. - Victor Karamzin <Victor.Karamzin@enterra-inc.com>
  113. - Vsevolod Solovyov <vsevolod.solovyov@gmail.com>
  114. - Anton Kovalyov <anton@kovalyov.net>
  115. - Nikita Ledyaev <lenikita@yandex.ru>
  116. - Konstantin Evdokimenko <qewerty@gmail.com>
  117. - Dmitri Roudakov <dmitri@roudakov.ru>
  118. - Yuri Ivanov <ivanov@supersoft.ru>
  119. - Vladimir Ermakov <vooon341@mail.ru>
  120. - Vladimir Gubarkov <xonixx@gmail.com>
  121. - Brian Beck <exogen@gmail.com>
  122. - MajestiC <majestic2k@gmail.com>
  123. - Vasily Polovnyov <vast@whiteants.net>
  124. - Vladimir Epifanov <voldmar@voldmar.ru>
  125. - Alexander Makarov (http://rmcreative.ru/)
  126. - Vah <vahtenberg@gmail.com>
  127. - Shuen-Huei Guan <drake.guan@gmail.com>
  128. - Jason Diamond <jason@diamond.name>
  129. - Michal Gabrukiewicz <mgabru@gmail.com>
  130. - Ruslan Keba <rukeba@gmail.com>
  131. - Sergey Baranov <segyrn@yandex.ru>
  132. - Zaripov Yura <yur4ik7@ukr.net>
  133. - Oleg Volchkov <oleg@volchkov.net>
  134. - Vasily Mikhailitchenko <vaskas@programica.ru>
  135. - Jan Berkel <jan.berkel@gmail.com>
  136. - Vladimir Moskva <vladmos@gmail.com>
  137. - Loren Segal <lsegal@soen.ca>
  138. - Andrew Fedorov <dmmdrs@mail.ru>
  139. - Igor Kalnitsky <igor@kalnitsky.org>
  140. - Jeremy Hull <sourdrums@gmail.com>
  141. - Valerii Hiora <valerii.hiora@gmail.com>
  142. - Nikolay Zakharov <nikolay.desh@gmail.com>
  143. - Dmitry Kovega <arhibot@gmail.com>
  144. - Sergey Ignatov <sergey@ignatov.spb.su>
  145. - Antono Vasiljev <self@antono.info>
  146. - Stephan Kountso <steplg@gmail.com>
  147. - pumbur <pumbur@pumbur.net>
  148. - John Crepezzi <john.crepezzi@gmail.com>
  149. - Andrey Vlasovskikh <andrey.vlasovskikh@gmail.com>
  150. - Alexander Myadzel <myadzel@gmail.com>
  151. - Evgeny Stepanischev <imbolk@gmail.com>
  152. - Dmytrii Nagirniak <dnagir@gmail.com>
  153. - Oleg Efimov <efimovov@gmail.com>
  154. - Luigi Maselli <grigio.org@gmail.com>
  155. - Denis Bardadym <bardadymchik@gmail.com>
  156. - Aahan Krish <geekpanth3r@gmail.com>
  157. - Ilya Baryshev <baryshev@gmail.com>
  158. - Aleksandar Ruzicic <aleksandar@ruzicic.info>
  159. - Joe Cheng <joe@rstudio.org>
  160. - Angel G. Olloqui <angelgarcia.mail@gmail.com>
  161. - Jason Tate <adminz@web-cms-designs.com>