rubychan / coderay

Fast and easy syntax highlighting for selected languages, written in Ruby.
http://coderay.rubychan.de/
Other
847 stars 115 forks source link

Many warnings for the same missing scanner in the same session #129

Closed Phrogz closed 11 years ago

Phrogz commented 11 years ago

I am converting many small Markdown snippets using kramdown+CodeRay.

def convert(markdown)
  Kramdown::Document.new(markdown, coderay_line_numbers:nil, coderay_css: :class).to_html
end

Each time there is a code block tagged with the Lua language I get:

CodeRay::Scanners could not load plugin :lua; falling back to :text

As a result my automated script for generating documentation is spitting out ~100 lines on stderr where one would suffice.

It would be nice if this warning could only be emitted once per language per process. Would you accept a patch for this, e.g. storing an instance variable on CodeRay::PluginHost referencing a hash of languages that have been warned about?

korny commented 11 years ago

It would be nice if this warning could only be emitted once per language per process.

Good idea. Can you make a PR?

Phrogz commented 11 years ago

Will do. (Now that I've locally added support for Lua, this is a much lower priority for me, though. ;)

Phrogz commented 11 years ago

BTW, I tried to figure out how to make a test for this, but couldn't figure it out. I'll probably PR without one.

korny commented 11 years ago

There's an assert_warning helper somewhere.

korny commented 11 years ago

I just disabled the warning completely. If we define a :default in the _map.rb file, it expresses intent to have a fallback instead of an error: Scanners fall back to plain text, while Encoders will raise an error.