julia-repl.js 1.7 KB

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