Is there a one-liner (or really simple) way to output a .rkt file as HTML for easy display, with snips, syntax highlighting, etc.?
One option is to use Pygments.
Pygments will only get you syntax highlighting.
In order to link identifiers to the documentation, you need to use Scribble.
I think I would use Scribble and something like typeset-code
over file->string
(see https://github.com/benknoble/frosthaven-manager/blob/d6edcdf0860ea5d7fa68138c1e5d3bcd129d5644/scribblings/programming-scenario.scrbl#L65-L67), then the usual raco scribble +m --redirect-main [http://pkg-build.racket-lang.org/doc/](http://pkg-build.racket-lang.org/doc/) …
to get output (which will be multiple files even with --html
due to CSS, IIRC).
You missed the note about snips, I think. When I try a file with images, it just spins and spins.
OK. I looked at typeset-code
, but I can't tell if it would work with files containing images, which is my use case. I'm trying to make it easier to look at a bunch of student assignments (yes, that I should have graded before the end of break) so that I can quickly go through a rubric. Unfortunately, the files all have images in them.
I was thinking I could do something clever and hook up a rubric to a web page, but I think that instead I'll be opening all the files in DrRacket and going through them, maybe with a pen and paper rubric.
As far as I know, there is no solution for snips.
Besides taking screenshots.
Why not open the wxme files in DrRacket and grade them by leaving comments in the code? Something like
;; TOB -10
;; TOB: this function fails to … …
Once the file is annotated, send it back to the students.
This is not 100% standalone code yet (and not ready for publishing as a racket package), but the code I wrote at bottlenose/lib/assets/render-racket.rkt at master · CodeGrade/bottlenose · GitHub will walk a wxme file and output an ASCII file that can then be rendered in a CodeMirror instance on a webpage. Snips are converted to plaintext, and have to be re-inserted via JS once the page is loaded -- this is done in bottlenose/app/views/submissions/_render_embedded_images.js.erb at master · CodeGrade/bottlenose · GitHub (which is injected into the page as part of a larger ruby project).
The code handles seven types of snips: comment boxes, xml boxes, text boxes, numbers, racket boxes, splice boxes, and images. This has sufficed to handle basically anything in the *SL languages, though I'd imagine you can extend the code to handle other snips if you need it...
Also, note that CodeMirror doesn't have a Racket mode, just a Scheme mode, so e.g. #true
and #false
get rendered as #t
rue and #f
alse, and #;(...)
doesn't give a faded-but-highlighted expression as it would in DrRacket.