在 Drupal 中使用 reStructuredText - 改进版
用于 Drupal6 的版本,加上了 Pygments 对代码做彩色语法显示。还是很简陋而且乱糟糟的,有很多地方要完善。
需要在主题的 style sheet 里设置菜色显示的颜色方案。 Acquia Marina 有个好处是可以把自己修改的设定加在 local.css 里这样升级的时候就安全了。
- local.css
#content {
font-size: 133%;
}
#comments h2.comments {
text-transform: none;
font-variant: small-caps;
}
h2.title {
text-transform: none;
font-variant: small-caps;
}
pre {
font-family: "Consolas", monospace;
}
.literal {
text-decoration: none;
background-color: #fbeddd;
border-width: 0 0 1px 0;
border-style: none none dashed none;
}
/* code-block highlight scheme for Pygments output */
.highlight {
background-color: #ddedfb;
border-style: solid;
border-color: #0099cc;
border-width: 1px 0 1px 0;
margin: 1em 0;
padding: 0.5em 1em;
}
/* css genetated from gen_pyg_style.py should be appended here*/
上面是针对自己的喜好改的 local.css 内容,代码彩色语法的 css 可以用下面的脚本生成,加在 local.css 后面。
- gen_pyg_style.py
#!/usr/bin/python
import sys
from pygments.formatters import HtmlFormatter
style='friendly'
if len(sys.argv) > 1:
style = sys.argv[1]
print style
f = HtmlFormatter(style=style)
print f.get_style_defs()
另外 settings.php 最好也改一下
- settings.php
1 <?php
2 $db_url = '<database url...>';
3 $db_prefix = '';
4 $update_free_access = FALSE;
5 $conf = array(
6 'reverse_proxy' => TRUE,
7 'reverse_proxy_addresses' => array('x.y.z.w',),
8 'allow_insecure_uploads' => 1,
9 );
6、7 行是放在反向代理后面而本服务器又没做特别设置时的必要措施。8 行是因为 Drupal 默认会在上传文件时把多段扩展名加个下划线,譬如 .tar.gz 的改成 .tar_.gz 的样子,号称为了安全,但相当丑陋,我不需要这种安全。
| 附件 | 大小 |
|---|---|
| drest-with-pygments.tar.gz | 3.35 KB |
- adoal's blog
- 1588 次点击

评论
没在 drupal
出来的结果
非常好! 但是没有在 Drupal
测试哈:
if __name__ == '__main__': # this way the module can be if 4 != len(sys.argv): print """ %s usage:: $ python sshuttler.py AIMUSER AIMHOST SSHPUBK """ % VER else: AIMUSER = sys.argv[1] AIMHOST = sys.argv[2] SSHPUBK = sys.argv[3] gensh(AIMUSER,AIMHOST,SSHPUBK,VER) print "Mnnnn export that .sh do it!"study your work
study your work
发表新评论