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

Import: Add apex code hightlight suport #4

Merged
merged 3 commits into from
May 17, 2019

Conversation

pyrmont
Copy link
Owner

@pyrmont pyrmont commented May 10, 2019

Import the "Add apex code hightlight suport jneen#1103" PR.

Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
Signed-off-by: Jefersson Nathan <malukenho.dev@gmail.com>
@pyrmont
Copy link
Owner Author

pyrmont commented May 10, 2019

The filename spec is failing because both Tex and Apex can use the .cls file extension. I'm not sure what the best solution to this problem is.

@pyrmont
Copy link
Owner Author

pyrmont commented May 10, 2019

Possibly relevant.

@pyrmont
Copy link
Owner Author

pyrmont commented May 11, 2019

The solution is:

  1. You need to specify a self.detect? method inside /lib/rouge/lexers/apex.rb file. This method will return true if the string being guessed matches a regex pattern that is unique to Apex class files. You can see an example of the kind of method in the TeX lexer.

  2. In your spec, you need to pass an additional source: argument at this line that is a piece of text from the start of an Apex .cls file. You can see an example of what this looks like in the Prolog spec.

  3. You need to edit the TeX spec to include a similar line here that passes a string that will be recognised by its self.detect? method. I'm not super familiar with TeX but it looks like the string '\ProcessOptions\relax' should work.

@pyrmont pyrmont changed the title Import: Add apex code hightlight suport #1103 Import: Add apex code hightlight suport May 11, 2019
@pyrmont
Copy link
Owner Author

pyrmont commented May 16, 2019

I was incorrect about points 1 and 3 in the earlier message. The correct place to put the disambiguation code is in lib/rouge/guessers/disambiguation.rb. The self.detect? method serves a different purpose.

@pyrmont pyrmont merged commit ecdcdf4 into pyrmont:moulin May 17, 2019
pyrmont added a commit that referenced this pull request May 17, 2019
This commit adds syntax highlighting for the Apex language. Due to the
fact both it and TeX declare an association with the `*.cls` filename
glob, this commit also adds a disambiguation and updates the TeX spec as
necessary to avoid conflicts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants