如何阻止Kramdown在代码块中删除凹痕?

发布于 2025-02-10 12:27:58 字数 888 浏览 0 评论 0原文

在我的Jekyll网站上渲染Python CodeBlocks时,Kramdown删除了所有凹痕。

代码:

from sort.AbstractSort import AbstractSort

class BubbleSort(AbstractSort):  
    @staticmethod  
    def swap(arr, i, j):  
        arr[i], arr[j] = arr[j], arr[i]  
  
    def _sort(self, arr):  
        for i in range(len(arr) - 1):  
            for j in range(len(arr) - 1):  
                if arr[j] > arr[j + 1]:  
                    BubbleSort.swap(arr, j, j + 1)  
        return arr
    

kramdown渲染:

”凹痕删除”

kramdown没有最好的文档,我找不到任何明显的设置,我应该在我的jekyll网站的_config.yaml中更改。

我正在GitHub页面上托管该网站。

如果不可能,也许我应该更改为其他渲染?但是,这也记录在案很差,我改用GFM的尝试失败了。

When rendering Python codeblocks on my Jekyll site, Kramdown removes all of the indents.

The code:

from sort.AbstractSort import AbstractSort

class BubbleSort(AbstractSort):  
    @staticmethod  
    def swap(arr, i, j):  
        arr[i], arr[j] = arr[j], arr[i]  
  
    def _sort(self, arr):  
        for i in range(len(arr) - 1):  
            for j in range(len(arr) - 1):  
                if arr[j] > arr[j + 1]:  
                    BubbleSort.swap(arr, j, j + 1)  
        return arr
    

Kramdown render:

Indents removed

Kramdown doesn't have the best documentation and I couldn't find any obvious settings that I should change in _config.yaml of my Jekyll site.

I'm hosting the site on GitHub pages.

If it is not possible, maybe I should change to a different rendered? But then this is also poorly documented and my attempts to switch to GFM had failed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千纸鹤带着心事 2025-02-17 12:27:58

AS benjamin w。 CSS 。

要解决问题,请更改:

pre code {
    ...
    white-space: pre-line !important;       
    ...
}

解决

pre code {
    ...
    white-space: pre !important;       
    ...
}

问题。

As Benjamin W. have written, this is due to bad CSS configuration in assets/css/style.css.

To solve the problem, change:

pre code {
    ...
    white-space: pre-line !important;       
    ...
}

to

pre code {
    ...
    white-space: pre !important;       
    ...
}

solves the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文