File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ export default function parse(code) {
55 commentContents = firstLine . substring ( 1 ) . trimStart ( ) ;
66 } else if ( firstLine . startsWith ( "//" ) ) {
77 commentContents = firstLine . substring ( 2 ) . trimStart ( ) ;
8+ } else if ( firstLine . startsWith ( "/*" ) ) {
9+ commentContents = firstLine . substring ( 2 ) . trimStart ( ) ;
10+ } else if ( firstLine . startsWith ( "<!--" ) ) {
11+ commentContents = firstLine . substring ( 4 ) . trimStart ( ) ;
812 }
913
1014 if ( commentContents ) {
Original file line number Diff line number Diff line change 55import parse from "./parse" ;
66import { CodeplusInstance } from "./index" ;
77
8- test ( "parse filename" , ( ) => {
8+ test ( "parse # filename" , ( ) => {
99 const parsed = parse ( "# filename.js\nfunction foo() {}" ) ;
1010 expect ( parsed ) . toEqual ( {
1111 filename : "filename.js" ,
1212 displayName : "" ,
1313 } ) ;
1414} ) ;
1515
16+ test ( "parse // filename" , ( ) => {
17+ const parsed = parse ( "// filename.js\nfunction foo() {}" ) ;
18+ expect ( parsed ) . toEqual ( {
19+ filename : "filename.js" ,
20+ displayName : "" ,
21+ } ) ;
22+ } ) ;
23+
24+ test ( "parse /* filename" , ( ) => {
25+ const parsed = parse ( "/* filename.js */\nfunction foo() {}" ) ;
26+ expect ( parsed ) . toEqual ( {
27+ filename : "filename.js" ,
28+ displayName : "" ,
29+ } ) ;
30+ } ) ;
31+
32+ test ( "parse <!-- filename" , ( ) => {
33+ const parsed = parse ( "<!-- filename.js -->\nfunction foo() {}" ) ;
34+ expect ( parsed ) . toEqual ( {
35+ filename : "filename.js" ,
36+ displayName : "" ,
37+ } ) ;
38+ } ) ;
39+
1640test ( "parse filename multiple dots" , ( ) => {
1741 const parsed = parse ( "# test.filename.template.js\nfunction foo() {}" ) ;
1842 expect ( parsed ) . toEqual ( {
You can’t perform that action at this time.
0 commit comments