PageRenderTime 4125ms CodeModel.GetById 13ms RepoModel.GetById 4ms app.codeStats 1ms

/samples/scalate-sample-sitegen/src/highlight/readme.eng.txt

http://github.com/scalate/scalate
Plain Text | 486 lines | 376 code | 110 blank | 0 comment | 0 complexity | 9db4724fef74148df95dcc2900c95a2c MD5 | raw file
  1. # Highlight.js
  2. Highlight.js highlights syntax in code examples on blogs, forums and
  3. in fact on any web pages. 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. ## Installation and usage
  7. Downloaded package includes file "highlight.pack.js" which is a full compressed
  8. version of the library intended to use in production. All uncompressed source
  9. files are also available, feel free to look into them!
  10. The script is installed by linking to a single file and making a single
  11. initialization call:
  12. <script type="text/javascript" src="highlight.pack.js"></script>
  13. <script type="text/javascript">
  14. hljs.initHighlightingOnLoad();
  15. </script>
  16. Also you can replaces TAB ('\x09') characters used for indentation in your code
  17. with some fixed number of spaces or with a `<span>` to set them special styling:
  18. <script type="text/javascript">
  19. hljs.tabReplace = ' '; // 4 spaces
  20. // ... or
  21. hljs.tabReplace = '<span class="indent">\t</span>';
  22. hljs.initHighlightingOnLoad();
  23. </script>
  24. Then the script looks in your page for fragments `<pre><code>...</code></pre>`
  25. that are used traditionally to mark up code examples. Their content is
  26. marked up by logical pieces with defined class names.
  27. ### Custom initialization
  28. If you use different markup for code blocks you can initialize them manually
  29. with `highlightBlock(code, tabReplace)` function. It takes a DOM element
  30. containing the code to highlight and optionally a string with which to replace
  31. TAB characters.
  32. Initialization using for example jQuery might look like this:
  33. $(document).ready(function() {
  34. $('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
  35. });
  36. ### Styling
  37. Elements of code marked up with classes can be styled as desired:
  38. .comment {
  39. color: gray;
  40. }
  41. .keyword {
  42. font-weight: bold;
  43. }
  44. .python .string {
  45. color: blue;
  46. }
  47. .html .atribute .value {
  48. color: green;
  49. }
  50. Highligt.js comes with several style themes located in "styles" directory that
  51. can be used directly or as a base for your own experiments.
  52. A full list of available classes is below ("Languages").
  53. ## Export
  54. File export.html contains a little program that shows and allows to copy and paste
  55. an HTML code generated by the highlighter for any code snippet. This can be useful
  56. in situations when one can't use the script itself on a site.
  57. ## Languages
  58. This is a full list of available classes corresponding to languages'
  59. syntactic structures. In parentheses after language names are identifiers
  60. used as class names in `<code>` element.
  61. Python ("python"):
  62. keyword keyword
  63. built_in built-in objects (None, False, True and Ellipsis)
  64. number number
  65. string string (of any type)
  66. comment comment
  67. decorator @-decorator for functions
  68. function function header "def some_name(...):"
  69. class class header "class SomeName(...):"
  70. title name of a function or a class inside a header
  71. params everything inside parentheses in a function's or class' header
  72. Python profiler results ("profile"):
  73. number number
  74. string string
  75. builtin builtin function entry
  76. filename filename in an entry
  77. summary profiling summary
  78. header header of table of results
  79. keyword column header
  80. function function name in an entry (including parentheses)
  81. title actual name of a function in an entry (excluding parentheses)
  82. Ruby ("ruby"):
  83. keyword keyword
  84. string string
  85. subst in-string substitution (#{...})
  86. comment comment
  87. yardoctag YARD tag
  88. function function header "def some_name(...):"
  89. class class header "class SomeName(...):"
  90. title name of a function or a class inside a header
  91. parent name of a parent class
  92. symbol symbol
  93. instancevar instance variable
  94. Perl ("perl"):
  95. keyword keyword
  96. comment comment
  97. number number
  98. string string
  99. regexp regular expression
  100. sub subroutine header (from "sub" till "{")
  101. variable variable starting with "$", "%", "@"
  102. operator operator
  103. pod plain old doc
  104. PHP ("php"):
  105. keyword keyword
  106. number number
  107. string string (of any type)
  108. comment comment
  109. phpdoc phpdoc params in comments
  110. variable variable starting with "$"
  111. preprocessor preprocessor marks: "<?php" and "?>"
  112. Scala ("scala"):
  113. keyword keyword
  114. number number
  115. string string
  116. comment comment
  117. annotaion annotation
  118. javadoc javadoc comment
  119. javadoctag @-tag in javadoc
  120. class class header
  121. title class name inside a header
  122. params everything in parentheses inside a class header
  123. inheritance keywords "extends" and "with" inside class header
  124. XML ("xml"):
  125. tag any tag from "<" till ">"
  126. comment comment
  127. pi processing instruction (<? ... ?>)
  128. cdata CDATA section
  129. attribute attribute
  130. value attribute's value
  131. HTML ("html"):
  132. keyword HTML tag
  133. tag any tag from "<" till ">"
  134. comment comment
  135. doctype <!DOCTYPE ... > declaration
  136. attribute tag's attribute with or without value
  137. value attribute's value
  138. CSS ("css"):
  139. keyword HTML tag when in selectors, CSS keyword when in rules
  140. id #some_name in selectors
  141. class .some_name in selectors
  142. at_rule @-rule till first "{" or ";"
  143. attr_selector attribute selector (square brackets in a[href^=http://])
  144. pseudo pseudo classes and elemens (:after, ::after etc.)
  145. comment comment
  146. rules everything from "{" till "}"
  147. value property's value inside a rule, from ":" till ";" or
  148. till the end of rule block
  149. number number within a value
  150. string string within a value
  151. hexcolor hex color (#FFFFFF) within a value
  152. function CSS function within a value
  153. params everything between "(" and ")" within a function
  154. Django ("django"):
  155. keyword HTML tag in HTML, default tags and default filters in templates
  156. tag any tag from "<" till ">"
  157. comment comment
  158. doctype <!DOCTYPE ... > declaration
  159. attribute tag's attribute with or withou value
  160. value attribute's value
  161. template_tag template tag {% .. %}
  162. variable template variable {{ .. }}
  163. template_comment template comment, both {# .. #} and {% comment %}
  164. filter filter from "|" till the next filter or the end of tag
  165. argument filter argument
  166. Javascript ("javascript"):
  167. keyword keyword
  168. comment comment
  169. number number
  170. literal special literal: "true", "false" and "null"
  171. string string
  172. regexp regular expression
  173. function header of a function
  174. title name of a function inside a header
  175. params everything inside parentheses in a function's header
  176. VBScript ("vbscript"):
  177. keyword keyword
  178. number number
  179. string string
  180. comment comment
  181. built_in built-in function
  182. Lua ("lua"):
  183. keyword keyword
  184. number number
  185. string string
  186. comment comment
  187. built_in built-in operator
  188. function header of a function
  189. title name of a function inside a header
  190. params everything inside parentheses in a function's header
  191. long_brackets multiline string in [=[ .. ]=]
  192. Delphi ("delphi"):
  193. keyword keyword
  194. comment comment (of any type)
  195. number number
  196. string string
  197. function header of a function, procedure, constructor and destructor
  198. title name of a function, procedure, constructor or destructor
  199. inside a header
  200. params everything inside parentheses in a function's header
  201. class class' body from "= class" till "end;"
  202. Java ("java"):
  203. keyword keyword
  204. number number
  205. string string
  206. comment commment
  207. annotaion annotation
  208. javadoc javadoc comment
  209. class class header from "class" till "{"
  210. title class name inside a header
  211. params everything in parentheses inside a class header
  212. inheritance keywords "extends" and "implements" inside class header
  213. C++ ("cpp"):
  214. keyword keyword
  215. number number
  216. string string and character
  217. comment comment
  218. preprocessor preprocessor directive
  219. stl_container instantiation of STL containers ("vector<...>")
  220. C# ("cs"):
  221. keyword keyword
  222. number number
  223. string string
  224. comment commment
  225. xmlDocTag xmldoc tag ("///", "<!--", "-->", "<..>")
  226. RenderMan RSL ("rsl"):
  227. keyword keyword
  228. number number
  229. string string (including @"..")
  230. comment comment
  231. preprocessor preprocessor directive
  232. shader sahder keywords
  233. shading shading keywords
  234. built_in built-in function
  235. RenderMan RIB ("rib"):
  236. keyword keyword
  237. number number
  238. string string
  239. comment comment
  240. commands command
  241. Maya Embedded Language ("mel"):
  242. keyword keyword
  243. number number
  244. string string
  245. comment comment
  246. variable variable
  247. SQL ("sql"):
  248. keyword keyword (mostly SQL'92 and SQL'99)
  249. number number
  250. string string (of any type: "..", '..', `..`)
  251. comment comment
  252. aggregate aggregate function
  253. Smalltalk ("smalltalk"):
  254. keyword keyword
  255. number number
  256. string string
  257. comment commment
  258. symbol symbol
  259. array array
  260. class name of a class
  261. char char
  262. localvars block of local variables
  263. Lisp ("lisp"):
  264. keyword keyword
  265. number number
  266. string string
  267. comment commment
  268. variable variable
  269. literal b, t and nil
  270. list non-quoted list
  271. title first symbol in a non-quoted list
  272. body remainder of the non-quoted list
  273. quoted_list quoted list, both "(quote .. )" and "'(..)"
  274. Ini ("ini"):
  275. title title of a section
  276. value value of a setting of any type
  277. string string
  278. number number
  279. keyword boolean value keyword
  280. Apache ("apache"):
  281. keyword keyword
  282. number number
  283. comment commment
  284. literal On and Off
  285. sqbracket variables in rewrites "%{..}"
  286. cbracket options in rewrites "[..]"
  287. tag begin and end of a configuration section
  288. Nginx ("nginx"):
  289. keyword keyword
  290. string string
  291. number number
  292. comment comment
  293. built_in built-in constant
  294. variable $-variable
  295. DOS ("dos"):
  296. keyword keyword
  297. flow batch control keyword
  298. stream DOS special files ("con", "prn", ...)
  299. winutils some commands (see dos.js specifically)
  300. envvar environment variables
  301. Bash ("bash"):
  302. keyword keyword
  303. string string
  304. number number
  305. comment comment
  306. literal special literal: "true" и "false"
  307. variable variable
  308. shebang script interpreter header
  309. Diff ("diff"):
  310. header file header
  311. chunk chunk header within a file
  312. addition added lines
  313. deletion deleted lines
  314. change changed lines
  315. Axapta ("axapta"):
  316. keyword keyword
  317. number number
  318. string string
  319. comment commment
  320. class class header from "class" till "{"
  321. title class name inside a header
  322. params everything in parentheses inside a class header
  323. inheritance keywords "extends" and "implements" inside class header
  324. preprocessor preprocessor directive
  325. 1C ("1c"):
  326. keyword keyword
  327. number number
  328. date date
  329. string string
  330. comment commment
  331. function header of function or procudure
  332. title function name inside a header
  333. params everything in parentheses inside a function header
  334. preprocessor preprocessor directive
  335. AVR assembler ("avrasm"):
  336. keyword keyword
  337. built_in pre-defined register
  338. number number
  339. string string
  340. comment commment
  341. label label
  342. preprocessor preprocessor directive
  343. localvars substitution in .macro
  344. Parser3 ("parser3"):
  345. keyword keyword
  346. number number
  347. comment commment
  348. variable variable starting with "$"
  349. preprocessor preprocessor directive
  350. title user-defined name starting with "@"
  351. TeX ("tex"):
  352. comment comment
  353. number number
  354. command command
  355. parameter parameter
  356. formula formula
  357. special special symbol
  358. ## Heuristics
  359. Autodetection of a code's language is done with a simple heuristics:
  360. the program tries to highlight a fragment with all available languages and
  361. counts all syntactic structures that it finds along the way. The language
  362. with greatest count wins.
  363. This means that in short fragments the probability of an error is high
  364. (and it really happens sometimes). In this cases you can set the fragment's
  365. language explicitly by assigning a class to the `<code>` element:
  366. <pre><code class="html">...</code></pre>
  367. You can use class names recommended in HTML5: "language-html",
  368. "language-php". Classes also can be assigned to the `<pre>` element.
  369. To disable highlighting of a fragment altogether use "no-highlight" class:
  370. <pre><code class="no-highlight">...</code></pre>
  371. ## Contacts
  372. Version: 5.11
  373. URL: http://softwaremaniacs.org/soft/highlight/en/
  374. Author: Ivan Sagalaev (Maniac@SoftwareManiacs.Org)
  375. For the license terms see LICENSE files.
  376. For the list of contributors see AUTHORS.en.txt file.