Greg’s Code Highlighter v1

AnkiWeb addon 112228974

Adds syntax highlighting to code snippets using Pygments, with day/night-compatible colors for block and inline code, working in both desktop Anki and AnkiDroid.
AI-generated summary; may contain mistakes.

card-creationformattingmobile-compatible

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
71 (👍 58 · 👎 13)
Updated
2026-06-17
Anki versions
25.09~
License
AGPL-3.0 (from the GitHub repository)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python, JavaScript, CSS, JSON
Description language
en

Maintenance

active

  • Last update or commit: 2026-10-26 (6 days before the snapshot).
  • Test files: 10.
  • GitHub Actions workflows: 2.
  • The GitHub repo is shared with 1 other addon; its commits, issues and releases are not specific to this one.
  • Commits in the last year: 70.
  • Issues: 0 open, 76 closed.
  • Pull requests: 0 open, 26 merged.
  • Median first response: 8 hours (60 answered issues and pull requests).
  • Outside pull requests: 50% of 2 merged.

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.492.1.662023-10-14
23.1023.12.12024-03-17
24.04.125.02.52025-05-29
25.07.125.07.42025-08-15
25.07.525.09+2026-06-17
History across monthly snapshots

Loading…

Similar addons

Code Highlight

Adds non-invasive automatic syntax highlighting to code blocks in Anki's editor preview and reviewer, auto-detecting languages or accepting manual class specifications, with configurable font size and color scheme.

formattingappearance

18 votes 55% approval 👍 14 · 👎 4 ⭐ 2 Anki 23.12.1~ Updated 2024-02-20

Description

⚠️ DEPRECATION NOTICE
This add-on version is deprecated and will no longer receive feature updates. It has been replaced by the v2 version: Greg’s Code Highlighter. It should continue to work for any foreseeable future though.

An Anki plugin that creates highlighted code blocks. This plugin uses a colorscheme that works in day and night modes. It also works on both, Anki for desktop and AnkiDroid.

Migration to v2

You only need to do this migration if you wish to uninstall this v1 add-on. You may continue using the v1 add-on if it works fine for you. You may even have both v1 and v2 installed.

  1. Install the new v2 add-on using code: 1527277801 (and restart Anki).
  2. In Anki’s menu bar, run Tools > Migrate Code to v2 Pygments.
  3. Uninstall this v1 add-on, and restart Anki.

Caveats
This add-on adds a custom stanza to your card templates. This is necessary to have the add-on work in an upgradeable manner. The add-on provides a convenient menu command to removing all stanzas if you decide you want to remove the plugin.

Use

  1. Select text that you want to create a code block from or copy code to clipboard and put a cursor at its desired destination.
  2. Press CTRL+' or click the add-on’s button.

For more information, consult the README.

Feedback If you have any suggestions, let me know at this plugin’s GitHub. I use the plugin personally, and I’m open to improving it.

README

🌈 Anki Code Highlighter

An Anki plugin that adds syntax highlighting to code snippets.

Features

  • A color scheme that works in day and night modes.
  • Works on Anki for desktop and AnkiDroid.
  • WYSIWYG highlighting.
  • Block and inline highlighting

Installation

Fetching from AnkiWeb

The recommended way to install this plugin is directly from AnkiWeb using Anki’s add-on management.

Fetching from source

Alternatively, you can install this plugin from source.

  1. Run dev/bin/package.
  2. Import codehighlighter.ankiaddon in Anki.

Usage

You can either highlight code from your clipboard or highlight a snippet of code already present in a card field.

Highlighting from clipboard

  1. Put the cursor in the place you want to place your code.
  2. Press ⌃+o (on macOS, ⌘+o) or click this add-on’s button in the editor’s button bar.

Highlighting an already written code snippet

  1. Write a code snippet in a card editor.
  2. Select the code snippet.
  3. Press ⌃+o (on macOS, ⌘+o) or click this add-on’s button in the editor’s button bar.

The plugin works on untagged code blocks. Do not add your own HTML tags like <code> or <pre><code> to the snippet you want to highlight. If you have run into issues with preannotated code snippets, see this comment for how to fix this.

Supported highlighters

This add-on uses Pygments. It creates highlighting tags when you run this plugin. This is useful for creating cloze cards. It supports both inline code and code blocks.

Configuration

The plugin accepts the following configuration options:

  • block-style (default: "display:flex; justify-content:center;") — The CSS style applied to the outer most container of a block code snippet. The default centers the block.
  • auto-detect-display-style (default: true) — Whether the add-on should auto-detect if the code snippet should be formatted as a block or inline.
  • shortcut (e.g. ctrl+o) — this sets the shortcut that triggers this plugin.
  • auto-update-media (default: true) — Whether the plugin updates the CSS stylesheet.
  • dev-mode (default: false) — Enables developer mode, which exposes the assets management options (Refresh/Delete assets) under the Tools menu.

Custom styles

You can use other styles than the provided Solarized style. This section explains how.

[!WARNING] Customized styling option is supported as-is. I do not provide special support for creating the stylesheet file nor guarantee forward compatibility.

  1. Set auto-update-media to false.
  2. In your Anki profile's media directory replace _gch-pygments-solarized.css with your stylesheet.

[!TIP] Check out tools/generatepygmentscss.py for how I generate the stylesheet for Solarized. You can reuse it for your own stylesheet.

Known limitations

Can’t highlight split HTML nodes

If you see “The selection splits an HTML node, which prevents the highlighting plugin from proceeding,” you are partially selecting an HTML element.

This plugin can not highlight a selection that partially selects an HTML element. To work around this, see these instructions.

🗑️ Uninstalling

This add-on installs its own CSS files into Anki’s media folder. You need to run some manual steps if you want to fully delete the add-on.

[!WARNING] Removing the CSS stylesheet file will remove highlighting from all notes that use that stylesheet. If you want to delete the add-on but keep already highlighted cards, then skip the file removal steps (1, 2, and 3).

  1. Open the add-on’s config, and add or set "dev-mode" to true.
  2. Restart Anki.
  3. Run Extras/Tools > Delete Greg’s Code Highlighter Assets.
  4. Delete the add-on.

This manual step is necessary until Anki adds add-on lifecycle hooks.