V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2012-04-21 10:36:41 +08:00 · 4356 次点击
    这是一个创建于 4388 天前的主题,其中的信息可能已经有所发展或是发生改变。
    大名顶顶的pocoo出品么,必属精品

    http://pygments.org/

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

    也配有命令行工具神马的
    6 条回复    1970-01-01 08:00:00 +08:00
    udonmai
        1
    udonmai  
       2012-04-21 11:14:15 +08:00
    oct0press的代码高亮就是基于这个的~
    duhastmich
        2
    duhastmich  
       2012-04-21 16:04:11 +08:00
    #!/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
        3
    gujiaxi  
       2012-04-21 16:12:10 +08:00
    @udonmai 为什么我没有安装pygments但是Octopress的代码高亮还是正常工作的……貌似Octopress用的是一个插件实现的,不知道跟原生的Jekyll的代码高亮有啥区别
    udonmai
        4
    udonmai  
       2012-04-21 18:38:43 +08:00
    @gujiaxi 额,好像就是那个插件是基于pygments的。。
    acdea4effdbb420d
        5
    acdea4effdbb420d  
       2012-04-21 18:59:36 +08:00
    这帖子title有歧义

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

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

    不卑不亢大胆发就是。
    “推荐一个很好用的代码高亮工具,pygments”
    ant_sz
        6
    ant_sz  
    OP
       2012-04-21 20:34:41 +08:00
    @acdea4effdbb420d TAT 好吧。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5797 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 06:10 · PVG 14:10 · LAX 23:10 · JFK 02:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.