prism-aspnet.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Prism.languages.aspnet = Prism.languages.extend('markup', {
  2. 'page-directive tag': {
  3. pattern: /<%\s*@.*%>/i,
  4. inside: {
  5. 'page-directive tag': /<%\s*@\s*(?:Assembly|Control|Implements|Import|Master|MasterType|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,
  6. rest: Prism.languages.markup.tag.inside
  7. }
  8. },
  9. 'directive tag': {
  10. pattern: /<%.*%>/i,
  11. inside: {
  12. 'directive tag': /<%\s*?[$=%#:]{0,2}|%>/i,
  13. rest: Prism.languages.csharp
  14. }
  15. }
  16. });
  17. // match directives of attribute value foo="<% Bar %>"
  18. Prism.languages.insertBefore('inside', 'punctuation', {
  19. 'directive tag': Prism.languages.aspnet['directive tag']
  20. }, Prism.languages.aspnet.tag.inside["attr-value"]);
  21. Prism.languages.insertBefore('aspnet', 'comment', {
  22. 'asp comment': /<%--[\w\W]*?--%>/
  23. });
  24. // script runat="server" contains csharp, not javascript
  25. Prism.languages.insertBefore('aspnet', Prism.languages.javascript ? 'script' : 'tag', {
  26. 'asp script': {
  27. pattern: /<script(?=.*runat=['"]?server['"]?)[\w\W]*?>[\w\W]*?<\/script>/i,
  28. inside: {
  29. tag: {
  30. pattern: /<\/?script\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,
  31. inside: Prism.languages.aspnet.tag.inside
  32. },
  33. rest: Prism.languages.csharp || {}
  34. }
  35. }
  36. });
  37. // Hacks to fix eager tag matching finishing too early: <script src="<% Foo.Bar %>"> => <script src="<% Foo.Bar %>
  38. if ( Prism.languages.aspnet.style ) {
  39. Prism.languages.aspnet.style.inside.tag.pattern = /<\/?style\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i;
  40. Prism.languages.aspnet.style.inside.tag.inside = Prism.languages.aspnet.tag.inside;
  41. }
  42. if ( Prism.languages.aspnet.script ) {
  43. Prism.languages.aspnet.script.inside.tag.pattern = Prism.languages.aspnet['asp script'].inside.tag.pattern;
  44. Prism.languages.aspnet.script.inside.tag.inside = Prism.languages.aspnet.tag.inside;
  45. }