ANN: XKCD.jl: Retrieve images and hover text from XKCD webcomic

I had a bit of fun this morning filling an obvious void in the Julia ecosystem:

using XKCD

XKCD.comic(552)
# Dict{Symbol,String} with 2 entries:
#   :imgsrc => "https://imgs.xkcd.com/comics/correlation.png"
#   :hover  => "Correlation doesn't imply causation, but it does waggle its eyebrows suggestively and gesture furtively while mouthing 'look over there'."
32 Likes

It’s not registered. Why is it not registered?!? :smile:

18 Likes

Fixed.

Note the behavior has changed a little bit:

julia> XKCD.comic()
JSON3.Object{Base.CodeUnits{UInt8,JSON3.VectorString{Array{UInt8,1}}},Array{UInt64,1}} with 11 entries:
  :month      => "1"
  :num        => 2251
  :link       => ""
  :year       => "2020"
  :news       => ""
  :safe_title => "Alignment Chart Alignment Chart"
  :transcript => ""
  :alt        => "I would describe my personal alignment as \"lawful heterozygo…
  :img        => "https://imgs.xkcd.com/comics/alignment_chart_alignment_chart.…
  :title      => "Alignment Chart Alignment Chart"
  :day        => "6"
7 Likes

Just chiming in to say XKCD.jl has new capabilities on master. Release coming soon!

9 Likes

Is there a way to view the comics within VS Code?

Is there a way to view the comics within VS Code?

What’s shown above is just a MIME"text/html" show method for XKCD.Comic. Anything that can use that mimetype should work. I wonder if there’s a way to hack into the plot pane in the Julia extension.

Good question. It looks like display is one way to open a plot in the plot pane. Unfortunately, it is not clear to me how it works.

Here is something that could be integrated into your package somehow:

using FileIO, ImageShow

url = "https://avatars.githubusercontent.com/u/9677184?s=460&u=9a169e34d4bb0c3f8a48cd0ecb01b23e388b031c&v=4"
"https://avatars.githubusercontent.com/u/9677184?s=460&u=9a169e34d4bb0c3f8a48cd0ecb01b23e388b031c&v=4"

download(url) |> load