【发布时间】:2015-10-14 03:51:15
【问题描述】:
我正在为基于 Jekyll 的网站编写 Redcarpet 扩展程序。我想使用{x|y} 作为markdown 中的一个标签,它评估为HTML <ruby> 标签(及其关联)。我按照Jekyll's guide、Redcarpet's guide 和this guide 编写了这个类,说明如何这样做:
class Jekyll::Converters::Markdown::HotelDown < Redcarpet::Render::HTML
def preprocess(doc)
s = "<ruby><rb>\\1</rb><rp>(</rp><rt>\\2</rt><rp>)</rp></ruby>"
doc.gsub!(/\[([\s\S]+)\|([\s\S]+)\]/, s)
doc
end
end
但是,当我运行 bundle exec jekyll serve 时,我似乎遇到了一些错误:
Configuration file: C:/Users/Alex/OneDrive/codes/hotelc.me/hotelc.me/_config.yml
plugin_manager.rb:58:in `require': HotelDown.rb:4: syntax error, unexpected tIDENTIFIER, expecting ')' (SyntaxError)
doc.gs-ub!(/\[([\-s\S]+)\|([-\s\S]+)\]/-, s)
^
HotelDown.rb:4: syntax error, unexpected ')', expecting '='
doc.gs-ub!(/\[([\-s\S]+)\|([-\s\S]+)\]/-, s)
^
我的语法似乎有问题(多余的空格、缺少括号或类似的东西)。有什么我错过的吗?
【问题讨论】:
标签: ruby markdown jekyll redcarpet