UNPKG

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