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:' V! z' s; g6 @4 }0 C7 j
HTML(这个vim用:TOhtml也可以)
. I* \& j8 ?7 k- a6 j/ z' h9 OXHTML5 D! u6 I, p* c$ J
LATEX
9 G* O! r. ]6 ?3 G( ?5 H5 ^TEXINFO2 a8 f! n9 z; _4 J) h3 k0 ~ [2 v; I
ANSI color escape sequences (可以在水木上彩色显示代码,vim有TOansi插件也可以, DocBook These are the input languages (or input formats) already supported (in alphabetical order):$ u( ~1 `8 o. L6 Z, i
C/C++. K3 k% k4 @% P" X0 Y( \( ~2 Q5 [ _+ T
C#4 ~3 ?- P4 u3 I! t K* h
Bib
3 f+ L2 Q7 [$ ^6 ~* `Bison
) ?- M5 N( o9 t. M' k" mCaml3 t7 D$ u8 W; Q4 ]( R3 q. }
Changelog
$ N% f6 T* C" ?- _) M5 R, D& y$ c5 t# XCss (new)
7 Z) g) s+ O. l) G. L4 v/ @/ D: NDiff- Y0 _; i) \1 P3 @2 s0 O2 H5 `* O
Flex, ?% i6 o0 C+ m5 k8 Q$ v
Fortran
3 V* Z- t) u- f" Y. B: m/ n: \, cHtml1 T8 I" {0 W7 F* F
Java8 o( b7 ~5 I. r' y/ K* Q5 V, a! h: I
Javascript
& d; z1 @+ l# b6 L! C0 J) L4 BLatex! Q) H- S0 e& Q* |6 s% p& u
Logtalk" R; T- C9 y6 u" p4 M# B
Log files
! D+ O# q1 {; ]( S- OLua
; T+ ?" t8 V; N" \, O# tMakefile (new)8 c& X1 L# R5 E, v" M
M4 (new)' F/ U6 B& W3 L- {
ML: G: q- O/ F- e* _5 Q
Pascal8 n; w3 x/ L2 l+ j
Perl
6 L8 M* o1 c, v( d! }PHP
7 Y/ z& p8 l8 e- _Postscript
% I- u H# Z% s; o2 y; NProlog1 d4 l& i+ v4 V+ |- N2 d
Python
; e# g; N M. jRuby
6 x+ v8 T( D( H1 ~# rShell
' _5 f$ S; m3 O) r8 y0 H' rSql
. x4 H$ x3 E# UTcl2 h. s8 U* T: k8 n) _
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
. a% j$ h {" W6 h8 k1 t- j5 Hfiles, but this1 N6 b0 j3 V- J/ ^/ D
is valid also for other source-highlight input languages):
- ]9 V6 u2 e$ B8 a9 I' o0 }source-highlight --src-lang cpp --out-format html \
: l& i T# ]- E N$ A: A0 k--input <C++ file> \6 O# E) o& y, o/ Q3 H S
--output <html file> \
+ t) W% o6 z( C--style-file <style file> \
# A& T2 u$ G" Goptions4 |5 `# i! B& {8 y) S J3 s v
For input files, apart from the -i (--input) option and the standard input redirection, you. l) t% r' ~) |
can simply specify some files at the command line and also use regular expressions (for instance* q9 ~$ ]8 m* h- E3 e
‘*.java’). In this case the name for the output files will be formed using the name of the source% o1 v7 y! V% `, r
file with a .<ext> appended, where <ext> is the extension chosen according to the output format
3 X. s# ?8 {; c, z2 ^! e6 {specified (in this example it would be .html). The style file (Section 5.1 [Output format style],9 o& Z2 v! T( I
page 8) contains information on how to format specific language parts (e.g., keywords in blue3 H0 ~) k. s( b( T4 K
and boldface, etc.). If STDOUT string is passed as -o (--output) option, then the output is forced8 N! X! Y* S: l, V7 ?2 d
to the standard output anyway.
, P( \+ G, M+ a# {) ?0 CIf -s (--src-lang) is not specified, the source language is inferred by the extension of the: d6 ^9 R8 k( r& [: I, j& j
input file (this, of course, does not work with standard input redirection).
) D# |: A- R3 @) A" [, X, M5 hIf -f (--out-format) is not specified, the output will be produced in HTML.# e; r) O* B- L
If --style-file is not specified, the ‘default.style’, which is included in4 m, p0 @9 R. E+ ^: K6 }1 m
the distribution,will be used。 自带文档说的更详细7 E9 l) Z- M# y' |
.style和.outlang都可以改得,比如附带的esc.style(输出成ansi彩色用的色彩配置文件)是 keyword blue b ;8 U" d8 M" [8 {* W. ~2 p# |
type darkgreen ;% b2 j( j9 s) ]+ n; W" E: c4 o+ D
string red ;
1 V- B7 P4 {6 ~6 a) U! bcomment brown i ;
) W' `' m% D# i" h; W: }; a6 \number purple ;9 M; f5 `( P% L( u% v
preproc darkblue b ;/ \; i1 W( V9 ~ R6 v7 ?
symbol darkred ;
/ V; R1 i p2 o+ F# w. r0 efunction black b;* l' S! a" U5 `. K
cbracket red; // line numbers
% U* o! V# g" | z P% g+ G4 K6 plinenum yellow; 输出出来在term下不是很好看,我把它改成 keyword green b ;
! \+ S/ U, W1 s$ jtype green ;
E3 F7 S2 F3 W$ n7 E6 Vstring yellow ;3 \3 G' a' X* Z6 E
comment cyan i ;1 f4 i7 A$ H) k: {5 M& T& c
number yellow ;7 c4 n j8 {% F0 Z' z9 B: R
preproc blue b ;
; j6 b5 T4 H9 M! W Lsymbol purple ;- ]% r. M2 _1 }% K
function red b;
" Q# e$ J Y' ]/ {( g. Ucbracket purple; // line numbers
1 f& G1 g* c/ @/ }linenum yellow; 改了之后term上水木的截图
% Y' H& P. @2 ~; ~转成html的用法是 source-highlight.exe -s cpp -f html --input comments.cpp --output xxx.html 就不贴图了,觉得默认style不好看就自己改一改 + z/ d, w) d* D+ V" Z1 h) I* a
|