Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 将Jekyll帖子转换为红地毯_Ruby_Jekyll_Redcarpet - Fatal编程技术网

Ruby 将Jekyll帖子转换为红地毯

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

我编写了一个Jekyll生成器,它解析标记并将生成的HTML编码为JSON。问题是,我的代码块没有被解析。我想这是因为我已经用红地毯风格写了我的降价,但我的生成器没有使用红地毯

在我的生成器中,我有如下内容:

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.