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
yinzishao
V2EX  ›  Python

markdown 代码块高亮问题。为什么不同的电脑显示不同的 html 格式?

  •  
  •   yinzishao · 2016-04-09 23:18:34 +08:00 · 4276 次点击
    这是一个创建于 2955 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用 django 和 markdown 和 Pygments 来实现代码高亮。在本地运行可以。可当我移植到另外一台电脑的时候。出现了一个很奇怪的问题! 相同的东西通过 markdown 后生成的 html 不一样。

    有色彩的 html :

    <div class="codehilite"><pre><span class="k">class</span> <span class="nc">Test</span><span class="p">:</span>
       <span class="k">pass</span>
    </pre></div>
    

    另外一台电脑生成这无色彩的 html

    <pre class="codehilite"><code>class Test:
       pass</code></pre>
    

    我很想知道是哪里出现了问题?!

    11 条回复    2016-04-10 18:14:06 +08:00
    4641585
        1
    4641585  
       2016-04-09 23:24:07 +08:00
    想了半天 codehilite 是什么的缩写…
    yinzishao
        2
    yinzishao  
    OP
       2016-04-09 23:28:39 +08:00
    @4641585 ~~~~~~醒目的代码~~~~~
    4641585
        3
    4641585  
       2016-04-09 23:50:52 +08:00
    @yinzishao

    code high light …
    msg7086
        4
    msg7086  
       2016-04-10 02:47:43 +08:00
    @4641585 他这个可能是拼音。
    580a388da131
        5
    580a388da131  
       2016-04-10 06:29:51 +08:00
    一般都是 Pygments 没配置好的锅吧。
    yinzishao
        6
    yinzishao  
    OP
       2016-04-10 09:32:56 +08:00
    @4641585 我还以为这就是一个单词呢。真的是缩写?
    yinzishao
        7
    yinzishao  
    OP
       2016-04-10 09:33:43 +08:00
    @580a388da131 应该不是吧。我都没有安装 pygments
    davidx
        8
    davidx  
       2016-04-10 15:58:10 +08:00
    两段代码使用了不同的语法来高亮的
    yinzishao
        9
    yinzishao  
    OP
       2016-04-10 16:17:40 +08:00
    @davidx 上面两端是
    ```class Test:
    pass
    ``` 通过相同 markdown 转换出来的两端不同的 html 源码。这是为什么?
    yinzishao
        10
    yinzishao  
    OP
       2016-04-10 16:18:48 +08:00
    @davidx 语法高亮是一样的,只是转换出来的 html 不一样。所以第二段没有色彩。可为什么不一样? 555
    davidx
        11
    davidx  
       2016-04-10 18:14:06 +08:00
    有`<span class="k">class</span>`表明它被高亮了, 而你下面的代码没有
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3610 人在线   最高记录 6547   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 11:20 · PVG 19:20 · LAX 04:20 · JFK 07:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.