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) {
7070
7171 var start = node . childNodes [ 0 ] . __location . start
7272 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+
7383 output [ type ] . push ( {
7484 lang : lang ,
7585 scoped : scoped ,
76- content : content . substring ( start , end ) . trim ( )
86+ content : result
7787 } )
7888 } )
7989
8090 cb ( null , 'module.exports = ' + JSON . stringify ( output ) )
8191}
8292
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+
83105function getAttribute ( node , name ) {
84106 if ( node . attrs ) {
85107 var i = node . attrs . length
You can’t perform that action at this time.
0 commit comments