Closed Phrogz closed 11 years ago
but I don't want to have to hack the library source code to achieve it.
Mmh, you can just update the Hash:
CodeRay::TokenKinds[:operator] = 'op'
It's not frozen on purpose :-)
I consider it a public API, though it needs to be documented better.
It's not frozen on purpose :-)
I like your answer, but I'm confused by what you wrote, because it doesn't work. It is frozen, currently.
>> require 'coderay'
#=> true
>> CodeRay::TokenKinds[:operator] = 'op'
RuntimeError: can't modify frozen Hash
from (irb):3:in `[]='
from (irb):3
from C:/Ruby193/bin/irb:12:in `<main>'
Did you mean that "It is a mistake that it is frozen, and it will be fixed in a future release"?
Yikes, you're right! I think I froze it for testing once, and then accidently commited this change. Bad idea.
It's supposed to be unfrozen. I'll fix that. (In the meantime, you can try to CodeRay::TokenKinds = CodeRay::TokenKinds.dup
or something.) Would such a fix also solve your request?
Would such a fix also solve your request?
Yup, totally. Thanks!
token_kinds.rb
currently has:operator => false
, which drops operator markup. I'd like to turn this on for my parsing, but I don't want to have to hack the library source code to achieve it.There should be a public interface during parsing that allows someone to override this, or any token/classes.