bdesham / reading_time

A Liquid filter to estimate how long a passage of text will take to read.
ISC License
120 stars 5 forks source link

Parse Exception: Missing end tag for 'img' #1

Closed WillsB3 closed 11 years ago

WillsB3 commented 11 years ago

Hi,

I'm trying to use this plugin in conjunction with Jekyll Picture Tag. I've got the picture tag plugin setup and working fine, but when I added this plugin I get errors in the console and the reading time isn't rendered.

Here's a sample error from my console:

Liquid Exception: #<REXML::ParseException: Missing end tag for 'img' (got "noscript") Line: 27 Position: 4365 Last 80 unconsumed characters: > /Users/Wills/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:335:inpull_event' /Users/Wills/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:183:in pull' /Users/Wills/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:22:inparse' /Users/Wills/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/document.rb:245:in build' /Users/Wills/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rexml/document.rb:43:ininitialize' /Users/Wills/Sites/Projects/Personal/Rather Semantic - Jekyll/_plugins/reading_time.rb:30:in new' /Users/Wills/Sites/Projects/Personal/Rather Semantic - Jekyll/_plugins/reading_time.rb:30:inwords' /Users/Wills/Sites/Projects/Personal/Rather Semantic - Jekyll/_plugins/reading_time.rb:7:in count_words' /Users/Wills/Sites/Projects/Personal/Rather Semantic - Jekyll/_plugins/reading_time.rb:11:inreading_time' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/strainer.rb:43:in invoke' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/context.rb:75:ininvoke' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/variable.rb:50:in block in render' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/variable.rb:38:ineach' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/variable.rb:38:in inject' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/variable.rb:38:inrender' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/block.rb:106:in block in render_all' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/block.rb:93:ineach' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/block.rb:93:in render_all' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/block.rb:82:inrender' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/template.rb:124:in render' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/liquid-2.5.1/lib/liquid/template.rb:132:inrender!' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/convertible.rb:81:in render_liquid' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/convertible.rb:102:inrender_all_layouts' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/convertible.rb:137:in do_layout' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/post.rb:260:inrender' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/site.rb:213:in block in render' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/site.rb:212:ineach' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/site.rb:212:in render' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/site.rb:44:inprocess' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/command.rb:18:in process_site' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/jekyll-1.1.2/lib/jekyll/commands/build.rb:47:inblock in watch' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:580:in call' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:580:inblock in notify_observers' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:579:in each' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:579:innotify_observers' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher.rb:334:in block in initialize' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:224:incall' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:224:in notify' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:102:inrun_once' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:150:in run_loop' /Users/Wills/.rvm/gems/ruby-1.9.3-p448@rathersemantic/gems/directory_watcher-1.4.1/lib/directory_watcher/scanner.rb:45:inblock in start' ... Missing end tag for 'img' (got "noscript") Line: 27 Position: 4365 Last 80 unconsumed characters: Line: 27 Position: 4365 Last 80 unconsumed characters: in post.html`

I've run my generated pages markup through HTML5 Validator and I get no relevant warnings or errors.

P.S - Apologies for the crazy single-line paste, but I'm not sure how else to format the error!

bdesham commented 11 years ago

The cause of this problem is that Jekyll Picture Tag is (quite reasonably) generating an img tag that isn’t self-closing, and so when reading_time tries to use an XML parser to look at your page’s source the parser barfs. I suspect the best solution will be to switch from REXML to a more forgiving, Beautiful Soup–like HTML parser. I’ll look into it.

WillsB3 commented 11 years ago

Great :+1:

bdesham commented 11 years ago

Fixed in 1.1.0.