生成博客时,octopress image_tag插件中的SyntaxError

时间:2012-11-19 20:48:18

标签: ruby jekyll octopress

我使用octopress作为我的技术博客。我从官方章鱼回购中更新了我的章鱼代码,当我运行rake generate时出现错误:

 |1.9.3-p194| home in ~/Documents/work/git/muratcorlu.github.com
± |source ✓| → rake generate
## Generating Site with Jekyll
directory source/stylesheets/ 
   create source/stylesheets/screen.css 
Configuration from /Users/muratcorlu/Documents/work/git/muratcorlu.github.com/_config.yml
/Users/muratcorlu/Documents/work/git/muratcorlu.github.com/plugins/category_generator.rb:109: warning: regexp has invalid interval
/Users/muratcorlu/Documents/work/git/muratcorlu.github.com/plugins/category_generator.rb:109: warning: regexp has `}' without escape
/Users/muratcorlu/Documents/work/git/muratcorlu.github.com/plugins/category_generator.rb:146: warning: regexp has invalid interval
/Users/muratcorlu/Documents/work/git/muratcorlu.github.com/plugins/category_generator.rb:146: warning: regexp has `}' without escape
/Library/Ruby/Gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:76:in `require': /Users/muratcorlu/Documents/work/git/muratcorlu.github.com/plugins/image_tag.rb:27: undefined (?...) sequence: /(?<class>\S.*\s+)?(?<src>(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?<width>\d+))?(?:\s+(?<height>\d+))?(?<title>\s+.+)?/ (SyntaxError)
/Users/muratcorlu/Documents/work/git/muratcorlu.github.com/plugins/image_tag.rb:29: undefined (?...) sequence: /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/
    from /Library/Ruby/Gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:76:in `setup'
    from /Library/Ruby/Gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:75:in `each'
    from /Library/Ruby/Gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:75:in `setup'
    from /Library/Ruby/Gems/1.8/gems/jekyll-0.11.2/bin/../lib/jekyll/site.rb:30:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/jekyll-0.11.2/bin/jekyll:224:in `new'
    from /Library/Ruby/Gems/1.8/gems/jekyll-0.11.2/bin/jekyll:224
    from /usr/bin/jekyll:23:in `load'
    from /usr/bin/jekyll:23

有什么问题?

1 个答案:

答案 0 :(得分:1)

首先我在irb中尝试了RegEx:

$ irb
irb(main):001:0> /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/
=> /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/
irb(main):002:0> 

我没有错误,但后来我发现服务器上的默认ruby版本是1.8.7。

我从rvm中选择了ruby-1.9.3-p551并将其激活。

我做了以下事情:

rvm use ruby-1.9.3-p551
bundle install
bundle exec rake generate

这解决了我的错误。