prism-xml-doc.js 781 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function (Prism) {
  2. /**
  3. * If the given language is present, it will insert the given doc comment grammar token into it.
  4. *
  5. * @param {string} lang
  6. * @param {any} docComment
  7. */
  8. function insertDocComment(lang, docComment) {
  9. if (Prism.languages[lang]) {
  10. Prism.languages.insertBefore(lang, 'comment', {
  11. 'doc-comment': docComment
  12. });
  13. }
  14. }
  15. var tag = Prism.languages.markup.tag;
  16. var slashDocComment = {
  17. pattern: /\/\/\/.*/,
  18. greedy: true,
  19. alias: 'comment',
  20. inside: {
  21. 'tag': tag
  22. }
  23. };
  24. var tickDocComment = {
  25. pattern: /'''.*/,
  26. greedy: true,
  27. alias: 'comment',
  28. inside: {
  29. 'tag': tag
  30. }
  31. };
  32. insertDocComment('csharp', slashDocComment);
  33. insertDocComment('fsharp', slashDocComment);
  34. insertDocComment('vbnet', tickDocComment);
  35. }(Prism));