-->

如何使用具有杰基尔Pygments来做时,支持滚动(How to support scrolling

2019-06-25 13:56发布

是否有可能使用水平滚动条,而不是文字环绕在杰基尔工作时用Pygments来做highlughted代码段。

文件来源:

{% highlight bash %}

Full thread dump OpenJDK Client VM (19.0-b09 mixed mode, sharing):

"Attach Listener" daemon prio=10 tid=0x0a482400 nid=0x5105 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
....
{% endhighlight %}

生成的页面(注意被包裹而不是滚动十六进制地址):

Answer 1:

寻找你的highlight.css在:/PROJECT_ROOT/assets/themes/THEME_NAME/css/highlight.css

并在年底加入这一行:

pre { white-space: pre; overflow: auto; }

感谢@manatwork的解决方案。



Answer 2:

这个答案用在GitHub上的页面Pygments来做和专门杰基尔交易

高亮正是如此生成:

<div class="highlight">
  <pre>
    <code>
      ... pygments highlighting spans ...
    </code>
  </pre>
</div>

您想,将让你的CSS是:

// -- selector prefixed to the wrapper div for collision prevention

.highlight pre code * {
  white-space: nowrap;    // this sets all children inside to nowrap
}

.highlight pre {
  overflow-x: auto;       // this sets the scrolling in x
}

.highlight pre code {
  white-space: pre;       // forces <code> to respect <pre> formatting
}


Answer 3:

我用的是杰基尔和Twitter的引导,下面是我到底什么工作:

.highlight pre {
    word-wrap: normal;
}

.highlight pre code {
    white-space: pre;
}


Answer 4:

对我来说,使用最新的greates杰基尔和荧光笔的版本中,这个钉的问题:

/* Make code block overflow */
.highlight pre {
  display: inline-block;
}


文章来源: How to support scrolling when using pygments with Jekyll