purescript / pursuit

Website for hosting and searching PureScript API documentation
https://pursuit.purescript.org/
Other
169 stars 47 forks source link

PureScript code highlighting #115

Open hdgarrood opened 9 years ago

hdgarrood commented 9 years ago

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.

paf31 commented 9 years ago

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

hdgarrood commented 9 years ago

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.

michaelficarra commented 9 years ago

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

hdgarrood commented 9 years ago

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:

hdgarrood commented 9 years ago

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.

paf31 commented 9 years ago

This can be closed right?

hdgarrood commented 9 years ago

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.