julia-repl.js 1.8 KB

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