简单杰基尔转换器插件不工作
问题描述:
我试图创建一个简单的哲基尔转换器插件,它是Converter Plugin in the Jekyll Documentation几乎完全克隆,但它似乎不工作:简单杰基尔转换器插件不工作
module Jekyll
class MyConverter < Converter
safe false
priority :high
def matches(ext)
ext =~ /^\.(md|markdown)$/i
end
def output_ext(ext)
".html"
end
def convert(content)
content.upcase
end
end
end
我已经放在这个文件my_converter.rb
进入我的_plugins
目录。
现在,当我做bundle exec jekyll serve
时,我希望看到呈现为HTML的每个降价页面的内容都将转换为大写。但是,似乎没有发生。
我错过了什么? (我是Ruby新手,顺便说一句)
答
问题解决了。事实证明,上述代码没有任何问题。
问题是,在某些时候,github页面的宝石已被添加到我们的Gemfile(不需要)。显然,用github-plugin插件,Jekyll is always started in safe mode and the plugin_dir
is a random string。
从我们的Gemfile中删除github页面gem修复了它!
PS,我已经尝试了这个SO回答中的建议(将我预处理过的'content'字符串提供给默认的Markdown转换器),无济于事。 https://*.com/questions/22761691/how-to-pass-content-to-jekyll-default-converter-after-custom-conversion –