- Timestamp:
- 11/15/08 09:28:25 (8 weeks ago)
- Files:
-
- 1 modified
-
src/perl6/STD_syntax_highlight (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/perl6/STD_syntax_highlight
r22881 r23020 23 23 =head1 SYNOPSIS 24 24 25 # print html output with inlined resources for 'comp_unit' 25 # read from standard input 26 STD_syntax_highlight 27 28 # print ansi-escaped text for 'comp_unit' 26 29 STD_syntax_highlight foo.pl 27 30 28 31 # print separate html, css and javascript files 29 STD_syntax_highlight -- clean-html foo.pl30 31 # print htmlfor with 'statementlist' as the top-level rule32 STD_syntax_highlight --full-html=foo.full.html --clean-html foo.pl 33 34 # print ansi-escaped text for with 'statementlist' as the top-level rule 32 35 STD_syntax_highlight foo.pl statementlist 33 36 … … 73 76 ); 74 77 75 if ($ #ARGV < 0 || $help) {78 if ($help) { 76 79 die <<"HELP"; 77 80 USAGE: 78 $PROGRAM_NAME [options] filename [rule] 79 80 where options can be one of the following: 81 $PROGRAM_NAME [options] [file] [rule] 82 83 where 'file' is optional; if omitted or is '-' then 84 STDIN will be used. And 'options' can be one of the following: 81 85 82 86 --clean-html … … 87 91 88 92 --simple-html=filename 89 write simple-mode html to filename (defaults to STDOUT if no other 90 option is selected, - for STDOUT) 93 write simple-mode html to filename (- for STDOUT) 91 94 92 95 --snippet-html=filename 93 same as --simple-html but with only the body section. 94 This is typically ideal for inline html code. 96 This is typically ideal for inline html code. (- for STDOUT) 95 97 96 98 --ansi-text=filename … … 103 105 104 106 #default is --simple-html=- if no option is selected 105 if(!($ ansi_text || $full_html || $snippet_html || $yaml) && !$simple_html) {106 $ simple_html= '-';107 if(!($simple_html || $full_html || $snippet_html || $yaml) && !$ansi_text) { 108 $ansi_text = '-'; 107 109 } 108 110 … … 111 113 my $what = shift @ARGV // 'comp_unit'; 112 114 113 unless(-r $file) { 114 die "Could not open '$file' for reading\n"; 115 } 116 117 # slurp the file for redspans 115 #what is the meaning of your input file? 116 if(!$file || $file eq '-') { 117 # i think you mean standard input 118 $file = \*STDIN; 119 } else { 120 # no it is should be a file, let me check 121 unless(-r $file) { 122 die "Could not open '$file' for reading\n"; 123 } 124 } 125 126 # slurp the file for parsing and redspans 118 127 $src_text = Encode::decode('utf8', read_file($file) ); 119 120 128 $loc[length($src_text) - 1] = []; 121 122 $parser = STD->parsefile($file,$what); 129 $parser = STD->parse($src_text,$what); 123 130 124 131 # and finally print out the html code
