1

我试图在使用 PrismJS 时包装长行代码,但行号不同步。

我正在使用这种风格包装代码:

pre[class*="language-"].line-numbers > code {
    position: relative;
    white-space: pre-wrap;        /* This is the line I changed to make it wrap */
}

HTML 是:

<pre class="language-none line-numbers">
<code>Short first line.
But this is a very, very long second line indeed. It goes on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on and on this far.
This is the third and last line. It should have the number 3 beside it but does not.</code>
</pre>

我在https://codepen.io/mpoo/pen/RwayGBy?editors=1100创建了一个完整的 Pen

棱镜截图

如您所见,行号与代码行完全不匹配。

是否可以使行号与 Prism 中的行匹配,或者他们根本不支持这一点?

4

0 回答 0