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:
# Q4 `* `2 r$ ~- J( ?& Q: T' JHTML(这个vim用:TOhtml也可以)( K. `7 T+ e( \3 X# J
XHTML
0 W/ k+ x+ e1 q8 i5 `8 MLATEX
* V6 o; J R% E4 P* vTEXINFO
) r" U f! s! b4 [, CANSI color escape sequences (可以在水木上彩色显示代码,vim有TOansi插件也可以, DocBook These are the input languages (or input formats) already supported (in alphabetical order):
6 v) f- ]5 B( {+ B# Y& p( rC/C++
# T6 S% u Y7 ~$ @5 xC#
; [, p3 ]5 Q8 C) v# Q2 pBib, f7 @$ P/ r/ x5 D* V3 Y( W
Bison! o/ s( H4 C; j
Caml' J: ?" l. m. K7 {$ j6 L
Changelog! m" v4 |' C. _. N
Css (new)) P8 Q0 p3 f/ b& ~7 ^
Diff6 R, A' O9 t% L$ F) ^% |0 _1 ~+ U
Flex
" k8 S% x# ]/ G; H, l- {Fortran \5 B0 k# _* i: s" |5 y; Y
Html0 H: H8 U/ D5 C+ m/ `! a$ S. o
Java+ O0 z9 Z8 ^2 s( ~4 j
Javascript; R9 a g, Q- T C0 i4 P5 V% l
Latex3 j$ R5 U% q5 g" d; W, S) Y
Logtalk
$ [( t2 o. {" h$ a! ILog files
3 e* J+ J) H2 r2 CLua
8 j& G7 V- P* e* iMakefile (new)' u6 R$ v# V+ I, S# Y
M4 (new)
& b8 h, Q/ \" o) L9 T/ K7 k5 dML
' {: d: F3 V6 J& ~5 XPascal8 g- [( H3 R5 b# k ~
Perl
$ [: u0 e( Q( ~, j T8 {PHP
7 K& P' @, ^$ A/ {Postscript
, r7 J7 |' A) }5 S) i- i" ]Prolog
5 F% g! X) X5 ePython
; D" B% A, X0 LRuby Y) Q( q, U! D; f- k' l n
Shell/ Q% Z; _6 ?8 t. ]! v
Sql
# H+ C/ R5 \3 a. b. d5 r6 ETcl
, n- M) K0 t! d9 f5 X* nXML 自己编译的话要用到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 b# a' U1 D! n" v) d/ x8 K
files, but this/ P+ ^6 B6 R" y$ e% `. L
is valid also for other source-highlight input languages):
" ? v& G7 O) F2 o3 Msource-highlight --src-lang cpp --out-format html \
K# P/ W: `- k--input <C++ file> \, H0 G9 T3 ~4 E |
--output <html file> \2 i9 ~* A7 g+ k" U/ h
--style-file <style file> \# ^" S. n+ i' Y; \7 |; i2 s- c
options, X( E0 }* w) Z
For input files, apart from the -i (--input) option and the standard input redirection, you8 h4 W- T, L: q% v6 f9 A2 d
can simply specify some files at the command line and also use regular expressions (for instance
! v! N$ w5 B/ t/ [) M( ^‘*.java’). In this case the name for the output files will be formed using the name of the source7 g' {4 {& T$ f) g
file with a .<ext> appended, where <ext> is the extension chosen according to the output format
& V3 J2 }: ?/ y: k1 S `2 P4 }specified (in this example it would be .html). The style file (Section 5.1 [Output format style],9 S8 l- C$ g) N: N
page 8) contains information on how to format specific language parts (e.g., keywords in blue6 x- W5 _% P' p) a
and boldface, etc.). If STDOUT string is passed as -o (--output) option, then the output is forced
/ O# I9 s B+ X1 `7 h/ v; Qto the standard output anyway.
: V3 x% w& Y2 g( L& H5 _If -s (--src-lang) is not specified, the source language is inferred by the extension of the
# m. B4 F# [* [2 Hinput file (this, of course, does not work with standard input redirection)." R. Q; E/ V" t* Y8 O6 s& P2 r8 l
If -f (--out-format) is not specified, the output will be produced in HTML.9 E. M8 M, N+ j! W* d4 k
If --style-file is not specified, the ‘default.style’, which is included in
) R x! L6 I5 p# M u8 _) K6 w" `/ Tthe distribution,will be used。 自带文档说的更详细 E) y* u' v+ F
.style和.outlang都可以改得,比如附带的esc.style(输出成ansi彩色用的色彩配置文件)是 keyword blue b ;
4 T6 |" Q0 Z$ U+ Gtype darkgreen ;
$ Q$ ]5 [/ N1 m6 E }$ istring red ;
1 {) z' l" w" f" mcomment brown i ;" y# z3 V1 |6 p: ?
number purple ;: H- s/ L, j9 p: ^5 G
preproc darkblue b ;
+ x. K0 F+ w7 }! {8 x* {- o1 r& x2 [symbol darkred ;
) }6 f8 y5 d; ?, ?8 u7 ffunction black b;/ R/ H" w1 _- t! H! Q: C
cbracket red; // line numbers
. H/ R: d' }7 Hlinenum yellow; 输出出来在term下不是很好看,我把它改成 keyword green b ;
5 s8 }7 V+ J' S" wtype green ;
* {1 O( C8 {2 F5 U: H# H" P. R9 Y8 {, S4 Cstring yellow ;# L% M% k- u2 K# O+ Y4 M# S
comment cyan i ;& ^9 ?' K* u3 `# O) r+ p5 _
number yellow ;2 u2 S. p" S4 I: A+ G" A0 _4 x
preproc blue b ;
# ~ P2 b) e h4 V! j) Gsymbol purple ;: u: b9 C4 |( C
function red b;
9 @2 [+ n5 E! v' w' ecbracket purple; // line numbers+ O5 |( z [2 U- J; n+ u, I
linenum yellow; 改了之后term上水木的截图
& o- U2 \+ t- |4 \* L0 v
转成html的用法是 source-highlight.exe -s cpp -f html --input comments.cpp --output xxx.html 就不贴图了,觉得默认style不好看就自己改一改
+ k* f& R9 B2 E7 }# Y( } |