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:
2 M; n( ?4 `' y3 `HTML(这个vim用:TOhtml也可以)+ l7 L) p) K3 A. C; O( B- K d5 a# w
XHTML" ?8 U; f" X3 N/ X& K9 |8 \
LATEX5 l# Q7 ?. g" u
TEXINFO% p% P" ]; ?, x# R" h+ A; W
ANSI color escape sequences (可以在水木上彩色显示代码,vim有TOansi插件也可以, DocBook These are the input languages (or input formats) already supported (in alphabetical order):# Q1 o6 ?) P4 `* x9 \
C/C++
$ [2 c9 R7 }2 @, ?, q5 AC#
& [, s! c z) m. F9 f- z, ?' y* wBib
# L( I8 O% K1 i# OBison; `- g3 d- e8 l; j$ X9 L- S; b* T$ d0 {
Caml
( g* a0 w0 P2 Y, W+ ]. E2 K& vChangelog6 B h' }+ u% S8 b9 C4 U$ n. |* R3 t
Css (new)
$ g7 P9 P# ?" X: P& SDiff
3 q7 ?+ }, X0 d2 h$ j6 B# u& iFlex
3 D8 h$ c$ a! w% z, |" f" [4 eFortran
: g6 [1 [: M' T: ~; THtml
' |4 f1 `& w. S' N( ^ FJava
) N: v Z u. h- EJavascript+ Z: U9 W" S* S! h
Latex
& _0 C. S; F/ Q7 l) Z3 tLogtalk
, _# N" U9 W V' h0 _" C8 J: @0 {" \Log files6 U/ ~6 a2 l9 Z
Lua
: D" m, h0 M5 f. V" qMakefile (new)) [- h& ]0 y# C7 ]4 D
M4 (new)
2 ?& C) e; U. @2 ?ML z" q4 m8 g( f3 _
Pascal, ~/ }8 C; g6 o7 ~. S& ?+ u% p
Perl
; w( P7 G2 y' e" ?9 Z) ?! \PHP V: S) z0 p! d+ O9 @
Postscript \' ]; L. P* X0 ~% C7 w: ?
Prolog
! N* X+ P* y1 r& n, H7 x/ ]Python' F% R! t$ B$ _
Ruby
; I: r( m# [" M( E" |) P+ YShell; o$ U( L8 F, L! f6 Y: T, Z
Sql
5 c- a. }+ B. D( @' `3 G: v+ PTcl
, M9 ?9 o$ ]. {% ]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+ z/ o( m4 t+ F" |
files, but this* f7 K% D5 j2 `- N
is valid also for other source-highlight input languages):& L5 A* {4 D- L
source-highlight --src-lang cpp --out-format html \
* B* u, z4 f* w0 l0 k--input <C++ file> \
& {4 M5 x( w' Z--output <html file> \
& s0 z( R% N" \+ K7 ]& x--style-file <style file> \
; b/ `. G0 W( a& f& [! H( Roptions
" I. L- U) O4 i; s& V6 BFor input files, apart from the -i (--input) option and the standard input redirection, you
& u% g% F" o: u4 H! _( u, Xcan simply specify some files at the command line and also use regular expressions (for instance
/ t }7 i. ~" t; Y: R6 {' n‘*.java’). In this case the name for the output files will be formed using the name of the source8 u* K. N% l1 v" {, Y" x2 _" \9 b$ o
file with a .<ext> appended, where <ext> is the extension chosen according to the output format o: ^9 Y$ o# ~6 T3 ]- C
specified (in this example it would be .html). The style file (Section 5.1 [Output format style],5 }' U$ p. d0 h+ \) K7 v; `
page 8) contains information on how to format specific language parts (e.g., keywords in blue
, M% u" H2 Y2 J+ ]7 O uand boldface, etc.). If STDOUT string is passed as -o (--output) option, then the output is forced2 U* _. l5 _6 v2 e$ ] W( A: c
to the standard output anyway.; X) F; r6 X' V& _4 K( {5 i
If -s (--src-lang) is not specified, the source language is inferred by the extension of the
, F% i$ o+ ?, ~$ [- s8 f1 }: Iinput file (this, of course, does not work with standard input redirection).- l! I1 [3 k3 Y1 c
If -f (--out-format) is not specified, the output will be produced in HTML." ~" w, B& p* z* V
If --style-file is not specified, the ‘default.style’, which is included in4 \0 C4 v! P1 [* u
the distribution,will be used。 自带文档说的更详细
V! F; U7 O6 L4 Z.style和.outlang都可以改得,比如附带的esc.style(输出成ansi彩色用的色彩配置文件)是 keyword blue b ;
: k+ P* _$ ]3 u6 c. Jtype darkgreen ;% N2 l5 ~1 V: F; @: Y% v- f+ t+ H1 ?, C
string red ;
' U' P S4 v1 e) }* X( Scomment brown i ;/ h7 c- V% w) \9 M k: W
number purple ;
! Z! p+ U4 L& H0 O0 o" _preproc darkblue b ;5 |7 z. [, i' G2 I
symbol darkred ;% P4 I3 Y: Y. c" A+ m
function black b;
; e5 F5 t' `0 Qcbracket red; // line numbers! r0 Y, R+ W8 s8 d% z: T- ~# v; E4 Q
linenum yellow; 输出出来在term下不是很好看,我把它改成 keyword green b ;
' i: j V; |+ w7 I, [. `! h8 x @type green ;
5 v/ G9 `! w+ H& h" xstring yellow ;
8 F% R( d; h) L+ \: kcomment cyan i ;4 d2 e$ G3 q) X
number yellow ;; v t5 X7 Z, O3 Z7 A7 ]8 L
preproc blue b ;( m5 g+ x! G6 T4 C; o
symbol purple ;+ }9 `3 o3 P2 b$ {, T/ ~0 X
function red b;
4 \: H8 G3 p- @8 N2 b9 x/ X( [' E' ocbracket purple; // line numbers
3 ]2 W# {% ?1 p+ B+ I/ E- _linenum yellow; 改了之后term上水木的截图
7 f: v$ h* u/ K E
转成html的用法是 source-highlight.exe -s cpp -f html --input comments.cpp --output xxx.html 就不贴图了,觉得默认style不好看就自己改一改
9 q% m* L$ U/ e: e. f. m* ? |