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

Add Julia REPL #6859

Merged
merged 5 commits into from
Jun 7, 2024
Merged

Add Julia REPL #6859

merged 5 commits into from
Jun 7, 2024

Conversation

adrhill
Copy link
Contributor

@adrhill adrhill commented May 29, 2024

This is a draft PR to add syntax highlighting to the Julia REPL mode julia-repl.

What is it?

The Julia programming language has an interactive read–eval–print loop (REPL) that requires custom syntax highlighting. Julia's documentation tools distinguish between julia-repl and julia code blocks for markdown syntax highlighting.

  • Julia Code vs. Julia REPL. Note the green julia> prompt and output:
    image

  • Example of Julia REPL syntax highlighting in the Julia documentation:
    image

Why is it needed?

Since the REPL is used to install and demonstrate packages, julia-repl code blocks are widely used in GitHub READMEs, as seen in the 560 results here. Outside of READMEs, julia-repl is used more than 10.000 times in code.
However, GitHub doesn't recognize julia-repl markdown code blocks, only julia.

  • julia codeblock:
    n = 1
    foo(x) = 2*x
    foo(n)
  • julia-repl codeblock:
    julia> n = 1
    1
    
    julia> foo(x) = 2*x
    foo (generic function with 1 method)
    
    julia> foo(n)
    2

Description

Interestingly, a Julia REPL grammar already exists in linguist as julia.console:

I wasn't sure on how to add this to languages.yml, since the Julia REPL mode isn't a programming language by itself and therefore doesn't have a custom file type.

I would love to get some guidance on how to get julia-repl markdown blocks working on GitHub.

Checklist:

  • I am adding a new language.

@adrhill adrhill marked this pull request as ready for review May 29, 2024 15:18
@adrhill adrhill requested a review from a team as a code owner May 29, 2024 15:18
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is good and similar to what was done in #6302 for Elvish transcripts.

You're also going to need to update the grammars README.md (the test will fail if you don't).

lib/linguist/languages.yml Outdated Show resolved Hide resolved
@adrhill
Copy link
Contributor Author

adrhill commented Jun 3, 2024

The test failure says:

1) Failure:
TestLanguage#test_all_languages_have_a_valid_ace_mode [test/test_language.rb:422]:
The following languages do not have an Ace mode listed in languages.yml. Please add an Ace mode for all new languages.
If no Ace mode exists for a language, mark the language with `ace_mode: text` in lib/linguist/languages.yml.
Julia REPL 

Should I add ace_mode: text or ace_mode: julia?

@lildude
Copy link
Member

lildude commented Jun 3, 2024

Should I add ace_mode: text or ace_mode: julia?

Top of that file has your answer 😉

# ace_mode - A String name of the Ace Mode used for highlighting whenever
# a file is edited. This must match one of the filenames in https://gh.io/acemodes.
# Use "text" if a mode does not exist.

@adrhill adrhill requested a review from lildude June 3, 2024 16:52
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

Note: this PR will not be merged until close to when the next release is made. See here for more details.

@adrhill
Copy link
Contributor Author

adrhill commented Jun 6, 2024

Awesome! Thanks for the guidance. :)

@lildude lildude added this pull request to the merge queue Jun 7, 2024
Merged via the queue into github-linguist:master with commit 117012a Jun 7, 2024
5 checks passed
@adrhill adrhill deleted the ah/julia-repl branch June 7, 2024 11:25
@adrhill
Copy link
Contributor Author

adrhill commented Jun 10, 2024

Now online #6870 (comment)! 🥳

n = 1
foo(x) = 2*x
foo(n)
julia> n = 1
1

julia> foo(x) = 2*x
foo (generic function with 1 method)

julia> foo(n)
2

@Kikki005 Kikki005 mentioned this pull request Jun 11, 2024
6 tasks
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants