File tree Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,15 @@ module.exports = function (content) {
71
71
var start = node . childNodes [ 0 ] . __location . start
72
72
var end = node . childNodes [ node . childNodes . length - 1 ] . __location . end
73
73
74
- var result = content . slice ( start , end ) . trim ( )
74
+ var result
75
+ if ( type === 'script' ) {
76
+ result =
77
+ commentScript ( content . slice ( 0 , start ) , lang ) +
78
+ content . slice ( start , end ) +
79
+ commentScript ( content . slice ( end ) , lang )
80
+ } else {
81
+ result = content . slice ( start , end ) . trim ( )
82
+ }
75
83
76
84
output [ type ] . push ( {
77
85
lang : lang ,
@@ -83,14 +91,32 @@ module.exports = function (content) {
83
91
cb ( null , 'module.exports = ' + JSON . stringify ( output ) )
84
92
}
85
93
86
- function commentScript ( content ) {
94
+ function commentScript ( content , lang ) {
87
95
return content
88
96
. split ( / \n \r | \n | \r / g)
89
97
. map ( function ( line ) {
90
- if ( line . trim ( ) === '' ) {
91
- return line
92
- } else {
93
- return '// ' + line
98
+ switch ( lang ) {
99
+ case 'coffee' :
100
+ case 'coffee-jsx' :
101
+ case 'coffee-redux' :
102
+ if ( line . trim ( ) === '' ) {
103
+ return line
104
+ } else {
105
+ return '# ' + line
106
+ }
107
+ case 'purs' :
108
+ case 'ulmus' :
109
+ if ( line . trim ( ) === '' ) {
110
+ return line
111
+ } else {
112
+ return '-- ' + line
113
+ }
114
+ default :
115
+ if ( line . trim ( ) === '' ) {
116
+ return line
117
+ } else {
118
+ return '// ' + line
119
+ }
94
120
}
95
121
} )
96
122
. join ( '\n' )
You can’t perform that action at this time.
0 commit comments