我想为开源项目贡献一些文档,所以我试图在本地预览文档页面,这是github网站的一部分。但是,我的代码块没有正确格式化。我创建了一个小例子:Jekyll/kramdown没有正确格式化scala
_config.yml
markdown: kramdown
highlighter: rouge
kramdown:
input: GFM
hard_wrap: false
parse_block_html: true
name: test
default.html中
<!doctype html>
<html>
<body>{{ content }}</body>
</html>
auth.md
---
layout: default
---
## Authentication
Some description.
```scala
case class User(id: Long, name: String)
// defined class User
```
从jekyll build
的输出得到的是
<!doctype html>
<html>
<body><h2 id="authentication">Authentication</h2>
<p>Some description.</p>
<div class="language-scala highlighter-rouge"><span class="k">case</span> <span class="k">class</span> <span class="nc">User</span><span class="o">(</span><span class="n">id</span><span class="k">:</span> <span class="kt">Long</span><span class="o">,</span> <span class="n">name</span><span class="k">:</span> <span class="kt">String</span><span class="o">)</span>
<span class="c1">// defined class User
</span></div>
</body>
</html>
这导致未格式化的代码一个长行。在github网站(你可以在这里看到http://http4s.org/docs/0.15/auth.html),html有<pre>
和<code>
元素。就像这样:
<div class="language-scala highlighter-rouge"><pre class="highlight"><code><span class="k">...
因为其他人没有这个问题在本地预览网站,我有同样的麻烦预览http://typelevel.org/cats/,我认为这是某种形式的一些地方的配置问题。但是,我一直无法弄清楚什么。这是我第一次使用jekyll/kramdown,所以我没有经验可以利用。
我已经安装了github-pages
宝石,它给了我jekyll 3.3.1
和kramdown 1.11.1
。
您是否尝试使用tildes(“〜”)而不是反引号(“'”)。不确定它是否有所作为,但它是kramdown文档显示代码块的内容。 – TBB
感谢您的建议,但这并没有帮助。我想真正的问题是,它似乎在github和本地其他用户上工作正常,但它不适合我。 –
这很奇怪。它好像是将块的内容解析为降价。也许尝试删除'parse_block_html:true'? – TBB