File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -70,16 +70,38 @@ module.exports = function (content) {
70
70
71
71
var start = node . childNodes [ 0 ] . __location . start
72
72
var end = node . childNodes [ node . childNodes . length - 1 ] . __location . end
73
+
74
+ var result
75
+ if ( type === 'script' ) {
76
+ result = commentScript ( content . slice ( 0 , start ) ) +
77
+ content . slice ( start , end ) +
78
+ commentScript ( content . slice ( end ) )
79
+ } else {
80
+ result = content . slice ( start , end ) . trim ( )
81
+ }
82
+
73
83
output [ type ] . push ( {
74
84
lang : lang ,
75
85
scoped : scoped ,
76
- content : content . substring ( start , end ) . trim ( )
86
+ content : result
77
87
} )
78
88
} )
79
89
80
90
cb ( null , 'module.exports = ' + JSON . stringify ( output ) )
81
91
}
82
92
93
+ function commentScript ( content ) {
94
+ return content . split ( / \n \r | \n | \r / g)
95
+ . map ( function ( line ) {
96
+ if ( line . trim ( ) === '' ) {
97
+ return line
98
+ } else {
99
+ return '// ' + line
100
+ }
101
+ } )
102
+ . join ( '\n' )
103
+ }
104
+
83
105
function getAttribute ( node , name ) {
84
106
if ( node . attrs ) {
85
107
var i = node . attrs . length
You can’t perform that action at this time.
0 commit comments