-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Crystal support #780
Crystal support #780
Conversation
[これ](https://github.com/PrismJS/prism/pull/780)。まだマージされてはいない。マージされるといいなぁ Prism.jsは後読みが使えるから正規表現リテラルがhighlight.jsよりは上手く扱えると思うんだけど、GitHubのプロジェクトのデフォルトのリポジトリが`gh-pages`なのが残念なところ。あとドキュメントがhighlight.jsほどしっかりしてない。 Virtual DOMを生成するシンタックスハイライターが求められている気がする‥‥。
@@ -0,0 +1,54 @@ | |||
(function(Prism) { | |||
Prism.languages.crystal = Prism.languages.extend('ruby', { | |||
number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[0-9a-fA-F_]*[0-9a-fA-F]|(?:[0-9][0-9_]*[0-9]|[0-9])(?:\.[0-9_]*[0-9])?(?:[eE][+-]?[0-9_]*[0-9])?)(?:_[uif](?:8|16|32|64|))?\b/, |
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.
This part (?:[0-9][0-9_]*[0-9]|[0-9])
could probably be rewritten as [0-9](?:[0-9_]*[0-9])?
.
Also, the last group (?:8|16|32|64|)
might be more explicit written as (?:8|16|32|64)?
.
Hi! Thanks for contributing. With example and tests, this is a great PR! Would you mind taking a look at the few comments I made? |
@Golmote Thanks for reviewing my code. I fixed them. |
keyword: [ | ||
/\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|ifdef|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|self|sizeof|struct|super|then|type|typeof|undef|union|unless|until|when|while|with|yield|__DIR__|__FILE__|__LINE__)\b/, | ||
{ | ||
pattern: /(\.\s*)(?:is_a|responds_to)\?/, |
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.
Can you fix the indentation of this line? It needs 4 tabs.
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.
Sorry. I'll fix it. My editor uses spaces as indent. Why doesn't this project use linter or .editorconfig
?
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.
Well, there is no reason. And this is a good idea. I'll definitely think about adding it. ;)
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 just added a basic .editorconfig file. Thanks for suggesting this.
Thanks. For some reason, the indentation of one line went crazy, can you check it out? Once this is fixed, I can merge the PR. |
4916ab6
to
239b95f
Compare
I added Crystal language definition, tests and examples.