Ruby 将Jekyll帖子转换为红地毯
我编写了一个Jekyll生成器,它解析标记并将生成的HTML编码为JSON。问题是,我的代码块没有被解析。我想这是因为我已经用红地毯风格写了我的降价,但我的生成器没有使用红地毯 在我的生成器中,我有如下内容:Ruby 将Jekyll帖子转换为红地毯,ruby,jekyll,redcarpet,Ruby,Jekyll,Redcarpet,我编写了一个Jekyll生成器,它解析标记并将生成的HTML编码为JSON。问题是,我的代码块没有被解析。我想这是因为我已经用红地毯风格写了我的降价,但我的生成器没有使用红地毯 在我的生成器中,我有如下内容: module Jekyll require 'json' class JSONGenerator < Generator safe true priority :low def generate(site) # Converter fo
module Jekyll
require 'json'
class JSONGenerator < Generator
safe true
priority :low
def generate(site)
# Converter for .md > .html
converter = site.getConverterImpl(Jekyll::Converters::Markdown)
# Iterate over all posts
site.posts.each do |post|
# Encode the HTML to JSON
hash = { "content" => converter.convert(post.content)}
end
end
end
end
。。。但引发了此异常:
Warning: Command failed: error: uninitialized constant Jekyll::JSONGenerator::Redcarpet.
看来在Jekyll中使用Red地毯的方法是实例化该类,并传入
site.config
converter=Jekyll::Converters::Markdown::redruffarser.new(site.config)
Warning: Command failed: error: uninitialized constant Jekyll::JSONGenerator::Redcarpet.