💾 Archived View for makeworld.space › amfora-wiki › Source-Code-Highlighting.gmi captured on 2023-11-14 at 07:49:27. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-07-16)

-=-=-=-=-=-=-

Source Code Highlighting

Pages

Home

Subscriptions

Caching

Bookmarks

Configuration

Client Certificates

Handling Other URL Schemes

Opening or streaming non text files

Proxying

Source Code Highlighting

--------------------------------------------------------------------------------

Make sure that you've read the configuration wiki page first.

configuration wiki page

By default Amfora will automatically attempt to highlight blocks of preformatted source code. This is accomplished by searching for a string at the start of the alt text; if the string corresponds to a supported language name or MIME type, then the syntax will be highlighted if possible.

Example Gemtext:


<p>Hello world!</p>


Because the word "HTML" was present at the start of the preformatted block's alt text, Amfora will attempt to read and highlight this as HTML code. This matching is case-insensitive, so `html` or `Html` would also work, as would `text/html` for matching based on media type.

Amfora will split the string at the first character that is not either an alphanumeric character or one of the following characters (all valid in media types per RFC 6838 or used in language names): `!` `_` `#` ` gemini - kennedy.gemi.dev `-` `^` `.` `+`.

RFC 6838

Any language supported by Chroma is supported by Amfora.

Chroma

Configuration

This feature can be enabled or disabled by the `highlight_code` flag in the configuration file.

You can change the style to any style supported by Chroma by changing the `highlight_style` string in the configuration file. A list of supported styles is available, with examples.

list of supported

styles

Amfora attempts to determine the number of colors supported by your terminal, which is then used by Chroma's syntax highlighter. This should work most of the time, even in recent versions of Windows.

Note to Gemtext authors

When preparing your Gemtext for use with this feature, it is recommended to use the language name rather than the media type, and (if necessary due to lack of context) to provide a short description. This is helpful for people who use screen readers.

If you'd like to support Amfora development, you can sponsor me through Ko-Fi or Github Sponsors. Feel free to submit a PR as well! Thanks.

Ko-Fi

Github Sponsors