@@ -27,6 +27,7 @@ public function __construct()
2727 $ this
2828 ->option ('-o --output ' , 'Output filepath where PNG image is exported ' , null , '' )
2929 ->option ('-e --echo ' , 'Forces echo to STDOUT when --output is passed ' , null , '' )
30+ ->option ('-l --with-line-no ' , 'Highlight with line number ' )
3031 ->option ('-f --file ' , \implode ("\n" , [
3132 'Input PHP file to highlight and/or export ' ,
3233 '(will read from piped input if file not given) ' ,
@@ -38,6 +39,7 @@ public function __construct()
3839 . '<bold> $0</end> <comment>< file.php</end> ## from redirected stdin<eol/> '
3940 . '<bold> $0</end> <comment>--file file.php --output file.png</end> ## export<eol/> '
4041 . '<bold> $0</end> <comment>--file file.php --output file.png --echo</end> ## print + export<eol/> '
42+ . '<bold> $0</end> <comment>--file file.php --with-line-no</end> ## print with lineno<eol/> '
4143 . '<bold> $0</end> <comment>-f file.php -o file.png -F dejavu</end> ## export in dejavu font<eol/> '
4244 );
4345 }
@@ -78,7 +80,7 @@ public function execute()
7880 protected function doHighlight (string $ code = null )
7981 {
8082 if (!$ this ->output || $ this ->echo ) {
81- $ this ->app ()->io ()->raw ((string ) new Highlighter ($ code ));
83+ $ this ->app ()->io ()->raw ((new Highlighter )-> highlight ($ code, [ ' lineNo ' => $ this -> lineNo ] ));
8284 }
8385 }
8486
@@ -92,7 +94,7 @@ protected function doExport(string $code = null)
9294 \mkdir (\dirname ($ this ->output ), 0755 , true );
9395 }
9496
95- $ options = ['font ' => $ this ->fixFont ($ this ->font ?: 'ubuntu ' )];
97+ $ options = ['font ' => $ this ->fixFont ($ this ->font ?: 'ubuntu ' ), ' lineNo ' => $ this -> lineNo ];
9698
9799 (new Exporter ($ code ))->export ($ this ->output , $ options );
98100 }
0 commit comments