星期日, 九月 07, 2014

在这个博客贴源代码

以前好像说过怎么在 Blogger 贴代码,这次详细记录一下。
#!/usr/bin/env bash
sudo yum install hightlight xclip #if highlight or xclip is not installed
# for example you are going to post contents of t.cpp
highlight --enclose-pre --inline-cs t.cpp | \
    sed -n "/\<pre/,/pre\>/p" | \
    xclip -selection clipboard
Then you can just past the formatted codes in the editing frame(html mode) of Blogger.

Note that if you are doing this on a remote machine, xclip cannot be used. Either the content is in the remote clipboard, or the X-windows is not started.

没有评论: