-
Notifications
You must be signed in to change notification settings - Fork 0
/
web-mode.el
11043 lines (9921 loc) · 379 KB
/
web-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; web-mode.el --- major mode for editing html templates
;;; -*- coding: utf-8 -*-
;; Copyright 2011-2014 François-Xavier Bois
;; Version: 8.0.55
;; Author: François-Xavier Bois <fxbois AT Google Mail Service>
;; Maintainer: François-Xavier Bois
;; Created: July 2011
;; Keywords: html template php javascript js css web
;; django jsp asp erb twig jinja blade dust closure
;; freemarker mustache velocity cheetah smarty
;; URL: http://web-mode.org
;; Repository: http://github.com/fxbois/web-mode
;; =========================================================================
;; This work is sponsored by Kernix : Digital Agency (Web & Mobile) in Paris
;; =========================================================================
;; This file is not part of Emacs
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; Code goes here
;;todo :
;; web-mode-block-code-beginning|end
;; invalidation partiel de block (cf. journal.psp)
;; C-n sur delimiter = on bascule sur open-delim ou close-delim
;; essayer de réduire la zone à scanner / repeindre
;; phphint
;;todo : Stickiness of Text Properties
;;todo : web-mode-engine-real-name (canonical name)
;;todo : finir filling
;;todo : screenshot : http://www.cockos.com/licecap/
;;todo : passer les content-types en symboles
;;todo : tester shortcut A -> pour pomme
(defconst web-mode-version "8.0.55"
"Web Mode version.")
(defgroup web-mode nil
"Major mode for editing web templates:
HTML files embedding parts (CSS/JavaScript)
and blocks (php, erb, django/twig, smarty, jsp, asp, etc.)"
:group 'languages
:prefix "web-"
:link '(url-link :tag "Site" "http://web-mode.org")
:link '(url-link :tag "Repository" "https://github.com/fxbois/web-mode"))
(defgroup web-mode-faces nil
"Faces for syntax highlighting."
:group 'web-mode
:group 'faces)
(defcustom web-mode-script-padding 1
"Script element left padding."
:type 'integer
:group 'web-mode)
(defcustom web-mode-style-padding 1
"Style element left padding."
:type 'integer
:group 'web-mode)
(defcustom web-mode-block-padding 0
"Multi-line block (PHP, Ruby, Java, etc.) left padding."
:type 'integer
:group 'web-mode)
(defcustom web-mode-markup-indent-offset 2
"HTML indentation level."
:type 'integer
:group 'web-mode)
(defcustom web-mode-css-indent-offset 2
"CSS indentation level."
:type 'integer
:group 'web-mode)
(defcustom web-mode-code-indent-offset 2
"Code (JavaScript, PHP, etc.) indentation level."
:type 'integer
:group 'web-mode)
(defcustom web-mode-enable-css-colorization (display-graphic-p)
"In a CSS part, set background according to the color: #xxx, rgb(x,x,x)."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-auto-indentation (display-graphic-p)
"Auto-indentation."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-auto-pairing (display-graphic-p)
"Auto-pairing."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-auto-opening (display-graphic-p)
"Html element auto-opening."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-indent-cycle nil
"Disable cycle indent."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-indent-cycle-left-first nil
"Indent from left to right instead of starting at rightmost match."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-current-element-highlight nil
"Disable element highlight."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-whitespaces nil
"Enable whitespaces."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-block-face nil
"Enable block face (useful for setting a background for example).
See web-mode-block-face."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-part-face nil
"Enable part face (useful for setting a background for example).
See web-mode-part-face."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-string-interpolation t
"Enable string interpolation fontification (php and erb)."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-heredoc-fontification t
"Enable heredoc fontification. The identifier should contain JS, JAVASCRIPT or HTML."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-comment-keywords nil
"Enable highlight of keywords like FIXME, TODO, etc. in comments."
:type 'list
:group 'web-mode)
(defcustom web-mode-comment-style 1
"Comment style : 1 = default, 2 = force server comments outside a block."
:group 'web-mode
:type '(choice (const :tag "default" 1)
(const :tag "force engine comments" 2)))
(defcustom web-mode-indent-style 2
"Indentation style."
:group 'web-mode
:type '(choice (const :tag "default (all lines are indented)" 2)
(const :tag "text at the beginning of line is not indented" 1)))
(defcustom web-mode-tag-auto-close-style 1
"Tag auto-close style:
0=no auto-closing
1=auto-close with </
2=auto-close with > and </."
:type 'integer
:group 'web-mode)
(defcustom web-mode-extra-auto-pairs '()
"A list of additional snippets."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-snippets '()
"A list of additional snippets."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-python-constants '()
"A list of additional strings to treat as Python constants."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-php-constants '()
"A list of additional strings to treat as PHP constants."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-php-keywords '()
"A list of additional strings to treat as PHP keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-jsp-keywords '()
"A list of additional strings to treat as JSP keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-python-keywords '()
"A list of additional strings to treat as Python keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-erb-keywords '()
"A list of additional strings to treat as ERB keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-mason-keywords '()
"A list of additional strings to treat as Mason keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-asp-constants '()
"A list of additional strings to treat as ASP constants."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-asp-keywords '()
"A list of additional strings to treat as ASP keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-asp-types '()
"A list of additional strings to treat as ASP types."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-aspx-keywords '()
"A list of additional strings to treat as ASPX keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-javascript-keywords '()
"A list of additional strings to treat as JS keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-razor-keywords '()
"A list of additional strings to treat as Razor keywords."
:type 'list
:group 'web-mode)
(defcustom web-mode-extra-comment-keywords '()
"A list of additional strings to treat as comment keywords."
:type 'list
:group 'web-mode)
(defface web-mode-error-face
'((t :background "red"))
"Face for warning."
:group 'web-mode-faces)
(defface web-mode-warning-face
'((t :inherit font-lock-warning-face))
"Face for warning."
:group 'web-mode-faces)
(defface web-mode-preprocessor-face
'((t :inherit font-lock-preprocessor-face))
"Face for preprocessor."
:group 'web-mode-faces)
(defface web-mode-block-delimiter-face
'((t :inherit font-lock-preprocessor-face))
"Face for block delimiters."
:group 'web-mode-faces)
(defface web-mode-block-control-face
'((t :inherit font-lock-preprocessor-face))
"Face for preprocessor."
:group 'web-mode-faces)
(defface web-mode-builtin-face
'((t :inherit font-lock-builtin-face))
"Face for builtins."
:group 'web-mode-faces)
(defface web-mode-symbol-face
'((t :foreground "gold"))
"Face for symbols."
:group 'web-mode-faces)
(defface web-mode-doctype-face
'((t :foreground "Grey"))
"Face for HTML doctype."
:group 'web-mode-faces)
(defface web-mode-html-tag-face
'((((class color) (min-colors 88) (background dark)) :foreground "Snow4")
(((class color) (min-colors 88) (background light)) :foreground "grey15")
(((class color) (min-colors 16) (background dark)) :foreground "Snow4")
(((class color) (min-colors 16) (background light)) :foreground "grey15")
(((class color) (min-colors 8)) :foreground "Snow4")
(((type tty) (class mono)) :inverse-video t)
(t :foreground "Snow4"))
"Face for HTML tags."
:group 'web-mode-faces)
(defface web-mode-html-tag-custom-face
'((t :inherit web-mode-html-tag-face))
"Face for HTML custom tags (e.g. <polymer-element>)."
:group 'web-mode-faces)
(defface web-mode-html-tag-bracket-face
;; '((t :inherit web-mode-html-tag-face))
'((((class color) (min-colors 88) (background dark)) :foreground "Snow3")
(((class color) (min-colors 88) (background light)) :foreground "grey14")
(((class color) (min-colors 16) (background dark)) :foreground "Snow3")
(((class color) (min-colors 16) (background light)) :foreground "grey14")
(((class color) (min-colors 8)) :foreground "Snow3")
(((type tty) (class mono)) :inverse-video t)
(t :foreground "Snow3"))
"Face for HTML tags angle brackets (< and >)."
:group 'web-mode-faces)
(defface web-mode-html-attr-name-face
'((((class color) (min-colors 88) (background dark)) :foreground "Snow3")
(((class color) (min-colors 88) (background light)) :foreground "grey13")
(((class color) (min-colors 16) (background dark)) :foreground "Snow3")
(((class color) (min-colors 16) (background light)) :foreground "grey13")
(((class color) (min-colors 8)) :foreground "Snow3")
(((type tty) (class mono)) :inverse-video t)
(t :foreground "Snow4"))
"Face for HTML attribute names."
:group 'web-mode-faces)
(defface web-mode-html-attr-custom-face
'((t :inherit web-mode-html-attr-name-face))
"Face for custom attribute names (e.g. data-*)."
:group 'web-mode-faces)
(defface web-mode-html-attr-engine-face
'((t :inherit web-mode-html-attr-custom-face))
"Face for custom engine attribute names (e.g. ng-*)."
:group 'web-mode-faces)
(defface web-mode-html-attr-equal-face
'((t :inherit web-mode-html-attr-name-face))
"Face for the = character between name and value."
:group 'web-mode-faces)
(defface web-mode-html-attr-value-face
'((t :inherit font-lock-string-face))
"Face for HTML attribute values."
:group 'web-mode-faces)
(defface web-mode-block-attr-name-face
'((t :foreground "#8fbc8f")) ;; inherit web-mode-html-attr-name-face))
"Face for block attribute names."
:group 'web-mode-faces)
(defface web-mode-block-attr-value-face
'((t :inherit web-mode-html-attr-value-face))
"Face for block attribute values."
:group 'web-mode-faces)
(defface web-mode-css-selector-face
'((t :inherit font-lock-keyword-face))
"Face for CSS rules."
:group 'web-mode-faces)
(defface web-mode-css-pseudo-class-face
'((t :inherit font-lock-builtin-face))
"Face for CSS pseudo-classes."
:group 'web-mode-faces)
(defface web-mode-css-at-rule-face
'((t :inherit font-lock-constant-face))
"Face for CSS at-rules."
:group 'web-mode-faces)
(defface web-mode-css-property-name-face
'((t :inherit font-lock-variable-name-face))
"Face for CSS props."
:group 'web-mode-faces)
(defface web-mode-css-color-face
'((t :inherit font-lock-builtin-face))
"Face for CSS colors (#xxx)."
:group 'web-mode-faces)
(defface web-mode-css-priority-face
'((t :inherit font-lock-builtin-face))
"Face for CSS priority (!important)."
:group 'web-mode-faces)
(defface web-mode-css-function-face
'((t :inherit font-lock-builtin-face))
"Face for CSS functions."
:group 'web-mode-faces)
(defface web-mode-variable-name-face
'((t :inherit font-lock-variable-name-face))
"Face for variable names."
:group 'web-mode-faces)
(defface web-mode-function-name-face
'((t :inherit font-lock-function-name-face))
"Face for function names."
:group 'web-mode-faces)
(defface web-mode-function-call-face
'((t :inherit font-lock-function-name-face))
"Face for function calls."
:group 'web-mode-faces)
(defface web-mode-string-face
'((t :inherit font-lock-string-face))
"Face for strings."
:group 'web-mode-faces)
(defface web-mode-block-string-face
'((t :inherit web-mode-string-face))
"Face for block strings."
:group 'web-mode-faces)
(defface web-mode-part-string-face
'((t :inherit web-mode-string-face))
"Face for part strings."
:group 'web-mode-faces)
(defface web-mode-javascript-string-face
'((t :inherit web-mode-string-face))
"Face for javascript strings."
:group 'web-mode-faces)
(defface web-mode-css-string-face
'((t :inherit web-mode-string-face))
"Face for css strings."
:group 'web-mode-faces)
(defface web-mode-json-key-face
'((t :foreground "plum"))
"Face for json key strings."
:group 'web-mode-faces)
(defface web-mode-json-context-face
'((t :foreground "orchid3"))
"Face for json context strings."
:group 'web-mode-faces)
(defface web-mode-json-string-face
'((t :inherit web-mode-string-face))
"Face for json strings."
:group 'web-mode-faces)
(defface web-mode-comment-face
'((t :inherit font-lock-comment-face))
"Face for comments."
:group 'web-mode-faces)
(defface web-mode-block-comment-face
'((t :inherit web-mode-comment-face))
"Face for server comments."
:group 'web-mode-faces)
(defface web-mode-part-comment-face
'((t :inherit web-mode-comment-face))
"Face for part comments."
:group 'web-mode-faces)
(defface web-mode-json-comment-face
'((t :inherit web-mode-comment-face))
"Face for json comments."
:group 'web-mode-faces)
(defface web-mode-javascript-comment-face
'((t :inherit web-mode-comment-face))
"Face for javascript comments."
:group 'web-mode-faces)
(defface web-mode-css-comment-face
'((t :inherit web-mode-comment-face))
"Face for css comments."
:group 'web-mode-faces)
(defface web-mode-constant-face
'((t :inherit font-lock-constant-face))
"Face for language constants."
:group 'web-mode-faces)
(defface web-mode-type-face
'((t :inherit font-lock-type-face))
"Face for language types."
:group 'web-mode-faces)
(defface web-mode-keyword-face
'((t :inherit font-lock-keyword-face))
"Face for language keywords."
:group 'web-mode-faces)
(defface web-mode-param-name-face
'((t :foreground "Snow3"))
"Face for server attribute names."
:group 'web-mode-faces)
(defface web-mode-whitespace-face
'((t :background "DarkOrchid4"))
"Face for whitespaces."
:group 'web-mode-faces)
(defface web-mode-block-face
'((((class color) (min-colors 88) (background dark))
:background "black") ;""grey18")
(((class color) (min-colors 88) (background light))
:background "LightYellow1")
(((class color) (min-colors 16) (background dark))
:background "grey18")
(((class color) (min-colors 16) (background light))
:background "LightYellow1")
(((class color) (min-colors 8))
:background "Black")
(((type tty) (class mono))
:inverse-video t)
(t :background "grey"))
"Face for blocks (useful for setting a background for example).
Must be used in conjunction with web-mode-enable-block-face."
:group 'web-mode-faces)
(defface web-mode-part-face
'((t :inherit web-mode-block-face))
"Face for parts."
:group 'web-mode-faces)
(defface web-mode-folded-face
'((t :underline t))
"Overlay face for folded."
:group 'web-mode-faces)
(defface web-mode-current-element-highlight-face
'((t :background "#000000"))
"Overlay face for element highlight."
:group 'web-mode-faces)
(defface web-mode-comment-keyword-face
'((t :weight bold :box t))
"Comment keywords."
:group 'web-mode-faces)
(defvar font-lock-beg)
(defvar font-lock-end)
(defvar web-mode-cache '()
"Cache computed values.")
(defvar web-mode-void-elements
'("area" "base" "br" "col" "command" "embed" "hr" "img" "input" "keygen"
"link" "meta" "param" "source" "track" "wbr")
"Void (self-closing) tags.")
(defvar web-mode-scan-properties
(list 'tag-beg nil 'tag-end nil 'tag-name nil 'tag-type nil 'tag-attr nil 'tag-attr-end nil
'part-side nil 'part-token nil 'part-expr nil
'block-side nil 'block-token nil 'block-controls nil 'block-beg nil 'block-end nil
'syntax-table)
;; 'comment nil
"Text properties used for tokens.")
;; (defvar web-mode-scan-properties2
;; (list 'tag-beg nil 'tag-end nil 'tag-name nil 'tag-type nil 'tag-attr nil 'tag-attr-end nil
;; 'part-side nil 'part-token nil 'part-expr nil)
;; "Text properties used for tokens.")
(defvar web-mode-large-embed-threshold 512
"Threshold for large part/block.")
(defvar web-mode-has-any-large-part nil
"Does the current buffer has large parts ?")
(defvar web-mode-has-any-large-block nil
"Does the current buffer has large blocks ?")
(defvar web-mode-is-scratch nil
"Is scratch buffer ?")
(defvar web-mode-time nil
"For benchmarking")
(defvar web-mode-start-tag-overlay nil)
(defvar web-mode-end-tag-overlay nil)
(defvar web-mode-expand-initial-pos nil
"First mark pos.")
(defvar web-mode-expand-previous-state ""
"Last mark state.")
(defvar web-mode-tag-regexp "<\\(/?[[:alpha:]][[:alnum:]-]*\\)"
"Regular expression for HTML/XML tag.")
(defvar web-mode-start-tag-regexp "<\\([[:alpha:]][[:alnum:]-]*\\)"
"Regular expression for HTML/XML start tag.")
(defvar web-mode-whitespaces-regexp
"^[ \t]\\{2,\\}$\\| \t\\|\t \\|[ \t]+$\\|^[ \n\t]+\\'\\|^[ \t]?[\n]\\{2,\\}"
"Regular expression for whitespaces.")
(defvar web-mode-imenu-regexp-list
'(("<\\(h[1-9]\\)\\([^>]*\\)>\\([^<]*\\)" 1 3 ">")
("^[ \t]*<\\([@a-z]+\\)[^>]*>? *$" 1 "id=\"\\([a-zA-Z0-9_]+\\)\"" "#" ">")
)
"List of regular expressions to match imenu items.
Each element of list could be either of two data types,
1. data type one: (regex index-to-extract-type index-to-extract-content concat-string)
1.1. regex => regular express to match the line contain the full tag from each line
1.2. index-to-extract-type => index to extract the tag type, for example, 1 means thing
between the *first* '\\(' '\\)' pair in above regex, the extracted string could be 'div' or 'span' ...
1.3. index-to-extract-content => index to extract to tag content, for example, 3 means the
thing between *third* '\\(' '\\)' pair in above regex.
1.4. concat-string => the string to concat the type and content
2. data type two: (regex index-to-extract-type another-regex-extract-content concat-string end-tag-regex)
Please note this one support multi-line tag.
2.1. regex => regular express to match the line contain the beginning of the tag from each line
2.2. index-to-extract-type => index to extract the tag type, for example, 1 means thing
between the *first* '\\(' '\\)' pair in above regex, the extracted string could be 'div' or 'span' ...
2.3. another-regex-extract-content => regex to extract tag content
The *first* thing between '\\(' '\\)' will be extracted as tag content
2.4. concat-string => the string to concat the type and content
2.5. end-tag-regex => the regex to match the end of a tag
")
(defvar web-mode-engine nil
"Template engine")
(defvar web-mode-engine-font-lock-keywords nil
"Font-lock keywords associated with the engine.")
(defvar web-mode-engines
'(("angular" . ("angular.js" "angularjs"))
("asp" . ())
("aspx" . ())
("blade" . ("laravel"))
("closure" . ("soy"))
("ctemplate" . ("mustache" "handlebars" "hapax" "ngtemplate" "ember"
"kite" "meteor"))
("django" . ("dtl" "twig" "swig" "jinja" "jinja2" "erlydtl" "liquid"))
("dust" . ("dustjs"))
("erb" . ("eruby" "erubis"))
("go" . ("gtl"))
("jsp" . ())
("mason" . ("poet"))
("python" . ())
("razor" . ("play" "play2"))
;; ("react" . ())
("underscore" . ("underscorejs"))
("velocity" . ("vtl" "cheetah"))
("web2py" . ()))
"Engine name aliases")
(defvar web-mode-content-types
'(("css" . "\\.css\\'\\|\\.css\\.erb\\'")
("javascript" . "\\.js\\'\\|\\.js\\.erb\\'")
("json" . "\\.\\(json\\|jsonld\\)\\'")
("jsx" . "\\.jsx\\'")
("html" . "."))
"content types")
(defvar web-mode-engine-attr-regexp nil
"Engine custom attributes"
)
(defvar web-mode-engine-attr-regexps
'(("angular" . "ng-")
)
"Engine custom attributes"
)
(defvar web-mode-engine-file-regexps
'(("asp" . "\\.asp\\'")
("aspx" . "\\.as[cp]x\\'")
("angular" . "angular")
("blade" . "\\.blade")
("closure" . "\\.soy\\'")
("ctemplate" . "\\.\\(chtml\\)\\'")
("django" . "\\.\\(djhtml\\|tmpl\\|dtl\\|liquid\\)\\'")
("django" . "twig")
("dust" . "\\.dust\\'")
("erb" . "\\.\\(erb\\|rhtml\\)\\'")
("freemarker" . "\\.ftl\\'")
("go" . "\\.go\\(html\\|tmpl\\)\\'")
("handlebars" . "\\(handlebars\\|.\\hbs\\'\\)")
("jsp" . "\\.jsp\\'")
("mako" . "\\.mako\\'")
("mason" . "\\.mas\\'")
("mustache" . "\\.mustache\\'")
("php" . "\\.\\(php\\|ctp\\|psp\\|inc\\)\\'")
("python" . "\\.pml\\'")
("razor" . "play\\|scala\\|\\.razor\\'\\|\\.cshtml\\'\\|\\.vbhtml\\'")
;; ("react" . "\\.react")
("smarty" . "\\.tpl\\'")
("template-toolkit" . "\\.tt.?\\'")
("underscore" . "\\.underscore\\'")
("velocity" . "\\.\\(vsl\\|vtl\\|vm\\)\\'")
("web2py" . "web2py"))
"Engine file extensions.")
(defvar web-mode-smart-quotes
'("«" . "»")
"Preferred smart quotes")
(defvar web-mode-xml-chars
'((?\& . "&")
(?\< . "<")
(?\> . ">"))
"XML chars")
(defvar web-mode-html-entities
'(("egrave" . 232)
("eacute" . 233)
("ecirc" . 234)
("euml" . 235)
("agrave" . 224)
("aacute" . 225)
("aelig" . 230)
("ccedil" . 231)
("times" . 215)
("quot" . 34)
("amp" . 38)
("lt" . 60)
("gt" . 62)
("laquo" . 171)
("raquo" . 187)
("lsquo" . 8249)
("rsquo" . 8250)
("ldquo" . 8220)
("rdquo" . 8221)
("lsaquo" . 8249)
("rsaquo" . 8250)
("apos" . 39)
("frac14" . 188)
("frac12" . 189)
("frac34" . 190)
("para" . 182)
("middot" . 183)
("ndash" . 8211)
("mdash" . 8212)
("bull" . 8226)
("hellip" . 8230)
("trade" . 8482)
("larr" . 8592)
("uarr" . 8593)
("rarr" . 8594)
("darr" . 8595)
("harr" . 8596)
("crarr" . 8629)
("and" . 8743)
("or" . 8744)
("sdot" . 8901)
)
"HTML entities")
;;(message "%S" web-mode-engines-alternate-delimiters)
(defvar web-mode-engines-alternate-delimiters
(if (boundp 'web-mode-engines-alternate-delimiters) web-mode-engines-alternate-delimiters '())
"Engine delimiters. Useful for engines that provide alternate delimiters.")
(defun web-mode-highlight-whitespaces (beg end)
"Scan whitespaces."
(save-excursion
(goto-char beg)
(while (re-search-forward web-mode-whitespaces-regexp end t)
(add-text-properties (match-beginning 0) (match-end 0)
'(face web-mode-whitespace-face))
) ;while
))
(defun web-mode-engine-delimiter-open (engine default)
"alternative open delimiter"
;; (setq engine (if (eq engine t) ))
(let (delim)
(setq delim (car (cdr (assoc engine web-mode-engines-alternate-delimiters))))
(or delim default)
))
(defun web-mode-engine-delimiter-close (engine default)
"alternative close delimiter"
;; (setq engine (if (eq engine t) ))
(let (delim)
(setq delim (cdr (cdr (assoc engine web-mode-engines-alternate-delimiters))))
(or delim default)
))
(defvar web-mode-jshint-errors 0
"JSHint errors")
(defvar web-mode-content-type ""
"Buffer file type.")
(defvar web-mode-comments-invisible nil
"Comments visbility.")
(defvar web-mode-is-narrowed nil
"Buffer has been narrowed.")
(defvar web-mode-hook nil
"List of functions to be executed with web-mode.")
(defvar web-mode-buffer-highlighted nil
"Is buffer highlighted.")
;; http://webdesign.about.com/od/localization/l/blhtmlcodes-ascii.htm
(defvar web-mode-display-table
(let ((table (make-display-table)))
(aset table 9 (vector ?\xBB ?\t)) ;tab
(aset table 10 (vector ?\xB6 ?\n)) ;line feed
(aset table 32 (vector ?\xB7))
table)
"Display table.")
(defvar web-mode-hl-line-mode-flag nil
"Is hl-line-mode enabled ?")
(defvar web-mode-django-control-blocks
(regexp-opt
'("assets" "autoescape" "block" "blocktrans" "cache" "call" "comment"
"elif" "else" "elseif" "elsif" "embed" "empty" "filter" "foreach" "for"
"ifchanged" "ifequal" "ifnotequal" "if"
"macro" "draw" "random" "sandbox" "spaceless" "verbatim" "with")
t)
"Django controls.")
(defvar web-mode-auto-pairs nil
"Auto-Pairs")
(defvar web-mode-closing-blocks nil
"Snippets")
(defvar web-mode-engines-closing-blocks
'(
("php" . (("if" . "<?php endif; ?>")
("for" . "<?php endfor; ?>")
("foreach" . "<?php endforeach; ?>")
("while" . "<?php endwhile; ?>")))
)
"Closing blocks (see web-mode-block-close)"
)
(defvar web-mode-engines-auto-pairs
'(
("angular" . (("{{ " " }}")))
("asp" . (("<% " " %>")))
("aspx" . (("<% " " %>")
("<%=" "%>")
("<%#" "%>")
("<%$" "%>")
("<%@" "%>")
("<%:" "%>")
("<%-" "- " " --%>")))
("blade" . (("{{ " " }}")
("{{-" "- " " --}}")))
("django" . (("{{ " " }}")
("{% " " %}")
("{# " " #}")))
("erb" . (("<% " " %>")
("<%=" "%>")
("<%#" "%>")))
("freemarker" . (("<% " " %>")
("${ " " }")
("[% " " %]")
("[# " " #]")
("[#-" "- " " --]")))
("jsp" . (("<% " " %>")
("<%-" "- " " %>")
("<%=" "%>")
("<%!" "%>")
("<%@" "%>")
("${ " " }")))
("mako" . (("<% " " %>")
("<%!" " " " %>")
("${ " " }")))
("mason" . (("<% " " %>")))
("php" . (("<?p" "hp " " ?>")
("<? " " ?>")
("<?=" "?>")))
("underscore" . (("<% " " %>")))
("web2py" . (("{{ " " }}")
("{{=" "}}")))
(nil . (("<!-" "- " " -->")))
)
"Engines auto-pairs")
(defvar web-mode-snippets nil
"Snippets")
(defvar web-mode-engines-snippets
'(("erb" . (("if" . ("<% if " . " %>\n\n<% end %>"))))
("php" . (("if" . ("<?php if (" . "): ?>\n\n<?php endif; ?>"))
("while" . ("<?php while (" . "): ?>\n\n<?php endwhile; ?>"))
("for" . ("<?php for (" . " ; ; ): ?>\n\n<?php endfor; ?>"))
("foreach" . ("<?php foreach (" . " as ): ?>\n\n<?php endforeach; ?>"))
("switch" . ("<?php switch (" . "): ?>\n<?php case 1: ?>\n\n<?php break ;?>\n<?php case 2: ?>\n\n<?php break ;?>\n<?php endswitch;?>"))))
("django" . (("block" . ("{% block " . " %}\n\n{% endblock %}"))
("comment" . ("{% comment " . " %}\n\n{% endcomment %}"))
("cycle" . ("{% cycle " . " as %}\n\n{% endcycle %}"))
("filter" . ("{% filter " . " %}\n\n{% endfilter %}"))
("for" . ("{% for " . " in %}\n\n{% endfor %}"))
("if" . ("{% if " . " %}\n\n{% endif %}"))))
(nil . (("html5" . ("<!doctype html>\n<html>\n<head>\n<title></title>\n<meta charset=\"utf-8\" />\n</head>\n<body>\n" . "\n</body>\n</html>"))
("table" . ("<table><tbody>\n<tr>\n<td>" . "</td>\n<td></td>\n</tr>\n</tbody></table>"))
("ul" . ("<ul>\n<li>" . "</li>\n<li></li>\n</ul>"))))
)
"Engines snippets")
(defvar web-mode-block-regexps
(list
'("angular" . "{{")
'("asp" . "<%")
'("aspx" . "<%")
'("blade" . "{{.\\|^[ \t]*@[[:alpha:]]")
'("closure" . "{.\\|/\\*\\| //")
'("ctemplate" . "[$]?{{.")
'("django" . "{[#{%]")
'("dust" . "{.")
'("erb" . "<%\\|^%.")
'("freemarker" . "<%\\|${\\|</?[[:alpha:]]+:[[:alpha:]]\\|</?[@#].\\|\\[/?[@#].")
'("go" . "{{.")
'("jsp" . "<%\\|${\\|</?[[:alpha:]]+:[[:alpha:]]")
'("mako" . "</?%\\|${\\|^[ \t]*% \\|^[ \t]*##")
;; '("mason" . "</&>\\|</%def\\|</%method\\|<%[[:alpha:]]+\\|<[%&]\\|^%.")
'("mason" . "</?[&%]\\|^%.")
'("php" . "<\\?")
'("python" . "<\\?")
'("razor" . "@.\\|^[ \t]*}")
;; '("react" . "<script type=.?text/jsx.*>")
(cons "smarty" (concat (web-mode-engine-delimiter-open "smarty" "{") "[[:alpha:]#$/*\"]"))
'("template-toolkit" . "\\[[%#]")
'("underscore" . "<%")
'("velocity" . "^[ \t]*#[[:alpha:]#*]\\|$[[:alpha:]!{]")
'("web2py" . "{{")
)
"Engine block regexps.")
(defvar web-mode-block-electric-chars
(list
(cons "blade" '(?\{ ?\@))
(cons "closure" '(?\{ ?\/))
(cons "ctemplate" '(?\{ ?\$))
(cons "django" '(?\{))
(cons "dust" '(?\{))
(cons "erb" '(?\%))
(cons "freemarker" '(?\[))
(cons "go" '(?\{))
(cons "jsp" '(?\$))
(cons "razor" '(?\@))
(cons "smarty" '(?\{))
(cons "velocity" '(?\# ?\$)))
"Block electric chars.")
(defvar web-mode-block-regexp nil
"Regular expression for identifying blocks.")
(defvar web-mode-electric-chars nil
"electric chars")
(defvar web-mode-normalization-rules
'(("tag-case" . "lower-case")
("attr-case" . "lower-case")
("special-chars" . "unicode") ; "unicode" "entities"
("css-indentation" . t)
("smart-apostrophes" . t)
("smart-quotes" . t)
("whitespaces" . t)
("indentation" . t))
"Normalization rules")
(defvar web-mode-comment-keywords