jialh
2025-01-07 bb59b053247ef82969b64979260e2478bd732e1f
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
 
module.exports = {
  simple : {
    echo : "^#echo[ \t]+(.*?)[ \t]*$",
    exec : "^#exec[ \t]+(\\S+)[ \t]*\\((.*)\\)[ \t]*$",
    include          : "^(.*)#include(?!-)[ \t]+(.*?)[ \t]*$", // allow prefix characters to specify the indent level of included file
    'include-static' : "^(.*)#include-static[ \t]+(.*?)[ \t]*$"
  },
  html : {
    echo : "<!--[ \t]*#echo[ \t]+(.*?)[ \t]*(?:-->|!>)",
    exec : "<!--[ \t]*#exec[ \t]+(\\S+)[ \t]*\\((.*)\\)[ \t]*(?:-->|!>)",
    include          : "(.*)<!--[ \t]*#include(?!-)[ \t]+(.*?)[ \t]*(?:-->|!>)",
    'include-static' : "(.*)<!--[ \t]*#include-static[ \t]+(.*?)[ \t]*(?:-->|!>)",
    exclude : {
      start : "[ \t]*<!--[ \t]*#exclude(?:[ \t]+(.*?))?[ \t]*(?:-->|!>)(?:[ \t]*\n+)?",
      end   : "[ \t]*<!--[ \t]*#endexclude[ \t]*(?:-->|!>)(?:[ \t]*\n)?"
    },
    extend : {
      start : "[ \t]*<!--[ \t]*#extend(?!able)[ \t]+(.*?)[ \t]*(?:-->|!>)(?:[ \t]*\n+)?",
      end   : "[ \t]*<!--[ \t]*#endextend[ \t]*(?:-->|!>)(?:[ \t]*\n)?"
    },
    extendable : "<!--[ \t]*#extendable[ \t]*(?:-->|!>)",
    if : {
      start : "[ \t]*<!--[ \t]*#(ifndef|ifdef|if)[ \t]+(.*?)[ \t]*(?:-->|!>)(?:[ \t]*\n+)?",
      end   : "[ \t]*<!(?:--)?[ \t]*#endif[ \t]*(?:-->|!>)(?:[ \t]*\n)?"
    },
    else : "[ \t]*<!(?:--)?[ \t]*#else[ \t]*(?:-->|!>)(?:[ \t]*\n)?",
    foreach : {
      start : "[ \t]*<!--[ \t]*#foreach[ \t]+(.*?)[ \t]*(?:-->|!>)(?:[ \t]*\n+)?",
      end   : "[ \t]*<!(?:--)?[ \t]*#endfor[ \t]*(?:-->|!>)(?:[ \t]*\n)?"
    }
  },
  js : {
    echo : [
      "/\\*[ \t]*#echo[ \t]+(.*?)[ \t]*\\*(?:\\*|/)",
      "//[ \t]*#echo[ \t]+(.*?)[ \t]*$"
    ],
    exec : "(?://|/\\*)[ \t]*#exec[ \t]+(\\S+?)[ \t]*\\((.*)\\)[ \t]*(?:\\*(?:\\*|/))?",
    include : [
      "^(.*)/\\*[ \t]*#include(?!-)[ \t]+(.*?)[ \t]*\\*(?:\\*|/)",
      "^(.*)//[ \t]*#include(?!-)[ \t]+(.*?)[ \t]*$"
    ],
    'include-static': [
      "^(.*)/\\*[ \t]*#include-static[ \t]+(.*?)[ \t]*\\*(?:\\*|/)",
      "^(.*)//[ \t]*#include-static[ \t]+(.*?)[ \t]*$"
    ],
    exclude : {
      start : "[ \t]*(?://|/\\*)[ \t]*#exclude(?:[ \t]+([^\n*]*))?[ \t]*(?:\\*(?:\\*|/))?(?:[ \t]*\n+)?",
      end   : "[ \t]*(?://|/\\*)[ \t]*#endexclude[ \t]*(?:\\*(?:\\*|/))?(?:[ \t]*\n)?"
    },
    extend : {
      start : "[ \t]*(?://|/\\*)[ \t]*#extend(?!able)[ \t]+([^\n*]*)(?:\\*(?:\\*|/))?(?:[ \t]*\n+)?",
      end   : "[ \t]*(?://|/\\*)[ \t]*#endextend[ \t]*(?:\\*(?:\\*|/))?(?:[ \t]*\n)?"
    },
    extendable : "[ \t]*(?://|/\\*)[ \t]*#extendable[ \t]*(?:\\*/)?",
    if : {
      start : "[ \t]*(?://|/\\*)[ \t]*#(ifndef|ifdef|if)[ \t]+([^\n*]*)(?:\\*(?:\\*|/))?(?:[ \t]*\n+)?",
      end   : "[ \t]*(?://|/\\*)[ \t]*#endif[ \t]*(?:\\*(?:\\*|/))?(?:[ \t]*\n)?"
    },
    else : "[ \t]*(?://|/\\*)[ \t]*#else[ \t]*(?:\\*(?:\\*|/))?(?:[ \t]*\n)?",
    foreach : {
      start : "[ \t]*(?://|/\\*)[ \t]*#foreach[ \t]+([^\n*]*)(?:\\*(?:\\*|/))?(?:[ \t]*\n+)?",
      end   : "[ \t]*(?://|/\\*)[ \t]*#endfor[ \t]*(?:\\*(?:\\*|/))?(?:[ \t]*\n)?"
    }
  },
  coffee : {
    echo : [
      "###+[ \t]*#echo[ \t]+(.*?)[ \t]###",
      "#+[ \t]*#echo[ \t]+(.*?)[ \t]*$"
    ],
    exec : "#+[ \t]*#exec[ \t]+(\\S+)[ \t]*\\((.*)\\)[ \t]*$",
    include          : "^(.*?)#+[ \t]*#include(?!-)[ \t]+(.*?)[ \t]*$",
    'include-static' : "^(.*?)#+[ \t]*#include-static[ \t]+(.*?)[ \t]*$",
    exclude : {
      start : "^[ \t]*#+[ \t]*#exclude(?:[ \t]+(.*?))?[ \t]*\n+",
      end   : "^[ \t]*#+[ \t]*#endexclude[ \t]*\n?"
    },
    extend : {
      start : "^[ \t]*#+[ \t]*#extend(?!able)[ \t]+(.*?)\n+",
      end   : "^[ \t]*#+[ \t]*#endextend[ \t]*\n?"
    },
    extendable : "^[ \t]*#+[ \t]*#extendable[ \t]*$",
    if : {
      start : "^[ \t]*#+[ \t]*#(ifndef|ifdef|if)[ \t]+(.*?)[ \t]*\n+",
      end   : "^[ \t]*#+[ \t]*#endif[ \t]*\n?"
    },
    else : "^[ \t]*#+[ \t]*#else[ \t]*\n?",
    foreach : {
      start : "^[ \t]*#+[ \t]*#foreach[ \t]+(.*?)[ \t]*\n+",
      end   : "^[ \t]*#+[ \t]*#endfor[ \t]*\n?"
    }
  }
};
 
module.exports.xml        = module.exports.html;
 
module.exports.javascript = module.exports.js;
module.exports.jsx        = module.exports.js;
module.exports.json       = module.exports.js;
module.exports.c          = module.exports.js;
module.exports.cc         = module.exports.js;
module.exports.cpp        = module.exports.js;
module.exports.cs         = module.exports.js;
module.exports.csharp     = module.exports.js;
module.exports.java       = module.exports.js;
module.exports.less       = module.exports.js;
module.exports.sass       = module.exports.js;
module.exports.scss       = module.exports.js;
module.exports.css        = module.exports.js;
module.exports.php        = module.exports.js;
module.exports.ts         = module.exports.js;
module.exports.tsx        = module.exports.js;
module.exports.peg        = module.exports.js;
module.exports.pegjs      = module.exports.js;
module.exports.jade       = module.exports.js;
module.exports.styl       = module.exports.js;
module.exports.go         = module.exports.js;
 
module.exports.bash       = module.exports.coffee;
module.exports.shell      = module.exports.coffee;
module.exports.sh         = module.exports.coffee;