# Any way to convert .rkt file to HTML?

**URL:** <https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460>\
**Category:** Questions & Answers\
**Created:** [January 3, 2025, 8:56pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460 "2025-01-03T20:56:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToddOBryan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/toddobryan/32/1962_2.png) [@ToddOBryan](https://racket.discourse.group/u/ToddOBryan)\
**Post date:** [January 3, 2025, 8:56pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/1 "2025-01-03T20:56:39Z")

</div>

Is there a one-liner (or really simple) way to output a .rkt file as HTML for easy display, with snips, syntax highlighting, etc.?

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [January 3, 2025, 9:18pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/2 "2025-01-03T21:18:30Z")

</div>

One option is to use Pygments.

[https://pygments.org/demo/](https://pygments.org/demo/)

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/d/df2b73a11e9d7d2d26140bb5b723d2602b37d03e.png)

Pygments will only get you syntax highlighting.  
In order to link identifiers to the documentation, you need to use Scribble.

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [January 3, 2025, 9:59pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/3 "2025-01-03T21:59:40Z")

</div>

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](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).

---

<div class="post-metadata">

**Author:** ![ToddOBryan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/toddobryan/32/1962_2.png) [@ToddOBryan](https://racket.discourse.group/u/ToddOBryan)\
**Post date:** [January 3, 2025, 10:11pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/4 "2025-01-03T22:11:39Z")

</div>

You missed the note about snips, I think. When I try a file with images, it just spins and spins.

---

<div class="post-metadata">

**Author:** ![ToddOBryan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/toddobryan/32/1962_2.png) [@ToddOBryan](https://racket.discourse.group/u/ToddOBryan)\
**Post date:** [January 3, 2025, 10:34pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/5 "2025-01-03T22:34:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [January 3, 2025, 10:34pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/6 "2025-01-03T22:34:49Z")

</div>

As far as I know, there is no solution for snips.

Besides taking screenshots.

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [January 3, 2025, 10:57pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/7 "2025-01-03T22:57:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![blerner](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@blerner](https://racket.discourse.group/u/blerner)\
**Post date:** [January 3, 2025, 11:12pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/8 "2025-01-03T23:12:16Z")

</div>

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](https://github.com/CodeGrade/bottlenose/blob/master/lib/assets/render-racket.rkt) 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](https://github.com/CodeGrade/bottlenose/blob/master/app/views/submissions/_render_embedded_images.js.erb) (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.

---

<div class="post-metadata">

**Author:** ![ToddOBryan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/toddobryan/32/1962_2.png) [@ToddOBryan](https://racket.discourse.group/u/ToddOBryan)\
**Post date:** [February 22, 2025, 5:26am UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/9 "2025-02-22T05:26:08Z")

</div>

Sorry I never responded to this. I have 125 students and no TAs. If you do the math, even spending 3 minutes on each file would mean that one set would take well over 6 hours. And if I have to click on each file to open it, annotate it, record the score, re-save, and deal with getting the grades into my school district's online grading system, it's going to take more than 3 minutes.

If I could get the files into something like HTML, I could create a rubric with clickable stuff and somewhat automate the process. In the interim, I've been having students print their files so I can write on them.

---

<div class="post-metadata">

**Author:** ![EmEf](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@EmEf](https://racket.discourse.group/u/EmEf)\
**Post date:** [February 22, 2025, 8:03am UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/10 "2025-02-22T08:03:58Z")

</div>

Todd, I just created 100 files in my shell (for …) and ran

```scheme
$ drracket foo*.rkt &

```

DrRacket easily opened up with all 100 tabs open in less than 10s on my macOS/M2.  
(I open 30 files every so often myself and was curious.)

If you grade by code inspection — the morally correct way of working with beginners — there is no way around to opening all files, looking at them, and ideally running them once. What’s the advantage of opening them as HTML files as opposed to opening them in DrRacket?

— Matthias

---

<div class="post-metadata">

**Author:** ![ToddOBryan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/toddobryan/32/1962_2.png) [@ToddOBryan](https://racket.discourse.group/u/ToddOBryan)\
**Post date:** [February 24, 2025, 10:58pm UTC](https://racket.discourse.group/t/any-way-to-convert-rkt-file-to-html/3460/11 "2025-02-24T22:58:48Z")

</div>

In an ideal world, I could create a web form that would let me enter a comment and score for each part and have students be able to see that. And then I could get a summary of each student's grade.

After I got that working, it would be nice to be able to look at unique student submissions. For example, out of 125 students, probably 100 would have the right contract and the other 25 would have 3 or 4 common misunderstandings. If I only have to grade each unique response once, I could save a huge amount of time, theoretically. Rinse and repeat with the header, purpose statement, body, and test cases.
