UQComputingSociety / uqcsbot-slack

:mortar_board: UQCSbot: our friendly little Slack bot
https://slack.uqcs.org.au
MIT License
55 stars 44 forks source link

Naive fix for hoogle. Strip html and formatting #434

Closed jdcaperon closed 5 years ago

jdcaperon commented 5 years ago

Fixes #433

For reference, the response format directly returns a list of dicts now. Example dict:

{"url":"https://hackage.haskell.org/package/base/docs/Prelude.html#v:const","module":{"url":"https://hackage.haskell.org/package/base/docs/Prelude.html","name":"Prelude"},"package":{"url":"https://hackage.haskell.org/package/base","name":"base"},"item":"<span class=name><s0>const</s0></span> :: a -&gt; b -&gt; a","type":"","docs":"<tt>const x</tt> is a unary function which evaluates to <tt>x</tt> for\nall inputs.\n\n<pre>\n&gt;&gt;&gt; const 42 \"hello\"\n42\n</pre>\n\n<pre>\n&gt;&gt;&gt; map (const 42) [0..3]\n[42,42,42,42]\n</pre>\n"}

The responses now also contain HTML markup. It's trivial to strip from the type sig but less so from the docs segment without the formatting for the docs section being a little awkward.

image

image