]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/julia-repl.js
Initial commit.
[flow-web.git] / static / highlight / languages / julia-repl.js
1 /*! `julia-repl` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Julia REPL
8 Description: Julia REPL sessions
9 Author: Morten Piibeleht <morten.piibeleht@gmail.com>
10 Website: https://julialang.org
11 Requires: julia.js
12 Category: scientific
13
14 The Julia REPL code blocks look something like the following:
15
16 julia> function foo(x)
17 x + 1
18 end
19 foo (generic function with 1 method)
20
21 They start on a new line with "julia>". Usually there should also be a space after this, but
22 we also allow the code to start right after the > character. The code may run over multiple
23 lines, but the additional lines must start with six spaces (i.e. be indented to match
24 "julia>"). The rest of the code is assumed to be output from the executed code and will be
25 left un-highlighted.
26
27 Using simply spaces to identify line continuations may get a false-positive if the output
28 also prints out six spaces, but such cases should be rare.
29 */
30
31 function juliaRepl(hljs) {
32 return {
33 name: 'Julia REPL',
34 contains: [
35 {
36 className: 'meta.prompt',
37 begin: /^julia>/,
38 relevance: 10,
39 starts: {
40 // end the highlighting if we are on a new line and the line does not have at
41 // least six spaces in the beginning
42 end: /^(?![ ]{6})/,
43 subLanguage: 'julia'
44 },
45 },
46 ],
47 // jldoctest Markdown blocks are used in the Julia manual and package docs indicate
48 // code snippets that should be verified when the documentation is built. They can be
49 // either REPL-like or script-like, but are usually REPL-like and therefore we apply
50 // julia-repl highlighting to them. More information can be found in Documenter's
51 // manual: https://juliadocs.github.io/Documenter.jl/latest/man/doctests.html
52 aliases: [ 'jldoctest' ],
53 };
54 }
55
56 return juliaRepl;
57
58 })();
59
60 hljs.registerLanguage('julia-repl', hljsGrammar);
61 })();