Jekyll 不解释 Markdown

发布于 2024-12-25 14:23:56 字数 1401 浏览 4 评论 0原文

我正在使用 jekyll.rb 创建网站。
我有一个名为 about.html 的页面:

<div class="grid_10 page">
    {% include about_content.markdown %}
</div>

在 about_content.markdown 中,我有一些虚拟的 markdown:

A First Level Header
====================

A Second Level Header
---------------------

Hello!

由于某种原因,当呈现页面时,结果是这样的:

结果http://gabrielecirulli.com/p/20120107-203135.png

即使我将 YAML 前面的内容添加到我的 Markdown 文件中,也不会发生任何变化。

这是我的 _config.yml

safe:        false
auto:        false
server:      false
server_port: 4000
baseurl:    /

source:      .
destination: ./_site
plugins:     ./_plugins

future:      true
lsi:         false
pygments:    false
markdown:    maruku
permalink:   date

maruku:
  use_tex:    false
  use_divs:   false
  png_engine: blahtex
  png_dir:    images/latex
  png_url:    /images/latex

rdiscount:
  extensions: []

kramdown:
  auto_ids: true,
  footnote_nr: 1
  entity_output: as_char
  toc_levels: 1..6
  use_coderay: false

  coderay:
    coderay_wrap: div
    coderay_line_numbers: inline
    coderay_line_numbers_start: 1
    coderay_tab_width: 4
    coderay_bold_every: 10
    coderay_css: style

如何让 jekyll 解释 markdown?

I'm creating a site using jekyll.rb.
I have a page called about.html:

<div class="grid_10 page">
    {% include about_content.markdown %}
</div>

In about_content.markdown I have some dummy markdown:

A First Level Header
====================

A Second Level Header
---------------------

Hello!

For some reason, when the page is rendered, the result is this:

result http://gabrielecirulli.com/p/20120107-203135.png

Even if I add the YAML front matter to my markdown file nothing changes.

This is my _config.yml

safe:        false
auto:        false
server:      false
server_port: 4000
baseurl:    /

source:      .
destination: ./_site
plugins:     ./_plugins

future:      true
lsi:         false
pygments:    false
markdown:    maruku
permalink:   date

maruku:
  use_tex:    false
  use_divs:   false
  png_engine: blahtex
  png_dir:    images/latex
  png_url:    /images/latex

rdiscount:
  extensions: []

kramdown:
  auto_ids: true,
  footnote_nr: 1
  entity_output: as_char
  toc_levels: 1..6
  use_coderay: false

  coderay:
    coderay_wrap: div
    coderay_line_numbers: inline
    coderay_line_numbers_start: 1
    coderay_tab_width: 4
    coderay_bold_every: 10
    coderay_css: style

How can I make jekyll interpret markdown?

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

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

发布评论

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

评论(1

回心转意 2025-01-01 14:23:56

您必须将其通过 markdownify 过滤器:

<div class="grid_10 page">
  {% capture about_content %}
    {% include about_content.markdown %}
  {% endcapture %}
  {{ about_content | unindent | markdownify }}
</div>

为了保持 Markdown 代码缩进,但在 markdownification 之前删除缩进,我会编写一个专用插件,例如 _plugins/unindent.rb< /代码>:

module Jekyll
  module UnindentFilter
    def unindent input
      input.lstrip
    end
  end
end

Liquid::Template.register_filter Jekyll::UnindentFilter

You will have to pass it through the markdownify filter:

<div class="grid_10 page">
  {% capture about_content %}
    {% include about_content.markdown %}
  {% endcapture %}
  {{ about_content | unindent | markdownify }}
</div>

To keep the Markdown code indented but remove the indentation before markdownification, I would write a dedicated plugin, called for example _plugins/unindent.rb:

module Jekyll
  module UnindentFilter
    def unindent input
      input.lstrip
    end
  end
end

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