diff --git a/lib/rouge/lexer.rb b/lib/rouge/lexer.rb index ca6b87ee44..5f4160dbe0 100644 --- a/lib/rouge/lexer.rb +++ b/lib/rouge/lexer.rb @@ -421,17 +421,29 @@ def reset! # @option opts :continue # Continue the lex from the previous state (i.e. don't call #reset!) # - # @note The use of `opts` has been deprecated. A warning is issued if run - # with `$VERBOSE` set to true. - def lex(string, opts={}, &b) - unless opts.nil? - warn 'The use of opts with Lexer.lex is deprecated' if $VERBOSE + # @note The use of :continue => true has been deprecated. A warning is + # issued if run with `$VERBOSE` set to true. + # + # @note The use of arbitrary `opts` has never been supported, but we + # previously ignored them with no error. We now warn unconditionally. + def lex(string, opts=nil, &b) + if opts + if (opts.keys - [:continue]).size > 0 + # improper use of options hash + warn('Improper use of Lexer#lex - this method does not receive options.' + + ' This will become an error in a future version.') + end + + if opts[:continue] + warn '`lex :continue => true` is deprecated, please use #continue_lex instead' + return continue_lex(string, &b) + end end - return enum_for(:lex, string, opts) unless block_given? + return enum_for(:lex, string) unless block_given? Lexer.assert_utf8!(string) - reset! unless opts[:continue] + reset! continue_lex(string, &b) end