【发布时间】:2020-06-26 16:36:34
【问题描述】:
通过阅读documentation Jekyll's template data,人们可能会认为访问未渲染内容的方式是page.content;但据我所知,这是提供降价解析器已经呈现的帖子内容。
我需要一个直接访问原始(原始降价)内容的解决方案,而不是简单地尝试将 html 转换回降价。
用例背景
我的用例如下:我使用pandoc plugin 为我的 Jekyll 网站呈现 markdown,使用“mathjax”选项来获得漂亮的方程式。但是,mathjax 需要 javascript,因此这些不会显示在 RSS 提要中,我通过循环 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 %}
正如xml_escape 过滤器所暗示的那样,post.content 出现在 html 中。如果我能获得原始内容(想象post.contentraw 或类似的存在),那么我可以轻松添加一个过滤器,该过滤器将使用带有“webtex”选项的 pandoc 在解析 RSS 提要时为方程式生成图像,例如:
require 'pandoc-ruby'
module TextFilter
def webtex(input)
PandocRuby.new(input, "webtex").to_html
end
end
Liquid::Template.register_filter(TextFilter)
但是当我得到已经在 html+mathjax 中呈现的方程式而不是原始降价时,我被卡住了。转换回降价并没有帮助,因为它不会转换 mathjax(只是乱码)。
有什么建议吗?当然有一种方法可以调用原始降价?
【问题讨论】:
-
解决我的用例的一种完全不同的方式在这里:stackoverflow.com/questions/13166112,尽管它没有解决如何访问原始降价。
标签: markdown jekyll liquid mathjax pandoc