readthedocs + mkdocs 错误渲染代码块
Wrong rendering of code blocks by readthedocs + mkdocs
我在使用带有 readthedocs 主题的 Mkdocs 的文档项目中呈现代码块时遇到问题。代码块似乎无法正确解析新行,因此代码块中的所有代码都呈现为一行。
repo 可用于重现示例,https://github.com/segrelab/comets-manual. The rendering can be seen in https://segrelab.github.io/comets-manual/。
我在 google 上找到的唯一提示是 this,但它似乎没有提供任何解决方案,除了确定问题与 css 有关(确实,我尝试了其他主题并且代码块正确呈现)。
有人知道如何解决这个问题吗?
首先,请确保您的工具是最新的(我无法重现代码块的错误渲染):
pip install --upgrade mkdocs
如果问题仍然存在,您可以使用 extra.css
解决方法(顺便说一下,extra.css
和 extra.js
必须位于 docs/css/extra.css
和 docs/js/extra.js
;见 this)。
通过从 current-rendered 页面猜测,以下应该有效:
/* docs/css/extra.css */
code, .rst-content tt, .rst-content code {
white-space: pre;
}
在呈现的页面中以某种方式设置为 white-space: nowrap;
。
我在使用带有 readthedocs 主题的 Mkdocs 的文档项目中呈现代码块时遇到问题。代码块似乎无法正确解析新行,因此代码块中的所有代码都呈现为一行。
repo 可用于重现示例,https://github.com/segrelab/comets-manual. The rendering can be seen in https://segrelab.github.io/comets-manual/。
我在 google 上找到的唯一提示是 this,但它似乎没有提供任何解决方案,除了确定问题与 css 有关(确实,我尝试了其他主题并且代码块正确呈现)。
有人知道如何解决这个问题吗?
首先,请确保您的工具是最新的(我无法重现代码块的错误渲染):
pip install --upgrade mkdocs
如果问题仍然存在,您可以使用 extra.css
解决方法(顺便说一下,extra.css
和 extra.js
必须位于 docs/css/extra.css
和 docs/js/extra.js
;见 this)。
通过从 current-rendered 页面猜测,以下应该有效:
/* docs/css/extra.css */
code, .rst-content tt, .rst-content code {
white-space: pre;
}
在呈现的页面中以某种方式设置为 white-space: nowrap;
。