-
Notifications
You must be signed in to change notification settings - Fork 738
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
Minor fixes for HTML, CSS and JavaScript #916
Conversation
Fix HTML: space is allowed before and after equal signs Fix JS: allows \n as a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One simple question, given my lack of JS experience. Otherwise, looks good. Thanks @miparnisari
lib/rouge/lexers/javascript.rb
Outdated
@@ -206,6 +206,7 @@ def self.id_regex | |||
|
|||
state :dq do | |||
rule /[^\\"]+/, Str::Double | |||
rule /\\n/, Str::Double |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no JS expert so forgive me if this is silly. In JS, does the \n
come out of the string exactly as is, or is it interpreted as a newline? For example, in Ruby:
# This would output a literal `\n` in the string. Would not be interpreted as a newline
single_str = 'This is a string\n'
# This would output a string with an actual newline.
double_str = "This is a string\n"
If JS treats the \n
as Ruby does with single quotes then the ways it's written in this PR is perfect. If JS actually interprets it as a newline as in Ruby with double quotes, then it may be nice to change the token to Str::Escape
so it's highlighted differently than surrounding text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, JS outputs an actual newline in both cases, so it's like Ruby with double quote. I'll fix this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
Thanks @miparnisari |
Fix CSS: space is allowed between
!
andimportant
Fix HTML: space is allowed before and after equal signs for attributes
Fix JS: allows
\n
as a string