eric6/ThirdParty/Pygments/pygments/lexers/templates.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.lexers.templates 3 pygments.lexers.templates
4 ~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for various template engines' markup. 6 Lexers for various template engines' markup.
7 7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
291 aliases = ['html+velocity'] 291 aliases = ['html+velocity']
292 alias_filenames = ['*.html', '*.fhtml'] 292 alias_filenames = ['*.html', '*.fhtml']
293 mimetypes = ['text/html+velocity'] 293 mimetypes = ['text/html+velocity']
294 294
295 def __init__(self, **options): 295 def __init__(self, **options):
296 super(VelocityHtmlLexer, self).__init__(HtmlLexer, VelocityLexer, 296 super().__init__(HtmlLexer, VelocityLexer, **options)
297 **options)
298 297
299 298
300 class VelocityXmlLexer(DelegatingLexer): 299 class VelocityXmlLexer(DelegatingLexer):
301 """ 300 """
302 Subclass of the `VelocityLexer` that highlights unlexed data 301 Subclass of the `VelocityLexer` that highlights unlexed data
308 aliases = ['xml+velocity'] 307 aliases = ['xml+velocity']
309 alias_filenames = ['*.xml', '*.vm'] 308 alias_filenames = ['*.xml', '*.vm']
310 mimetypes = ['application/xml+velocity'] 309 mimetypes = ['application/xml+velocity']
311 310
312 def __init__(self, **options): 311 def __init__(self, **options):
313 super(VelocityXmlLexer, self).__init__(XmlLexer, VelocityLexer, 312 super().__init__(XmlLexer, VelocityLexer, **options)
314 **options)
315 313
316 def analyse_text(text): 314 def analyse_text(text):
317 rv = VelocityLexer.analyse_text(text) - 0.01 315 rv = VelocityLexer.analyse_text(text) - 0.01
318 if looks_like_xml(text): 316 if looks_like_xml(text):
319 rv += 0.4 317 rv += 0.4
462 name = 'HTML+Myghty' 460 name = 'HTML+Myghty'
463 aliases = ['html+myghty'] 461 aliases = ['html+myghty']
464 mimetypes = ['text/html+myghty'] 462 mimetypes = ['text/html+myghty']
465 463
466 def __init__(self, **options): 464 def __init__(self, **options):
467 super(MyghtyHtmlLexer, self).__init__(HtmlLexer, MyghtyLexer, 465 super().__init__(HtmlLexer, MyghtyLexer, **options)
468 **options)
469 466
470 467
471 class MyghtyXmlLexer(DelegatingLexer): 468 class MyghtyXmlLexer(DelegatingLexer):
472 """ 469 """
473 Subclass of the `MyghtyLexer` that highlights unlexed data 470 Subclass of the `MyghtyLexer` that highlights unlexed data
479 name = 'XML+Myghty' 476 name = 'XML+Myghty'
480 aliases = ['xml+myghty'] 477 aliases = ['xml+myghty']
481 mimetypes = ['application/xml+myghty'] 478 mimetypes = ['application/xml+myghty']
482 479
483 def __init__(self, **options): 480 def __init__(self, **options):
484 super(MyghtyXmlLexer, self).__init__(XmlLexer, MyghtyLexer, 481 super().__init__(XmlLexer, MyghtyLexer, **options)
485 **options)
486 482
487 483
488 class MyghtyJavascriptLexer(DelegatingLexer): 484 class MyghtyJavascriptLexer(DelegatingLexer):
489 """ 485 """
490 Subclass of the `MyghtyLexer` that highlights unlexed data 486 Subclass of the `MyghtyLexer` that highlights unlexed data
498 mimetypes = ['application/x-javascript+myghty', 494 mimetypes = ['application/x-javascript+myghty',
499 'text/x-javascript+myghty', 495 'text/x-javascript+myghty',
500 'text/javascript+mygthy'] 496 'text/javascript+mygthy']
501 497
502 def __init__(self, **options): 498 def __init__(self, **options):
503 super(MyghtyJavascriptLexer, self).__init__(JavascriptLexer, 499 super().__init__(JavascriptLexer, MyghtyLexer, **options)
504 MyghtyLexer, **options)
505 500
506 501
507 class MyghtyCssLexer(DelegatingLexer): 502 class MyghtyCssLexer(DelegatingLexer):
508 """ 503 """
509 Subclass of the `MyghtyLexer` that highlights unlexed data 504 Subclass of the `MyghtyLexer` that highlights unlexed data
515 name = 'CSS+Myghty' 510 name = 'CSS+Myghty'
516 aliases = ['css+myghty'] 511 aliases = ['css+myghty']
517 mimetypes = ['text/css+myghty'] 512 mimetypes = ['text/css+myghty']
518 513
519 def __init__(self, **options): 514 def __init__(self, **options):
520 super(MyghtyCssLexer, self).__init__(CssLexer, MyghtyLexer, 515 super().__init__(CssLexer, MyghtyLexer, **options)
521 **options)
522 516
523 517
524 class MasonLexer(RegexLexer): 518 class MasonLexer(RegexLexer):
525 """ 519 """
526 Generic `mason templates`_ lexer. Stolen from Myghty lexer. Code that isn't 520 Generic `mason templates`_ lexer. Stolen from Myghty lexer. Code that isn't
657 name = 'HTML+Mako' 651 name = 'HTML+Mako'
658 aliases = ['html+mako'] 652 aliases = ['html+mako']
659 mimetypes = ['text/html+mako'] 653 mimetypes = ['text/html+mako']
660 654
661 def __init__(self, **options): 655 def __init__(self, **options):
662 super(MakoHtmlLexer, self).__init__(HtmlLexer, MakoLexer, 656 super().__init__(HtmlLexer, MakoLexer, **options)
663 **options)
664 657
665 658
666 class MakoXmlLexer(DelegatingLexer): 659 class MakoXmlLexer(DelegatingLexer):
667 """ 660 """
668 Subclass of the `MakoLexer` that highlights unlexed data 661 Subclass of the `MakoLexer` that highlights unlexed data
674 name = 'XML+Mako' 667 name = 'XML+Mako'
675 aliases = ['xml+mako'] 668 aliases = ['xml+mako']
676 mimetypes = ['application/xml+mako'] 669 mimetypes = ['application/xml+mako']
677 670
678 def __init__(self, **options): 671 def __init__(self, **options):
679 super(MakoXmlLexer, self).__init__(XmlLexer, MakoLexer, 672 super().__init__(XmlLexer, MakoLexer, **options)
680 **options)
681 673
682 674
683 class MakoJavascriptLexer(DelegatingLexer): 675 class MakoJavascriptLexer(DelegatingLexer):
684 """ 676 """
685 Subclass of the `MakoLexer` that highlights unlexed data 677 Subclass of the `MakoLexer` that highlights unlexed data
693 mimetypes = ['application/x-javascript+mako', 685 mimetypes = ['application/x-javascript+mako',
694 'text/x-javascript+mako', 686 'text/x-javascript+mako',
695 'text/javascript+mako'] 687 'text/javascript+mako']
696 688
697 def __init__(self, **options): 689 def __init__(self, **options):
698 super(MakoJavascriptLexer, self).__init__(JavascriptLexer, 690 super().__init__(JavascriptLexer, MakoLexer, **options)
699 MakoLexer, **options)
700 691
701 692
702 class MakoCssLexer(DelegatingLexer): 693 class MakoCssLexer(DelegatingLexer):
703 """ 694 """
704 Subclass of the `MakoLexer` that highlights unlexed data 695 Subclass of the `MakoLexer` that highlights unlexed data
710 name = 'CSS+Mako' 701 name = 'CSS+Mako'
711 aliases = ['css+mako'] 702 aliases = ['css+mako']
712 mimetypes = ['text/css+mako'] 703 mimetypes = ['text/css+mako']
713 704
714 def __init__(self, **options): 705 def __init__(self, **options):
715 super(MakoCssLexer, self).__init__(CssLexer, MakoLexer, 706 super().__init__(CssLexer, MakoLexer, **options)
716 **options)
717 707
718 708
719 # Genshi and Cheetah lexers courtesy of Matt Good. 709 # Genshi and Cheetah lexers courtesy of Matt Good.
720 710
721 class CheetahPythonLexer(Lexer): 711 class CheetahPythonLexer(Lexer):
784 name = 'HTML+Cheetah' 774 name = 'HTML+Cheetah'
785 aliases = ['html+cheetah', 'html+spitfire', 'htmlcheetah'] 775 aliases = ['html+cheetah', 'html+spitfire', 'htmlcheetah']
786 mimetypes = ['text/html+cheetah', 'text/html+spitfire'] 776 mimetypes = ['text/html+cheetah', 'text/html+spitfire']
787 777
788 def __init__(self, **options): 778 def __init__(self, **options):
789 super(CheetahHtmlLexer, self).__init__(HtmlLexer, CheetahLexer, 779 super().__init__(HtmlLexer, CheetahLexer, **options)
790 **options)
791 780
792 781
793 class CheetahXmlLexer(DelegatingLexer): 782 class CheetahXmlLexer(DelegatingLexer):
794 """ 783 """
795 Subclass of the `CheetahLexer` that highlights unlexed data 784 Subclass of the `CheetahLexer` that highlights unlexed data
799 name = 'XML+Cheetah' 788 name = 'XML+Cheetah'
800 aliases = ['xml+cheetah', 'xml+spitfire'] 789 aliases = ['xml+cheetah', 'xml+spitfire']
801 mimetypes = ['application/xml+cheetah', 'application/xml+spitfire'] 790 mimetypes = ['application/xml+cheetah', 'application/xml+spitfire']
802 791
803 def __init__(self, **options): 792 def __init__(self, **options):
804 super(CheetahXmlLexer, self).__init__(XmlLexer, CheetahLexer, 793 super().__init__(XmlLexer, CheetahLexer, **options)
805 **options)
806 794
807 795
808 class CheetahJavascriptLexer(DelegatingLexer): 796 class CheetahJavascriptLexer(DelegatingLexer):
809 """ 797 """
810 Subclass of the `CheetahLexer` that highlights unlexed data 798 Subclass of the `CheetahLexer` that highlights unlexed data
820 'application/x-javascript+spitfire', 808 'application/x-javascript+spitfire',
821 'text/x-javascript+spitfire', 809 'text/x-javascript+spitfire',
822 'text/javascript+spitfire'] 810 'text/javascript+spitfire']
823 811
824 def __init__(self, **options): 812 def __init__(self, **options):
825 super(CheetahJavascriptLexer, self).__init__(JavascriptLexer, 813 super().__init__(JavascriptLexer, CheetahLexer, **options)
826 CheetahLexer, **options)
827 814
828 815
829 class GenshiTextLexer(RegexLexer): 816 class GenshiTextLexer(RegexLexer):
830 """ 817 """
831 A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ text 818 A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ text
935 aliases = ['html+genshi', 'html+kid'] 922 aliases = ['html+genshi', 'html+kid']
936 alias_filenames = ['*.html', '*.htm', '*.xhtml'] 923 alias_filenames = ['*.html', '*.htm', '*.xhtml']
937 mimetypes = ['text/html+genshi'] 924 mimetypes = ['text/html+genshi']
938 925
939 def __init__(self, **options): 926 def __init__(self, **options):
940 super(HtmlGenshiLexer, self).__init__(HtmlLexer, GenshiMarkupLexer, 927 super().__init__(HtmlLexer, GenshiMarkupLexer, **options)
941 **options)
942 928
943 def analyse_text(text): 929 def analyse_text(text):
944 rv = 0.0 930 rv = 0.0
945 if re.search(r'\$\{.*?\}', text) is not None: 931 if re.search(r'\$\{.*?\}', text) is not None:
946 rv += 0.2 932 rv += 0.2
960 filenames = ['*.kid'] 946 filenames = ['*.kid']
961 alias_filenames = ['*.xml'] 947 alias_filenames = ['*.xml']
962 mimetypes = ['application/x-genshi', 'application/x-kid'] 948 mimetypes = ['application/x-genshi', 'application/x-kid']
963 949
964 def __init__(self, **options): 950 def __init__(self, **options):
965 super(GenshiLexer, self).__init__(XmlLexer, GenshiMarkupLexer, 951 super().__init__(XmlLexer, GenshiMarkupLexer, **options)
966 **options)
967 952
968 def analyse_text(text): 953 def analyse_text(text):
969 rv = 0.0 954 rv = 0.0
970 if re.search(r'\$\{.*?\}', text) is not None: 955 if re.search(r'\$\{.*?\}', text) is not None:
971 rv += 0.2 956 rv += 0.2
986 mimetypes = ['application/x-javascript+genshi', 971 mimetypes = ['application/x-javascript+genshi',
987 'text/x-javascript+genshi', 972 'text/x-javascript+genshi',
988 'text/javascript+genshi'] 973 'text/javascript+genshi']
989 974
990 def __init__(self, **options): 975 def __init__(self, **options):
991 super(JavascriptGenshiLexer, self).__init__(JavascriptLexer, 976 super().__init__(JavascriptLexer, GenshiTextLexer, **options)
992 GenshiTextLexer,
993 **options)
994 977
995 def analyse_text(text): 978 def analyse_text(text):
996 return GenshiLexer.analyse_text(text) - 0.05 979 return GenshiLexer.analyse_text(text) - 0.05
997 980
998 981
1005 aliases = ['css+genshitext', 'css+genshi'] 988 aliases = ['css+genshitext', 'css+genshi']
1006 alias_filenames = ['*.css'] 989 alias_filenames = ['*.css']
1007 mimetypes = ['text/css+genshi'] 990 mimetypes = ['text/css+genshi']
1008 991
1009 def __init__(self, **options): 992 def __init__(self, **options):
1010 super(CssGenshiLexer, self).__init__(CssLexer, GenshiTextLexer, 993 super().__init__(CssLexer, GenshiTextLexer, **options)
1011 **options)
1012 994
1013 def analyse_text(text): 995 def analyse_text(text):
1014 return GenshiLexer.analyse_text(text) - 0.05 996 return GenshiLexer.analyse_text(text) - 0.05
1015 997
1016 998
1027 filenames = ['*.rhtml'] 1009 filenames = ['*.rhtml']
1028 alias_filenames = ['*.html', '*.htm', '*.xhtml'] 1010 alias_filenames = ['*.html', '*.htm', '*.xhtml']
1029 mimetypes = ['text/html+ruby'] 1011 mimetypes = ['text/html+ruby']
1030 1012
1031 def __init__(self, **options): 1013 def __init__(self, **options):
1032 super(RhtmlLexer, self).__init__(HtmlLexer, ErbLexer, **options) 1014 super().__init__(HtmlLexer, ErbLexer, **options)
1033 1015
1034 def analyse_text(text): 1016 def analyse_text(text):
1035 rv = ErbLexer.analyse_text(text) - 0.01 1017 rv = ErbLexer.analyse_text(text) - 0.01
1036 if html_doctype_matches(text): 1018 if html_doctype_matches(text):
1037 # one more than the XmlErbLexer returns 1019 # one more than the XmlErbLexer returns
1049 aliases = ['xml+erb', 'xml+ruby'] 1031 aliases = ['xml+erb', 'xml+ruby']
1050 alias_filenames = ['*.xml'] 1032 alias_filenames = ['*.xml']
1051 mimetypes = ['application/xml+ruby'] 1033 mimetypes = ['application/xml+ruby']
1052 1034
1053 def __init__(self, **options): 1035 def __init__(self, **options):
1054 super(XmlErbLexer, self).__init__(XmlLexer, ErbLexer, **options) 1036 super().__init__(XmlLexer, ErbLexer, **options)
1055 1037
1056 def analyse_text(text): 1038 def analyse_text(text):
1057 rv = ErbLexer.analyse_text(text) - 0.01 1039 rv = ErbLexer.analyse_text(text) - 0.01
1058 if looks_like_xml(text): 1040 if looks_like_xml(text):
1059 rv += 0.4 1041 rv += 0.4
1069 aliases = ['css+erb', 'css+ruby'] 1051 aliases = ['css+erb', 'css+ruby']
1070 alias_filenames = ['*.css'] 1052 alias_filenames = ['*.css']
1071 mimetypes = ['text/css+ruby'] 1053 mimetypes = ['text/css+ruby']
1072 1054
1073 def __init__(self, **options): 1055 def __init__(self, **options):
1074 super(CssErbLexer, self).__init__(CssLexer, ErbLexer, **options) 1056 super().__init__(CssLexer, ErbLexer, **options)
1075 1057
1076 def analyse_text(text): 1058 def analyse_text(text):
1077 return ErbLexer.analyse_text(text) - 0.05 1059 return ErbLexer.analyse_text(text) - 0.05
1078 1060
1079 1061
1089 mimetypes = ['application/x-javascript+ruby', 1071 mimetypes = ['application/x-javascript+ruby',
1090 'text/x-javascript+ruby', 1072 'text/x-javascript+ruby',
1091 'text/javascript+ruby'] 1073 'text/javascript+ruby']
1092 1074
1093 def __init__(self, **options): 1075 def __init__(self, **options):
1094 super(JavascriptErbLexer, self).__init__(JavascriptLexer, ErbLexer, 1076 super().__init__(JavascriptLexer, ErbLexer, **options)
1095 **options)
1096 1077
1097 def analyse_text(text): 1078 def analyse_text(text):
1098 return ErbLexer.analyse_text(text) - 0.05 1079 return ErbLexer.analyse_text(text) - 0.05
1099 1080
1100 1081
1113 mimetypes = ['application/x-php', 1094 mimetypes = ['application/x-php',
1114 'application/x-httpd-php', 'application/x-httpd-php3', 1095 'application/x-httpd-php', 'application/x-httpd-php3',
1115 'application/x-httpd-php4', 'application/x-httpd-php5'] 1096 'application/x-httpd-php4', 'application/x-httpd-php5']
1116 1097
1117 def __init__(self, **options): 1098 def __init__(self, **options):
1118 super(HtmlPhpLexer, self).__init__(HtmlLexer, PhpLexer, **options) 1099 super().__init__(HtmlLexer, PhpLexer, **options)
1119 1100
1120 def analyse_text(text): 1101 def analyse_text(text):
1121 rv = PhpLexer.analyse_text(text) - 0.01 1102 rv = PhpLexer.analyse_text(text) - 0.01
1122 if html_doctype_matches(text): 1103 if html_doctype_matches(text):
1123 rv += 0.5 1104 rv += 0.5
1133 aliases = ['xml+php'] 1114 aliases = ['xml+php']
1134 alias_filenames = ['*.xml', '*.php', '*.php[345]'] 1115 alias_filenames = ['*.xml', '*.php', '*.php[345]']
1135 mimetypes = ['application/xml+php'] 1116 mimetypes = ['application/xml+php']
1136 1117
1137 def __init__(self, **options): 1118 def __init__(self, **options):
1138 super(XmlPhpLexer, self).__init__(XmlLexer, PhpLexer, **options) 1119 super().__init__(XmlLexer, PhpLexer, **options)
1139 1120
1140 def analyse_text(text): 1121 def analyse_text(text):
1141 rv = PhpLexer.analyse_text(text) - 0.01 1122 rv = PhpLexer.analyse_text(text) - 0.01
1142 if looks_like_xml(text): 1123 if looks_like_xml(text):
1143 rv += 0.4 1124 rv += 0.4
1153 aliases = ['css+php'] 1134 aliases = ['css+php']
1154 alias_filenames = ['*.css'] 1135 alias_filenames = ['*.css']
1155 mimetypes = ['text/css+php'] 1136 mimetypes = ['text/css+php']
1156 1137
1157 def __init__(self, **options): 1138 def __init__(self, **options):
1158 super(CssPhpLexer, self).__init__(CssLexer, PhpLexer, **options) 1139 super().__init__(CssLexer, PhpLexer, **options)
1159 1140
1160 def analyse_text(text): 1141 def analyse_text(text):
1161 return PhpLexer.analyse_text(text) - 0.05 1142 return PhpLexer.analyse_text(text) - 0.05
1162 1143
1163 1144
1173 mimetypes = ['application/x-javascript+php', 1154 mimetypes = ['application/x-javascript+php',
1174 'text/x-javascript+php', 1155 'text/x-javascript+php',
1175 'text/javascript+php'] 1156 'text/javascript+php']
1176 1157
1177 def __init__(self, **options): 1158 def __init__(self, **options):
1178 super(JavascriptPhpLexer, self).__init__(JavascriptLexer, PhpLexer, 1159 super().__init__(JavascriptLexer, PhpLexer, **options)
1179 **options)
1180 1160
1181 def analyse_text(text): 1161 def analyse_text(text):
1182 return PhpLexer.analyse_text(text) 1162 return PhpLexer.analyse_text(text)
1183 1163
1184 1164
1194 aliases = ['html+smarty'] 1174 aliases = ['html+smarty']
1195 alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.tpl'] 1175 alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.tpl']
1196 mimetypes = ['text/html+smarty'] 1176 mimetypes = ['text/html+smarty']
1197 1177
1198 def __init__(self, **options): 1178 def __init__(self, **options):
1199 super(HtmlSmartyLexer, self).__init__(HtmlLexer, SmartyLexer, **options) 1179 super().__init__(HtmlLexer, SmartyLexer, **options)
1200 1180
1201 def analyse_text(text): 1181 def analyse_text(text):
1202 rv = SmartyLexer.analyse_text(text) - 0.01 1182 rv = SmartyLexer.analyse_text(text) - 0.01
1203 if html_doctype_matches(text): 1183 if html_doctype_matches(text):
1204 rv += 0.5 1184 rv += 0.5
1215 aliases = ['xml+smarty'] 1195 aliases = ['xml+smarty']
1216 alias_filenames = ['*.xml', '*.tpl'] 1196 alias_filenames = ['*.xml', '*.tpl']
1217 mimetypes = ['application/xml+smarty'] 1197 mimetypes = ['application/xml+smarty']
1218 1198
1219 def __init__(self, **options): 1199 def __init__(self, **options):
1220 super(XmlSmartyLexer, self).__init__(XmlLexer, SmartyLexer, **options) 1200 super().__init__(XmlLexer, SmartyLexer, **options)
1221 1201
1222 def analyse_text(text): 1202 def analyse_text(text):
1223 rv = SmartyLexer.analyse_text(text) - 0.01 1203 rv = SmartyLexer.analyse_text(text) - 0.01
1224 if looks_like_xml(text): 1204 if looks_like_xml(text):
1225 rv += 0.4 1205 rv += 0.4
1236 aliases = ['css+smarty'] 1216 aliases = ['css+smarty']
1237 alias_filenames = ['*.css', '*.tpl'] 1217 alias_filenames = ['*.css', '*.tpl']
1238 mimetypes = ['text/css+smarty'] 1218 mimetypes = ['text/css+smarty']
1239 1219
1240 def __init__(self, **options): 1220 def __init__(self, **options):
1241 super(CssSmartyLexer, self).__init__(CssLexer, SmartyLexer, **options) 1221 super().__init__(CssLexer, SmartyLexer, **options)
1242 1222
1243 def analyse_text(text): 1223 def analyse_text(text):
1244 return SmartyLexer.analyse_text(text) - 0.05 1224 return SmartyLexer.analyse_text(text) - 0.05
1245 1225
1246 1226
1256 mimetypes = ['application/x-javascript+smarty', 1236 mimetypes = ['application/x-javascript+smarty',
1257 'text/x-javascript+smarty', 1237 'text/x-javascript+smarty',
1258 'text/javascript+smarty'] 1238 'text/javascript+smarty']
1259 1239
1260 def __init__(self, **options): 1240 def __init__(self, **options):
1261 super(JavascriptSmartyLexer, self).__init__(JavascriptLexer, SmartyLexer, 1241 super().__init__(JavascriptLexer, SmartyLexer, **options)
1262 **options)
1263 1242
1264 def analyse_text(text): 1243 def analyse_text(text):
1265 return SmartyLexer.analyse_text(text) - 0.05 1244 return SmartyLexer.analyse_text(text) - 0.05
1266 1245
1267 1246
1277 aliases = ['html+django', 'html+jinja', 'htmldjango'] 1256 aliases = ['html+django', 'html+jinja', 'htmldjango']
1278 alias_filenames = ['*.html', '*.htm', '*.xhtml'] 1257 alias_filenames = ['*.html', '*.htm', '*.xhtml']
1279 mimetypes = ['text/html+django', 'text/html+jinja'] 1258 mimetypes = ['text/html+django', 'text/html+jinja']
1280 1259
1281 def __init__(self, **options): 1260 def __init__(self, **options):
1282 super(HtmlDjangoLexer, self).__init__(HtmlLexer, DjangoLexer, **options) 1261 super().__init__(HtmlLexer, DjangoLexer, **options)
1283 1262
1284 def analyse_text(text): 1263 def analyse_text(text):
1285 rv = DjangoLexer.analyse_text(text) - 0.01 1264 rv = DjangoLexer.analyse_text(text) - 0.01
1286 if html_doctype_matches(text): 1265 if html_doctype_matches(text):
1287 rv += 0.5 1266 rv += 0.5
1298 aliases = ['xml+django', 'xml+jinja'] 1277 aliases = ['xml+django', 'xml+jinja']
1299 alias_filenames = ['*.xml'] 1278 alias_filenames = ['*.xml']
1300 mimetypes = ['application/xml+django', 'application/xml+jinja'] 1279 mimetypes = ['application/xml+django', 'application/xml+jinja']
1301 1280
1302 def __init__(self, **options): 1281 def __init__(self, **options):
1303 super(XmlDjangoLexer, self).__init__(XmlLexer, DjangoLexer, **options) 1282 super().__init__(XmlLexer, DjangoLexer, **options)
1304 1283
1305 def analyse_text(text): 1284 def analyse_text(text):
1306 rv = DjangoLexer.analyse_text(text) - 0.01 1285 rv = DjangoLexer.analyse_text(text) - 0.01
1307 if looks_like_xml(text): 1286 if looks_like_xml(text):
1308 rv += 0.4 1287 rv += 0.4
1319 aliases = ['css+django', 'css+jinja'] 1298 aliases = ['css+django', 'css+jinja']
1320 alias_filenames = ['*.css'] 1299 alias_filenames = ['*.css']
1321 mimetypes = ['text/css+django', 'text/css+jinja'] 1300 mimetypes = ['text/css+django', 'text/css+jinja']
1322 1301
1323 def __init__(self, **options): 1302 def __init__(self, **options):
1324 super(CssDjangoLexer, self).__init__(CssLexer, DjangoLexer, **options) 1303 super().__init__(CssLexer, DjangoLexer, **options)
1325 1304
1326 def analyse_text(text): 1305 def analyse_text(text):
1327 return DjangoLexer.analyse_text(text) - 0.05 1306 return DjangoLexer.analyse_text(text) - 0.05
1328 1307
1329 1308
1343 'text/x-javascript+jinja', 1322 'text/x-javascript+jinja',
1344 'text/javascript+django', 1323 'text/javascript+django',
1345 'text/javascript+jinja'] 1324 'text/javascript+jinja']
1346 1325
1347 def __init__(self, **options): 1326 def __init__(self, **options):
1348 super(JavascriptDjangoLexer, self).__init__(JavascriptLexer, DjangoLexer, 1327 super().__init__(JavascriptLexer, DjangoLexer, **options)
1349 **options)
1350 1328
1351 def analyse_text(text): 1329 def analyse_text(text):
1352 return DjangoLexer.analyse_text(text) - 0.05 1330 return DjangoLexer.analyse_text(text) - 0.05
1353 1331
1354 1332
1387 aliases = ['jsp'] 1365 aliases = ['jsp']
1388 filenames = ['*.jsp'] 1366 filenames = ['*.jsp']
1389 mimetypes = ['application/x-jsp'] 1367 mimetypes = ['application/x-jsp']
1390 1368
1391 def __init__(self, **options): 1369 def __init__(self, **options):
1392 super(JspLexer, self).__init__(XmlLexer, JspRootLexer, **options) 1370 super().__init__(XmlLexer, JspRootLexer, **options)
1393 1371
1394 def analyse_text(text): 1372 def analyse_text(text):
1395 rv = JavaLexer.analyse_text(text) - 0.01 1373 rv = JavaLexer.analyse_text(text) - 0.01
1396 if looks_like_xml(text): 1374 if looks_like_xml(text):
1397 rv += 0.4 1375 rv += 0.4
1464 aliases = ['html+evoque'] 1442 aliases = ['html+evoque']
1465 filenames = ['*.html'] 1443 filenames = ['*.html']
1466 mimetypes = ['text/html+evoque'] 1444 mimetypes = ['text/html+evoque']
1467 1445
1468 def __init__(self, **options): 1446 def __init__(self, **options):
1469 super(EvoqueHtmlLexer, self).__init__(HtmlLexer, EvoqueLexer, 1447 super().__init__(HtmlLexer, EvoqueLexer, **options)
1470 **options)
1471 1448
1472 1449
1473 class EvoqueXmlLexer(DelegatingLexer): 1450 class EvoqueXmlLexer(DelegatingLexer):
1474 """ 1451 """
1475 Subclass of the `EvoqueLexer` that highlights unlexed data with the 1452 Subclass of the `EvoqueLexer` that highlights unlexed data with the
1481 aliases = ['xml+evoque'] 1458 aliases = ['xml+evoque']
1482 filenames = ['*.xml'] 1459 filenames = ['*.xml']
1483 mimetypes = ['application/xml+evoque'] 1460 mimetypes = ['application/xml+evoque']
1484 1461
1485 def __init__(self, **options): 1462 def __init__(self, **options):
1486 super(EvoqueXmlLexer, self).__init__(XmlLexer, EvoqueLexer, 1463 super().__init__(XmlLexer, EvoqueLexer, **options)
1487 **options)
1488 1464
1489 1465
1490 class ColdfusionLexer(RegexLexer): 1466 class ColdfusionLexer(RegexLexer):
1491 """ 1467 """
1492 Coldfusion statements 1468 Coldfusion statements
1589 aliases = ['cfm'] 1565 aliases = ['cfm']
1590 filenames = ['*.cfm', '*.cfml'] 1566 filenames = ['*.cfm', '*.cfml']
1591 mimetypes = ['application/x-coldfusion'] 1567 mimetypes = ['application/x-coldfusion']
1592 1568
1593 def __init__(self, **options): 1569 def __init__(self, **options):
1594 super(ColdfusionHtmlLexer, self).__init__(HtmlLexer, ColdfusionMarkupLexer, 1570 super().__init__(HtmlLexer, ColdfusionMarkupLexer, **options)
1595 **options)
1596 1571
1597 1572
1598 class ColdfusionCFCLexer(DelegatingLexer): 1573 class ColdfusionCFCLexer(DelegatingLexer):
1599 """ 1574 """
1600 Coldfusion markup/script components 1575 Coldfusion markup/script components
1605 aliases = ['cfc'] 1580 aliases = ['cfc']
1606 filenames = ['*.cfc'] 1581 filenames = ['*.cfc']
1607 mimetypes = [] 1582 mimetypes = []
1608 1583
1609 def __init__(self, **options): 1584 def __init__(self, **options):
1610 super(ColdfusionCFCLexer, self).__init__(ColdfusionHtmlLexer, ColdfusionLexer, 1585 super().__init__(ColdfusionHtmlLexer, ColdfusionLexer, **options)
1611 **options)
1612 1586
1613 1587
1614 class SspLexer(DelegatingLexer): 1588 class SspLexer(DelegatingLexer):
1615 """ 1589 """
1616 Lexer for Scalate Server Pages. 1590 Lexer for Scalate Server Pages.
1621 aliases = ['ssp'] 1595 aliases = ['ssp']
1622 filenames = ['*.ssp'] 1596 filenames = ['*.ssp']
1623 mimetypes = ['application/x-ssp'] 1597 mimetypes = ['application/x-ssp']
1624 1598
1625 def __init__(self, **options): 1599 def __init__(self, **options):
1626 super(SspLexer, self).__init__(XmlLexer, JspRootLexer, **options) 1600 super().__init__(XmlLexer, JspRootLexer, **options)
1627 1601
1628 def analyse_text(text): 1602 def analyse_text(text):
1629 rv = 0.0 1603 rv = 0.0
1630 if re.search(r'val \w+\s*:', text): 1604 if re.search(r'val \w+\s*:', text):
1631 rv += 0.6 1605 rv += 0.6
1668 aliases = ['tea'] 1642 aliases = ['tea']
1669 filenames = ['*.tea'] 1643 filenames = ['*.tea']
1670 mimetypes = ['text/x-tea'] 1644 mimetypes = ['text/x-tea']
1671 1645
1672 def __init__(self, **options): 1646 def __init__(self, **options):
1673 super(TeaTemplateLexer, self).__init__(XmlLexer, 1647 super().__init__(XmlLexer, TeaTemplateRootLexer, **options)
1674 TeaTemplateRootLexer, **options)
1675 1648
1676 def analyse_text(text): 1649 def analyse_text(text):
1677 rv = TeaLangLexer.analyse_text(text) - 0.01 1650 rv = TeaLangLexer.analyse_text(text) - 0.01
1678 if looks_like_xml(text): 1651 if looks_like_xml(text):
1679 rv += 0.4 1652 rv += 0.4
1699 mimetypes = ['text/html+lasso', 1672 mimetypes = ['text/html+lasso',
1700 'application/x-httpd-lasso', 1673 'application/x-httpd-lasso',
1701 'application/x-httpd-lasso[89]'] 1674 'application/x-httpd-lasso[89]']
1702 1675
1703 def __init__(self, **options): 1676 def __init__(self, **options):
1704 super(LassoHtmlLexer, self).__init__(HtmlLexer, LassoLexer, **options) 1677 super().__init__(HtmlLexer, LassoLexer, **options)
1705 1678
1706 def analyse_text(text): 1679 def analyse_text(text):
1707 rv = LassoLexer.analyse_text(text) - 0.01 1680 rv = LassoLexer.analyse_text(text) - 0.01
1708 if html_doctype_matches(text): # same as HTML lexer 1681 if html_doctype_matches(text): # same as HTML lexer
1709 rv += 0.5 1682 rv += 0.5
1723 alias_filenames = ['*.xml', '*.lasso', '*.lasso[89]', 1696 alias_filenames = ['*.xml', '*.lasso', '*.lasso[89]',
1724 '*.incl', '*.inc', '*.las'] 1697 '*.incl', '*.inc', '*.las']
1725 mimetypes = ['application/xml+lasso'] 1698 mimetypes = ['application/xml+lasso']
1726 1699
1727 def __init__(self, **options): 1700 def __init__(self, **options):
1728 super(LassoXmlLexer, self).__init__(XmlLexer, LassoLexer, **options) 1701 super().__init__(XmlLexer, LassoLexer, **options)
1729 1702
1730 def analyse_text(text): 1703 def analyse_text(text):
1731 rv = LassoLexer.analyse_text(text) - 0.01 1704 rv = LassoLexer.analyse_text(text) - 0.01
1732 if looks_like_xml(text): 1705 if looks_like_xml(text):
1733 rv += 0.4 1706 rv += 0.4
1747 alias_filenames = ['*.css'] 1720 alias_filenames = ['*.css']
1748 mimetypes = ['text/css+lasso'] 1721 mimetypes = ['text/css+lasso']
1749 1722
1750 def __init__(self, **options): 1723 def __init__(self, **options):
1751 options['requiredelimiters'] = True 1724 options['requiredelimiters'] = True
1752 super(LassoCssLexer, self).__init__(CssLexer, LassoLexer, **options) 1725 super().__init__(CssLexer, LassoLexer, **options)
1753 1726
1754 def analyse_text(text): 1727 def analyse_text(text):
1755 rv = LassoLexer.analyse_text(text) - 0.05 1728 rv = LassoLexer.analyse_text(text) - 0.05
1756 if re.search(r'\w+:.+?;', text): 1729 if re.search(r'\w+:.+?;', text):
1757 rv += 0.1 1730 rv += 0.1
1775 'text/x-javascript+lasso', 1748 'text/x-javascript+lasso',
1776 'text/javascript+lasso'] 1749 'text/javascript+lasso']
1777 1750
1778 def __init__(self, **options): 1751 def __init__(self, **options):
1779 options['requiredelimiters'] = True 1752 options['requiredelimiters'] = True
1780 super(LassoJavascriptLexer, self).__init__(JavascriptLexer, LassoLexer, 1753 super().__init__(JavascriptLexer, LassoLexer, **options)
1781 **options)
1782 1754
1783 def analyse_text(text): 1755 def analyse_text(text):
1784 rv = LassoLexer.analyse_text(text) - 0.05 1756 rv = LassoLexer.analyse_text(text) - 0.05
1785 return rv 1757 return rv
1786 1758
1873 aliases = ["html+handlebars"] 1845 aliases = ["html+handlebars"]
1874 filenames = ['*.handlebars', '*.hbs'] 1846 filenames = ['*.handlebars', '*.hbs']
1875 mimetypes = ['text/html+handlebars', 'text/x-handlebars-template'] 1847 mimetypes = ['text/html+handlebars', 'text/x-handlebars-template']
1876 1848
1877 def __init__(self, **options): 1849 def __init__(self, **options):
1878 super(HandlebarsHtmlLexer, self).__init__(HtmlLexer, HandlebarsLexer, **options) 1850 super().__init__(HtmlLexer, HandlebarsLexer, **options)
1879 1851
1880 1852
1881 class YamlJinjaLexer(DelegatingLexer): 1853 class YamlJinjaLexer(DelegatingLexer):
1882 """ 1854 """
1883 Subclass of the `DjangoLexer` that highlights unlexed data with the 1855 Subclass of the `DjangoLexer` that highlights unlexed data with the
1892 aliases = ['yaml+jinja', 'salt', 'sls'] 1864 aliases = ['yaml+jinja', 'salt', 'sls']
1893 filenames = ['*.sls'] 1865 filenames = ['*.sls']
1894 mimetypes = ['text/x-yaml+jinja', 'text/x-sls'] 1866 mimetypes = ['text/x-yaml+jinja', 'text/x-sls']
1895 1867
1896 def __init__(self, **options): 1868 def __init__(self, **options):
1897 super(YamlJinjaLexer, self).__init__(YamlLexer, DjangoLexer, **options) 1869 super().__init__(YamlLexer, DjangoLexer, **options)
1898 1870
1899 1871
1900 class LiquidLexer(RegexLexer): 1872 class LiquidLexer(RegexLexer):
1901 """ 1873 """
1902 Lexer for `Liquid templates 1874 Lexer for `Liquid templates
2198 aliases = ["html+twig"] 2170 aliases = ["html+twig"]
2199 filenames = ['*.twig'] 2171 filenames = ['*.twig']
2200 mimetypes = ['text/html+twig'] 2172 mimetypes = ['text/html+twig']
2201 2173
2202 def __init__(self, **options): 2174 def __init__(self, **options):
2203 super(TwigHtmlLexer, self).__init__(HtmlLexer, TwigLexer, **options) 2175 super().__init__(HtmlLexer, TwigLexer, **options)
2204 2176
2205 2177
2206 class Angular2Lexer(RegexLexer): 2178 class Angular2Lexer(RegexLexer):
2207 """ 2179 """
2208 Generic 2180 Generic
2233 (r'([([]+)([\w:.-]+)([\])]+)(\s*)', 2205 (r'([([]+)([\w:.-]+)([\])]+)(\s*)',
2234 bygroups(Punctuation, Name.Attribute, Punctuation, Text)), 2206 bygroups(Punctuation, Name.Attribute, Punctuation, Text)),
2235 2207
2236 # *ngIf="..."; #f="ngForm" 2208 # *ngIf="..."; #f="ngForm"
2237 (r'([*#])([\w:.-]+)(\s*)(=)(\s*)', 2209 (r'([*#])([\w:.-]+)(\s*)(=)(\s*)',
2238 bygroups(Punctuation, Name.Attribute, Punctuation, Operator), 'attr'), 2210 bygroups(Punctuation, Name.Attribute, Text, Operator, Text), 'attr'),
2239 (r'([*#])([\w:.-]+)(\s*)', 2211 (r'([*#])([\w:.-]+)(\s*)',
2240 bygroups(Punctuation, Name.Attribute, Punctuation)), 2212 bygroups(Punctuation, Name.Attribute, Text)),
2241 ], 2213 ],
2242 2214
2243 'ngExpression': [ 2215 'ngExpression': [
2244 (r'\s+(\|\s+)?', Text), 2216 (r'\s+(\|\s+)?', Text),
2245 (r'\}\}', Comment.Preproc, '#pop'), 2217 (r'\}\}', Comment.Preproc, '#pop'),
2278 name = "HTML + Angular2" 2250 name = "HTML + Angular2"
2279 aliases = ["html+ng2"] 2251 aliases = ["html+ng2"]
2280 filenames = ['*.ng2'] 2252 filenames = ['*.ng2']
2281 2253
2282 def __init__(self, **options): 2254 def __init__(self, **options):
2283 super(Angular2HtmlLexer, self).__init__(HtmlLexer, Angular2Lexer, **options) 2255 super().__init__(HtmlLexer, Angular2Lexer, **options)

eric ide

mercurial