推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
ant_sz
V2EX  ›  Python

发一个很out的东西,pygments

  •  
  •   ant_sz ·
    shanzi · Apr 21, 2012 · 5559 views
    This topic created in 5322 days ago, the information mentioned may be changed or developed.
    大名顶顶的pocoo出品么,必属精品

    http://pygments.org/

    用python将目标源代码高亮化,然后可以输出到html、TeX、图片等诸多格式,还可以直接在Terminal里输出,高亮方面,甚至支持BrainFXXk这种奇葩语言。。。

    也配有命令行工具神马的
    6 replies  •  1970-01-01 08:00:00 +08:00
    udonmai
    udonmai
    Apr 21, 2012
    1
    oct0press的代码高亮就是基于这个的~
    duhastmich
    duhastmich
    Apr 21, 2012
    2
    #!/bin/sh
    if [ ! -t 0 ];then
    file=/dev/stdin
    elif [[ -f $1 ]];then
    file=$1
    else
    echo "Usage: $0 code.c"
    echo "or e.g. head code.c|$0"
    exit 1
    fi
    pygmentize -f terminal -g "$file"
    gujiaxi
    gujiaxi
    Apr 21, 2012
    3
    @udonmai 为什么我没有安装pygments但是Octopress的代码高亮还是正常工作的……貌似Octopress用的是一个插件实现的,不知道跟原生的Jekyll的代码高亮有啥区别
    udonmai
    udonmai
    Apr 21, 2012
    4
    @gujiaxi 额,好像就是那个插件是基于pygments的。。
    acdea4effdbb420d
    acdea4effdbb420d
    Apr 21, 2012
    5
    这帖子title有歧义

    是pygments本身out了?
    现在还有很多地方在用pygments,我不觉得它已经out(过时?)了。

    还是你发pygments这个行为out了?
    既然你自己都觉得自己这个行为很out,为什么还要去执行这个行为?
    如果你真的觉得pygments很好用想与大家分享,又何必贬低自己的分享行为?
    只是为了防止有人回复“lz你out了,这玩意儿我几万年前就知道了”?
    这样的人的看法你去管他们干什么。

    不卑不亢大胆发就是。
    “推荐一个很好用的代码高亮工具,pygments”
    ant_sz
    ant_sz
    OP
    Apr 21, 2012
    6
    @acdea4effdbb420d TAT 好吧。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   988 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:33 · PVG 06:33 · LAX 14:33 · JFK 17:33
    ♥ Do have faith in what you're doing.