相关疑难解决方法(0)

如何使用液体标签访问Jekyll中的未渲染(降价)内容?

通过阅读文档Jekyll的模板数据,人们可能会认为访问未呈现内容的方式是page.content; 但据我所知,这是提供已经由降价解析器呈现的帖子的内容.

我需要一个直接访问原始(原始降价)内容的解决方案,而不是简单地尝试将html转换回markdown.

用例背景

我的用例如下:我使用pandoc插件为我的Jekyll站点渲染markdown,使用'mathjax'选项获得漂亮的方程式.但是,mathjax需要javascript,所以这些不会显示在RSS feed中,我通过循环生成它,page.content如下所示:

 {% for post in site.posts %}
 <entry>
   <title>{{ post.title }}</title>
   <link href="{{ site.production_url }}{{ post.url }}"/>
   <updated>{{ post.date | date_to_xmlschema }}</updated>
   <id>{{ site.production_url }}{{ post.id }}</id>
   <content type="html">{{ post.content | xml_escape }}</content>
 </entry>
 {% endfor %}
Run Code Online (Sandbox Code Playgroud)

xml_escape过滤器所示,post.content这里出现在html中.如果我可以获得原始内容(想象post.contentraw或存在),那么我可以轻松地添加一个过滤器,该过滤器将使用pandoc和"webtex"选项在解析RSS源时为方程生成图像,例如:

require 'pandoc-ruby'
module TextFilter
  def webtex(input)
    PandocRuby.new(input, "webtex").to_html
  end
end
Liquid::Template.register_filter(TextFilter)
Run Code Online (Sandbox Code Playgroud)

但是当我对已经在html + mathjax中呈现的方程式而不是原始markdown的内容感到满意时,我就被卡住了.转换回markdown没有帮助,因为它不会转换mathjax(只是简单地加油).

有什么建议?当然有一种方法可以调用原始降价吗?

markdown liquid jekyll mathjax pandoc

10
推荐指数
1
解决办法
2378
查看次数

标签 统计

jekyll ×1

liquid ×1

markdown ×1

mathjax ×1

pandoc ×1