zoukankan      html  css  js  c++  java
  • GNU Sourcehighlight 语法高亮代码

    官方主页

    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:
    HTML(这个vim用:TOhtml也可以)
    XHTML
    LATEX
    TEXINFO
    ANSI color escape sequences (可以在水木上彩色显示代码,vim有TOansi插件也可以,

    可以在这里下载
    DocBook

    These are the input languages (or input formats) already supported (in alphabetical order):
    C/C++
    C#
    Bib
    Bison
    Caml
    Changelog
    Css             (new)
    Diff
    Flex
    Fortran
    Html
    Java
    Javascript
    Latex
    Logtalk
    Log files
    Lua
    Makefile             (new)
    M4             (new)
    ML
    Pascal
    Perl
    PHP
    Postscript
    Prolog
    Python
    Ruby
    Shell
    Sql
    Tcl
    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
    files, but this
    is valid also for other source-highlight input languages):
    source-highlight --src-lang cpp --out-format html \
    --input <C++ file> \
    --output <html file> \
    --style-file <style file> \
    options
    For input files, apart from the -i (--input) option and the standard input redirection, you
    can simply specify some files at the command line and also use regular expressions (for instance
    ‘*.java’). In this case the name for the output files will be formed using the name of the source
    file with a .<ext> appended, where <ext> is the extension chosen according to the output format
    specified (in this example it would be .html). The style file (Section 5.1 [Output format style],
    page 8) contains information on how to format specific language parts (e.g., keywords in blue
    and boldface, etc.). If STDOUT string is passed as -o (--output) option, then the output is forced
    to the standard output anyway.
    If -s (--src-lang) is not specified, the source language is inferred by the extension of the
    input file (this, of course, does not work with standard input redirection).
    If -f (--out-format) is not specified, the output will be produced in HTML.
    If --style-file is not specified, the ‘default.style’, which is included in
    the distribution,will be used。

    自带文档说的更详细
    .style和.outlang都可以改得,比如附带的esc.style(输出成ansi彩色用的色彩配置文件)是

    keyword blue b ;
    type darkgreen ;
    string red ;
    comment brown i ;
    number purple ;
    preproc darkblue b ;
    symbol darkred ;
    function black b;
    cbracket red;

    // line numbers
    linenum yellow;

    输出出来在term下不是很好看,我把它改成

    keyword green b ;
    type green ;
    string yellow ;
    comment cyan i ;
    number yellow ;
    preproc blue b ;
    symbol purple ;
    function red b;
    cbracket purple;

    // line numbers
    linenum yellow;

    改了之后term上水木的截图

    转成html的用法是

    source-highlight.exe -s cpp -f html --input comments.cpp --output xxx.html

    就不贴图了,觉得默认style不好看就自己改一改

  • 相关阅读:
    学号 20175201张驰 《Java程序设计》第5周学习总结
    2018-2019-20175329 实验五《网络编程与安全》实验报告
    MySort作业与IO-Myhead
    实验四《Android程序设计》实验报告封面
    学号 20175329 《Java程序设计》第10周学习总结
    2018-2019-20175329 实验三敏捷开发与XP实践《Java开发环境的熟悉》实验报告
    MyCP(课下作业,必做)
    # 20175329 2018-2019-3 《Java程序设计》第九周学习总结
    学号 20175329 2018-2019-3《Java程序设计》第八周学习总结
    学号 20175329 2018-2019-3《Java程序设计》第八周学习总结
  • 原文地址:https://www.cnblogs.com/feisky/p/2310347.html
Copyright © 2011-2022 走看看