推荐学习书目
› 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 · Apr 9, 2016 · 5317 views
    This topic created in 3878 days ago, the information mentioned may be changed or developed.

    用 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 replies  •  2016-04-10 18:14:06 +08:00
    4641585
    4641585
    Apr 9, 2016
    1
    想了半天 codehilite 是什么的缩写…
    yinzishao
    yinzishao
    OP
    Apr 9, 2016
    2
    @4641585 ~~~~~~醒目的代码~~~~~
    4641585
    4641585
    Apr 9, 2016
    3
    @yinzishao

    code high light …
    msg7086
    msg7086
    Apr 10, 2016
    4
    @4641585 他这个可能是拼音。
    580a388da131
    580a388da131
    Apr 10, 2016
    5
    一般都是 Pygments 没配置好的锅吧。
    yinzishao
    yinzishao
    OP
    Apr 10, 2016
    6
    @4641585 我还以为这就是一个单词呢。真的是缩写?
    yinzishao
    yinzishao
    OP
    Apr 10, 2016
    7
    @580a388da131 应该不是吧。我都没有安装 pygments
    davidx
    davidx
    Apr 10, 2016
    8
    两段代码使用了不同的语法来高亮的
    yinzishao
    yinzishao
    OP
    Apr 10, 2016
    9
    @davidx 上面两端是
    ```class Test:
    pass
    ``` 通过相同 markdown 转换出来的两端不同的 html 源码。这是为什么?
    yinzishao
    yinzishao
    OP
    Apr 10, 2016
    10
    @davidx 语法高亮是一样的,只是转换出来的 html 不一样。所以第二段没有色彩。可为什么不一样? 555
    davidx
    davidx
    Apr 10, 2016
    11
    有`<span class="k">class</span>`表明它被高亮了, 而你下面的代码没有
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1981 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:03 · PVG 12:03 · LAX 20:03 · JFK 23:03
    ♥ Do have faith in what you're doing.