pursuit icon indicating copy to clipboard operation
pursuit copied to clipboard

PureScript code highlighting

Open hdgarrood opened this issue 10 years ago • 7 comments

For example: http://pursuit.purescript.org/packages/purescript-benchotron/2.1.0

I think we can improve on the GitHub highlighter too (pygments?). I really don't like how it highlights random common functions or types, like foldr and Array.

hdgarrood avatar Jul 15 '15 21:07 hdgarrood

:+1: Would you a highlighter in JavaScript or in Haskell? I think there are good options for both. Agreed re:Pygments by the way :)

paf31 avatar Jul 15 '15 21:07 paf31

I forgot that we are currently using GitHub for readme rendering. I don't really want to change that, since people might use formats other than markdown for their readmes.

GitHub is serving the readme HTML with classes on it for highlighting purposes already, so we could achieve highlighting on readmes just by adding some style rules for those classes.

Perhaps I could look at fixing the pygments purescript highlighter first? I suspect most code examples are in readmes at the moment, so implementing our own highlighter doesn't seem worth doing just yet.

hdgarrood avatar Jul 15 '15 21:07 hdgarrood

That seems like a good route forward. Fixes things in both places. Working with pygments is nasty, though. Good luck!

michaelficarra avatar Jul 15 '15 21:07 michaelficarra

Looks like they're using TextMate for highlighting, not Pygments. Also looks like they're just using the Haskell lexer from the Haskell TextMate bundle:

  • https://github.com/github/linguist/blob/master/lib/linguist/languages.yml#L2657-L2663
  • https://github.com/github/linguist/blob/master/grammars.yml#L274-L276

hdgarrood avatar Jul 16 '15 01:07 hdgarrood

Good news: https://github.com/github/linguist/pull/2506

I think we just need to add some CSS to style the relevant classes now, then readmes will work. Highlighting PureScript code inside normal code documentation is a bit harder, unfortunately. We could use the GitHub API, but that might result in an absurd number of requests to it. We could also use Cheapskate to extract only the bits which need highlighting and get GitHub to highlight just those, or perhaps implement our own highlighter.

hdgarrood avatar Jul 23 '15 01:07 hdgarrood

This can be closed right?

paf31 avatar Aug 14 '15 21:08 paf31

We don't have highlighting for code blocks in inline documentation, eg here: http://pursuit.purescript.org/packages/purescript-prelude/0.1.2/docs/Prelude#v:%28$%29 but I think we can live without that for now.

hdgarrood avatar Aug 14 '15 21:08 hdgarrood