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 support for Elvish transcripts. #6302

Merged
merged 5 commits into from
Mar 8, 2023
Merged

Conversation

xiaq
Copy link
Contributor

@xiaq xiaq commented Mar 1, 2023

This adds support for highlighting transcripts of Elvish sessions.

Description

Support for Elvish was accepted in #5940. Because Elvish is a shell language, it is very frequent to not show just Elvish code, but also its outputs. Instead of just:

echo foo

One often needs to show:

~> echo foo
foo

These transcripts are most often used inside the Markdown of (for example) issue comments, and rarely saved to files, so there aren't a lot of those files on GitHub today.

However, my primary goal is to make it possible to use the elvish-transcript language tag on GitHub, and since elvish is already usable as a language tag, I'd argue that it should be supported too. The notability test was passed when Elvish itself was accepted.

I did define a file extension for Elvish transcripts, .elvts, but I am fine if I should drop that.

Checklist:

  • I am adding a new language.
    • The extension of the new language is used in hundreds of repositories on github.com.
      • The .elvts extension is not widely used, see above for explanation.
    • I have included a real-world usage sample for all extensions added in this PR:
    • I have included a syntax highlighting grammar: https://github.com/elves/elvish, already included
    • I have updated the heuristics to distinguish my language from others using the same extension.

@xiaq xiaq requested a review from a team as a code owner March 1, 2023 23:08
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.

We really don't need an extension or sample in this case and can simplify the entry (see inline comment).

Widespread usage is still a consideration which is quite easy to determine as you've stated this will only be used in markdown files or issue comments.

This search shows it is only being used in 135 markdown files so falls a little short on the files side.

Searching issue comments or bodies doesn't seem to indicate it's used that much with only 8 results.

So whilst there is usage, it doesn't appear widely adopted on GitHub yet, though I guess the lack of highlighting might have something to do with that in issues.

Let me sleep on this.

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

xiaq commented Mar 2, 2023

Thanks, applied your suggested change. Also regenerated vendor/README.md and removed the sample.

I wonder though - how does Linguist know that the elvish-transcript language tag in Markdown maps to the source.elvish-transcript scope? Is it just based on the name of the scope? (Also FWIW, the reason I added an interpreter was based on the misunderstanding that it is also used as a language tag.)

So whilst there is usage, it doesn't appear widely adopted on GitHub yet, though I guess the lack of highlighting might have something to do with that in issues.

I definitely agree that the lack of usage currently is because there's no syntax highlighting yet, so people don't bother.

Looking at the first page of open issues in https://github.com/elves/elvish/issues, a lot of comments containing transcripts, but not using the elvish-transcript tag: elves/elvish#1599 (comment), elves/elvish#1603 (comment), elves/elvish#1625 (comment), elves/elvish#1631 (comment), elves/elvish#1641 (comment), elves/elvish#1648 (comment), elves/elvish#1653 (comment), elves/elvish#1654 (comment), elves/elvish#1656 (comment) (the last code block), elves/elvish#1662 (comment). That is about 1/3 of all Elvish issues that has at least one transcript and could benefit from elvish-transcript support. At least in the context of issues the use of Elvish transcripts is already widespread, just not the use of the elvish-transcript tag.

@lildude
Copy link
Member

lildude commented Mar 3, 2023

I wonder though - how does Linguist know that the elvish-transcript language tag in Markdown maps to the source.elvish-transcript scope? Is it just based on the name of the scope?

Linguist doesn't directly handle the codeblocks, markup does, but markup uses the languages and grammars supplied by Linguist.

I gave a brief run down of how this works just yesterday at #6293 (comment) but in short it knows because users tell it and thanks to the entry in the languages.yml file it knows to tell the syntax highlighting engine to use the grammar which has the source.elvish-transcript scope to highlight the blocks:

"The file/codeblock has been identified as 'Elvish Transcript', so Mr Syntax Highlighting Engine, please use the source.elvish-transcript grammar to make it pretty" 😁

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.

Lets go for it.

@lildude lildude merged commit 8db1455 into github-linguist:master Mar 8, 2023
@xiaq
Copy link
Contributor Author

xiaq commented Mar 8, 2023

Awesome, thank you 🥳

@lildude lildude mentioned this pull request Jun 1, 2024
6 tasks
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 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