In addition to a full web application for exploring GitHub repositories, Kin uses much of the same code to provide a second useful service: Ink syntax highlighting as a service.
To make the service available, Kin acts as an HTTP proxy for public source
files on GitHub. Kin URLs of the format https://code.dotink.co/embed/{{
GitHub Download URL }}
are parsed to the right files. In each case, the
file is downloaded from GitHub, and if it's an Ink source file, it's
additionally highlighted and annotated with line numbers before being sent back
to the client. This means embedding a syntax-highlighted, line-numbered Ink
source file in any webpage is as simple as writing
<iframe src="/embed/https://raw.githubusercontent.com/thesephist/ink/master/samples/std.ink" frameborder="0"> </iframe>
For example, here's a syntax-highlighted version of the Ink standard library.
This file implements the sorting algorithm quicksort, used as the sorting algorithm in most Ink programs today.
More complex Ink source files can also be highlighted this way. For example, the following source file is the semantic analysis algorithm in the September compiler, an Ink-to-JavaScript compiler written in Ink itself.
Embedding source files that aren't Ink programs will simply return line-numbered previews -- no syntax highlighting occurs. For example, the following is the JavaScript runtime used by the September compiler.
Syntax highlighting as a service is a feature of the Ink codebase browser.