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

F# support #286

Merged
merged 6 commits into from Jul 18, 2016
Merged

F# support #286

merged 6 commits into from Jul 18, 2016

Conversation

raymens
Copy link
Contributor

@raymens raymens commented Jul 13, 2015

A start of adding F# support to Rouge. Related issue: #285.

Cloned and renamed the OCaml files for a start of the FSharp lexer, so a big thanks to the person that provided the OCaml bindings.
Now I'm trying to actually run this whole thing as I'm new to Ruby so I can check the output and make adjustments.

@raymens raymens changed the title [WIP] FSharp support [WIP] F# support Jul 13, 2015
@DavidArno
Copy link

@raymens,

Did you give up on this, or was it completed elsewhere? Thanks.

@raymens
Copy link
Contributor Author

raymens commented May 9, 2016

I forgot about this. I'll update it soon to at least have basic support

Cloned and renamed the OCaml files for a start of the FSharp lexer
@jneen
Copy link
Member

jneen commented Jun 3, 2016

Hey @raymens, any update on this branch? If not I can see if someone else is willing to implement the F# lexer.

@jneen jneen added lexer-request A request for a lexer to be developed. needs-review The PR needs to be reviewed labels Jun 3, 2016
@raymens
Copy link
Contributor Author

raymens commented Jun 3, 2016

One of the tests is failing and I haven't figured out why yet. But if someone can complete this work that's totally fine with me.

@nickbabcock
Copy link
Contributor

This patch will fix the test because *.fs is ambiguous between glsl files and f# files. Since *.fs is a secondary extension for shaders, F# should have the priority here.

diff --git a/lib/rouge/lexers/glsl.rb b/lib/rouge/lexers/glsl.rb
index 792706a..bff3674 100644
--- a/lib/rouge/lexers/glsl.rb
+++ b/lib/rouge/lexers/glsl.rb
@@ -10,7 +10,7 @@ module Rouge
     # Author: Sri Harsha Chilakapati
     class Glsl < C
       tag 'glsl'
-      filenames '*.glsl', '*.frag', '*.vert', '*.geom', '*.fs', '*.vs', '*.gs', '*.shader'
+      filenames '*.glsl', '*.frag', '*.vert', '*.geom', '*.vs', '*.gs', '*.shader'
       mimetypes 'x-shader/x-vertex', 'x-shader/x-fragment', 'x-shader/x-geometry'

       title "GLSL"

@jneen
Copy link
Member

jneen commented Jun 15, 2016

Agreed.

@raymens
Copy link
Contributor Author

raymens commented Jun 16, 2016

Thanks @nickbabcock . This fixes the tests. Using rackup there seems to still be some errors around the // comments

@nickbabcock
Copy link
Contributor

Patch fixes the // issue

diff --git a/lib/rouge/lexers/fsharp.rb b/lib/rouge/lexers/fsharp.rb
index 928ff61..e8e6be0 100644
--- a/lib/rouge/lexers/fsharp.rb
+++ b/lib/rouge/lexers/fsharp.rb
@@ -50,6 +50,7 @@ module Rouge
         rule /#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
         rule upper_id, Name::Class
         rule /[(][*](?![)])/, Comment, :comment
+        rule %r(//.*?\n), Comment::Single
         rule id do |m|
           match = m[0]
           if self.class.keywords.include? match

Not 100% sure it's optimal but it looks good to me 😄

@raymens
Copy link
Contributor Author

raymens commented Jun 16, 2016

I tried putting that in the :comment but that seemed to break the multi-line comments. Thanks @nickbabcock . Looks pretty good now!

@nickbabcock
Copy link
Contributor

Everything rendered beautifully on my end. @jneen, looks like this PR is ready for your review/blessing

@raymens raymens changed the title [WIP] F# support F# support Jul 1, 2016
@raymens raymens mentioned this pull request Jul 18, 2016
@jneen
Copy link
Member

jneen commented Jul 18, 2016

Thanks for your work, sorry about the delay. This looks great.

@jneen jneen merged commit fc15272 into rouge-ruby:master Jul 18, 2016
@kmadof
Copy link

kmadof commented Dec 13, 2016

What should I do to have fsharp syntax working on Jekyll page hosted on GitHub Pages?

@connelhooley
Copy link

I'd also like to have F Sharp Syntax highlighting in Jekyll. Is there any progress on this? Looks like this has been awaiting review quite a while.

@nickbabcock
Copy link
Contributor

Allowing rouge 2.0 (and thus F#) in jekyll is being tracked in a jekyll PR. You may feel free to try out that jekyll branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lexer-request A request for a lexer to be developed. needs-review The PR needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants