Class: Rouge::RegexLexer
- Inherits:
-
Object
- Object
- Rouge::RegexLexer
- Defined in:
- lib/blusher/shim.rb
Instance Method Summary collapse
Instance Method Details
#__blusher_rouge_lex ⇒ Object
86 |
# File 'lib/blusher/shim.rb', line 86 alias_method :__blusher_rouge_lex, :lex |
#lex(string, opts = nil, &b) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/blusher/shim.rb', line 88 def lex(string, opts = nil, &b) tag = self.class.tag # :continue (incremental relex) isn't expressible against carmine — and # non-routable lexers gain nothing — so hand those straight to rouge. return __blusher_rouge_lex(string, opts, &b) if (opts && opts[:continue]) || !Blusher::Shim.routable?(tag) if b # Block form (the caller wants tokens now): lex via carmine and stream. toks = Blusher::Native.lex(tag, Blusher::Shim.table_for(tag), string, Blusher::Shim::QUALNAME) return toks ? toks.each(&b) : __blusher_rouge_lex(string, opts, &b) end # No block: defer, so HTML#format can fuse lex+format in Rust. Blusher::Shim::TokenStream.new(self, string) end |