prism-tsx.js 668 B

123456789101112131415
  1. (function (Prism) {
  2. var typescript = Prism.util.clone(Prism.languages.typescript);
  3. Prism.languages.tsx = Prism.languages.extend('jsx', typescript);
  4. // doesn't work with TS because TS is too complex
  5. delete Prism.languages.tsx['parameter'];
  6. delete Prism.languages.tsx['literal-property'];
  7. // This will prevent collisions between TSX tags and TS generic types.
  8. // Idea by https://github.com/karlhorky
  9. // Discussion: https://github.com/PrismJS/prism/issues/2594#issuecomment-710666928
  10. var tag = Prism.languages.tsx.tag;
  11. tag.pattern = RegExp(/(^|[^\w$]|(?=<\/))/.source + '(?:' + tag.pattern.source + ')', tag.pattern.flags);
  12. tag.lookbehind = true;
  13. }(Prism));