Skip to content
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

Added Ruby string interpolation #583

Merged
merged 3 commits into from Jul 11, 2015

Conversation

Projects
None yet
3 participants
@westonganger
Copy link
Contributor

commented May 23, 2015

The only case it doesnt handle is if the string interpolation is not inside a string

@@ -5,17 +5,33 @@
* constant, builtin, variable, symbol, regex
*/
Prism.languages.ruby = Prism.languages.extend('clike', {
'comment': /#[^\r\n]*(\r?\n|$)/,
'keyword': /\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/,
'comment': /#(?!\{[^\r\n]*?\})[^\r\n]*(\r?\n|$)/g,

This comment has been minimized.

Copy link
@Golmote

Golmote May 25, 2015

Contributor

Please use tabs to indent, not spaces.

Also, why the g flags everywhere? It is not used by Prism.

pattern: /^#\{|\}$/,
alias: 'tag'
},
rest: Prism.languages.extend('ruby')

This comment has been minimized.

Copy link
@Golmote

Golmote May 25, 2015

Contributor

You should use Prism.util.clone instead of extend.

});

Prism.languages.ruby.string = {
pattern: /("|')(\\\n|\\?.)*?\1/,

This comment has been minimized.

Copy link
@Golmote

Golmote May 25, 2015

Contributor

Again, be careful with the indentation. Prism uses tabs, not spaces.

@Golmote

This comment has been minimized.

Copy link
Contributor

commented May 25, 2015

I don't have time to test it right now, but I quickly reviewed the code. Please take a look at my comments ;)

@Golmote

This comment has been minimized.

Copy link
Contributor

commented Jun 12, 2015

I finally got some time to play around with your PR.
I think you could fix the second failure ("Double quoted strings inside of string interpolation") by changing the string pattern to /("|')(#\{[^}]+\}|\\\n|\\?.)*?\1/. What do you think?

@LeaVerou

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2015

@Golmote do you think this is good to merge now?

@Golmote

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2015

Oh, I did not notice the last commit. So yes, it looks good to me now.

Golmote added a commit that referenced this pull request Jul 11, 2015

Merge pull request #583 from westonganger/gh-pages
Added Ruby string interpolation

@Golmote Golmote merged commit c36b123 into PrismJS:gh-pages Jul 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.