EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
官方主页 http://www.gnu.org/software/src-highlite/ This program, given a source file, produces a document with syntax highlighting. These are the output formats already supported:
8 b$ L8 ]- ~$ B/ H; n3 HHTML(这个vim用:TOhtml也可以)
. p/ _9 N# ]1 t* i' `$ W qXHTML
. ^/ k- [$ J' CLATEX$ d. A; p6 o/ J+ d8 l* Q" W
TEXINFO1 y; F5 P. q8 f6 O
ANSI color escape sequences (可以在水木上彩色显示代码,vim有TOansi插件也可以, DocBook These are the input languages (or input formats) already supported (in alphabetical order):: z( t; L+ g( a$ b5 Z0 K, F
C/C++, g: z8 F0 E% M) E' X
C#; k8 ?6 [* R4 ~6 l
Bib* x3 Q6 e, O& s7 s/ p/ J
Bison* |% u( i B2 y$ ~
Caml" l( ?3 S8 Q) k8 E9 W
Changelog: V+ T7 b: u9 L
Css (new)+ ?* b& n7 w" M% Z S
Diff
% d( K/ C# }) u6 LFlex6 `0 E( M+ n' b9 a" z3 Q
Fortran6 L* T0 S4 F8 Z! A: R: @! b! }
Html
( x& Y5 F# s& @% F6 UJava3 X7 c* F- A+ p- f5 ]8 | K- t
Javascript
3 ^! k( _. G; h$ o6 T" p8 D- NLatex& r* M+ J" @% l0 C7 h+ Z# n
Logtalk
, I/ I7 F3 D g7 ?. k, H( O' SLog files
( [+ u6 z7 j+ Y) }6 h- fLua2 ~- N: ]- d5 e/ d0 ^0 a
Makefile (new)
: e |9 y) @8 j a9 Z i8 yM4 (new)+ e# F8 b2 `+ J1 w1 f
ML
5 t3 e E) q# O- j0 XPascal
! V D+ q& q% O' w9 \Perl0 e" \) ~5 Y" q, c( @; r
PHP6 B6 l# G/ W4 G2 F$ V* W2 u- a
Postscript
& D" F" Z2 \% hProlog2 `/ q3 G( J0 q' R% E4 ]- B, J2 ?) u
Python1 p, s+ P& `# }2 F; `. b$ w
Ruby
+ f* H/ X& k4 p$ K, t4 b; KShell% U( W% n4 r8 S. q
Sql
% t5 F1 t5 o* R8 Z* WTcl3 T3 Q7 d1 B, u7 d3 j
XML 自己编译的话要用到boost::regex库,win32的有直接下载的 http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=33223 win32的安装之后开始菜单里只有文档,用的的时候把GnuWin32\bin\source-highlight.exe复制到GnuWin32\share\source-highlight里用吧,使用方法是 source-highlight.exe -s cpp -f esc --input comments.cpp --output xxx.txt --style-file esc.style Here’s how to run source-highlight (for this example we will use C/C++ input
/ {7 h& S' M ?# }- s4 D9 T* vfiles, but this! Q( b5 w4 c. d( K( J0 A8 Q- c
is valid also for other source-highlight input languages):
2 {( R3 c. l0 o! [! y! u i4 ]0 rsource-highlight --src-lang cpp --out-format html \
9 }+ V6 v; a ]3 |' F--input <C++ file> \5 H2 R6 e2 p8 g- k R: @3 H
--output <html file> \3 d u. v! p2 \3 I- K) t# H
--style-file <style file> \) J% c$ o ]% V5 R1 b; g1 x4 m
options
( n# H: {: U* c: K/ jFor input files, apart from the -i (--input) option and the standard input redirection, you
+ ]/ M* i0 X2 z% d/ o4 Ycan simply specify some files at the command line and also use regular expressions (for instance1 [3 ? K! X' F* u; p6 \2 |' N' \
‘*.java’). In this case the name for the output files will be formed using the name of the source! f; j2 s. K$ f5 P
file with a .<ext> appended, where <ext> is the extension chosen according to the output format+ [7 U0 n) I0 y o
specified (in this example it would be .html). The style file (Section 5.1 [Output format style],3 l' W) b v+ I$ i
page 8) contains information on how to format specific language parts (e.g., keywords in blue, M$ n: R4 T/ Y6 x1 O7 R
and boldface, etc.). If STDOUT string is passed as -o (--output) option, then the output is forced2 u0 q8 U/ W$ l" B5 B/ e3 n; S$ r
to the standard output anyway.
8 h1 ^ x7 o- A [) T `If -s (--src-lang) is not specified, the source language is inferred by the extension of the
, w8 y; [. y' f5 \4 q# g. Linput file (this, of course, does not work with standard input redirection).! c) u6 I9 R9 y: C* u, x
If -f (--out-format) is not specified, the output will be produced in HTML.
0 m1 {- \8 L3 x5 x6 _( cIf --style-file is not specified, the ‘default.style’, which is included in
% |% D, S! u' R5 F5 h7 u& n1 F: q+ W6 bthe distribution,will be used。 自带文档说的更详细
3 i( ~" P2 C* o: y! v, v1 [. B) [.style和.outlang都可以改得,比如附带的esc.style(输出成ansi彩色用的色彩配置文件)是 keyword blue b ;0 O) `. |4 q: e/ C) G' t9 H
type darkgreen ;
7 n- d4 J2 b, d. n* l$ Mstring red ;
1 M4 x9 |! @( G9 ycomment brown i ;& D9 R0 k$ k6 o
number purple ;
: s# z3 g. J" Q0 h9 k7 r2 X0 Qpreproc darkblue b ;
9 _; J' y# \6 ?; w- F; |, o- {symbol darkred ;
& z( H% t6 [3 E( B; ffunction black b;
4 Q* g1 f' N: {1 icbracket red; // line numbers' x* X& S+ X" R, I
linenum yellow; 输出出来在term下不是很好看,我把它改成 keyword green b ;9 h0 T8 \ e* P$ p& S
type green ;' Q' p* N: M9 U3 h/ L6 T9 J; l
string yellow ;9 D6 y- S% d1 C0 ]" P; l3 v3 u/ ]
comment cyan i ;3 Q0 ^; _3 Z( T4 O
number yellow ;
; L/ X" x! ^! P* Qpreproc blue b ;* {0 w/ A. K" i! F8 j, R6 s
symbol purple ;
: ^0 v. ]* M6 b5 H7 }function red b;( D4 `7 c; ^0 t, P1 a: O0 I5 l
cbracket purple; // line numbers; H8 M( @8 [) `& U
linenum yellow; 改了之后term上水木的截图
* I/ O: B4 _, h: n1 T: z# R
转成html的用法是 source-highlight.exe -s cpp -f html --input comments.cpp --output xxx.html 就不贴图了,觉得默认style不好看就自己改一改
" `4 }% ?2 X" b- t6 ^ |