prismjs_components_prism-shell-session.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // node_modules/prismjs/components/prism-shell-session.js
  2. (function(Prism2) {
  3. var strings = [
  4. // normal string
  5. /"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/.source,
  6. /'[^']*'/.source,
  7. /\$'(?:[^'\\]|\\[\s\S])*'/.source,
  8. // here doc
  9. // 2 capturing groups
  10. /<<-?\s*(["']?)(\w+)\1\s[\s\S]*?[\r\n]\2/.source
  11. ].join("|");
  12. Prism2.languages["shell-session"] = {
  13. "command": {
  14. pattern: RegExp(
  15. // user info
  16. /^/.source + "(?:" + // <user> ":" ( <path> )?
  17. (/[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+(?::[^\0-\x1F$#%*?"<>:;|]+)?/.source + "|" + // <path>
  18. // Since the path pattern is quite general, we will require it to start with a special character to
  19. // prevent false positives.
  20. /[/~.][^\0-\x1F$#%*?"<>@:;|]*/.source) + ")?" + // shell symbol
  21. /[$#%](?=\s)/.source + // bash command
  22. /(?:[^\\\r\n \t'"<$]|[ \t](?:(?!#)|#.*$)|\\(?:[^\r]|\r\n?)|\$(?!')|<(?!<)|<<str>>)+/.source.replace(/<<str>>/g, function() {
  23. return strings;
  24. }),
  25. "m"
  26. ),
  27. greedy: true,
  28. inside: {
  29. "info": {
  30. // foo@bar:~/files$ exit
  31. // foo@bar$ exit
  32. // ~/files$ exit
  33. pattern: /^[^#$%]+/,
  34. alias: "punctuation",
  35. inside: {
  36. "user": /^[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+/,
  37. "punctuation": /:/,
  38. "path": /[\s\S]+/
  39. }
  40. },
  41. "bash": {
  42. pattern: /(^[$#%]\s*)\S[\s\S]*/,
  43. lookbehind: true,
  44. alias: "language-bash",
  45. inside: Prism2.languages.bash
  46. },
  47. "shell-symbol": {
  48. pattern: /^[$#%]/,
  49. alias: "important"
  50. }
  51. }
  52. },
  53. "output": /.(?:.*(?:[\r\n]|.$))*/
  54. };
  55. Prism2.languages["sh-session"] = Prism2.languages["shellsession"] = Prism2.languages["shell-session"];
  56. })(Prism);
  57. //# sourceMappingURL=prismjs_components_prism-shell-session.js.map