sapling icon indicating copy to clipboard operation
sapling copied to clipboard

[docs] add sl-shell-example syntax-highlighting language

Open shish opened this issue 3 years ago • 10 comments

Stack created with [Sapling]

  • #270
  • #267
  • #266
  • -> #264

[docs] add sl-shell-example syntax-highlighting language

Summary: Right now the example sl sessions have no hightlighting, or sometimes they pretend to be bash, which kind-of-half-works but also half doesn't work and is ugly (See the "Before" example - there is random highlighting for some numbers in the middle of command output, the ".." in "..." is randomly highlighted as a directory, etc)

This diff adds a new custom Prism language called "sl-shell-example" which does syntax highlighting specifically tailored for our example sessions with these main parts:

# comment
$ shell command
~/my/subdir $ shell command in a specific subdirectory
output
Screenshot 2022-11-24 at 16 15 08

(For the record, Prism already has a language called "shell-session", but that language doesn't support comments (which is something we make heavy use of), and also it tries to be clever by highlighting random words in the middle of shell commands (which is just distracting in the context of sapling docs))

Test Plan:

Before: Screenshot 2022-11-24 at 15 54 27

After: Screenshot 2022-11-24 at 15 54 39

shish avatar Nov 24 '22 15:11 shish

If somebody is some kind of regex-genius it might even be possible to automatically highlight smartlog examples, but I'll leave that as an exercise for the reader (or my future self :) )

shish avatar Nov 24 '22 16:11 shish

@mzr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Nov 24 '22 17:11 facebook-github-bot

Thanks for the PR! LGTM, but one nit from me. Can we change sl-session to something like sl-shell-example? IMO it better reflects what it really is, and it is also similar to the original shell-session in Prism.

mzr avatar Nov 24 '22 17:11 mzr

@shish has updated the pull request. You must reimport the pull request before landing.

facebook-github-bot avatar Nov 24 '22 17:11 facebook-github-bot

@shish has updated the pull request. You must reimport the pull request before landing.

facebook-github-bot avatar Nov 24 '22 17:11 facebook-github-bot

@shish has updated the pull request. You must reimport the pull request before landing.

facebook-github-bot avatar Nov 24 '22 17:11 facebook-github-bot

Can we change sl-session to something like sl-shell-example?

Done :)

shish avatar Nov 24 '22 17:11 shish

@mzr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Nov 24 '22 17:11 facebook-github-bot

@shish has updated the pull request. You must reimport the pull request before landing.

facebook-github-bot avatar Nov 24 '22 20:11 facebook-github-bot

@shish has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Nov 24 '22 20:11 facebook-github-bot