-
Notifications
You must be signed in to change notification settings - Fork 112
Term encoder still has problems with nested tokens #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Awesome :-) From your examples, I guess that you looked at the Terminal encoder. It is not a good reference of how token kinds are used. Instead, I suggest you look at
That's because escape sequences like The Terminal encode should highlight
PHP, Python, C, and even SQL use modifiers for strings to mark them as binary, Unicode, wchar_t or something else.
Can you explain more? What output do you get, and which one did you expect? |
I did look at the Terminal encoder. Although
For example, I have the following string: However, when you remove a color value of |
Code interpolations inside of strings should be an
There is no I'm sorry that there is no description of the token kind semantic right now ^_^ Maybe I can find the time to write an article about that. Feel free to ask if you run into more unexpected behavior. |
Yes, the "connection" between my program and CodeRay is established via
It would be great. Thank you for the answers. Currently, I have no questions left. Thanks! |
It looks like Example:
So instead of having a blue color for My question: how to separate apples from oranges? I want to get |
The Terminal encoder is not able to work with tokens nested deeper than 2 levels, as far as I know (it's not my implementation, but Rob Aldred's = @raldred, I believe). If you want to have this functionality, you have to fix/enhance the Terminal encoder. I recommend branching off or copying it. The CodeRay library contains no code to interpret all possible token nestings; rather, that's left to the browser in the form of HTML+CSS. Since the terminal has no concept of colors applied to nested spans of text, you would need to recreate quite a bit of browser layout logic. Or you find something that converts HTML+CSS to ANSI colored text. |
But they are not nested: https://github.com/rubychan/coderay/blob/master/lib/coderay/styles/alpha.rb#L85-86 |
They are, in the HTML code, and also in the token structure. The Debug encoder is helpful here: puts CodeRay.scan('"#{foo} bar"', :ruby).debug
#=> string<delimiter(")inline<inline_delimiter(#{)ident(foo)inline_delimiter(})>content( bar)delimiter(")>
|
OK, thank you :) I'll keep this issue open, if you don't mind (maybe someone wants to fix the nesting problems). |
From Redmine: http://odd-eyed-code.org/issues/145 |
Changed the title subtly. |
Hey. I'm developing a Ruby terminal application on top of CodeRay and I'm having troubles with understanding of
string
,regexp
andshell
attributes.What is regexp
function
? Why doesself
sub-attribute set a color value for\d
,\w
,\b
and so on?Why does
self
sub-attribute set a color value for escape sequences like\n
,\t
and so on?Why does
self
sub-attribute set a color value for escape sequences like\n
,\t
and so on? What is a stringmodifier
? Why doesescape
sub-attribute not set a color for escape sequences?The text was updated successfully, but these errors were encountered: