Add custom Markdown-like highlighting to your Anki cards!
Download and run the latest AnkiMarker.ankiaddon
release.
Markers are defined in two different files: markers.json
and markers.css
.
The markers.json
file defines the markers' name, markup and their classes.
The markers.css
file defines how the markers' style. Both files can be
found within the add-on's user_files
folder:
addons21/AnkiMarker
├── src/
└── user_files
├── markers.css
└── markers.json
The default markers.json
defines a single marker named Accent
with a markup
of *
and a class name of accent
. This would convert the string *abc*
to
<marker class="accent">abc</marker>
.
{
"parent-class": "",
"markers": [
{
"name": "Accent",
"markup": "*",
"classname": "accent"
}
]
}
The default markers.css
file defines the style of the Accent
marker. To
properly connect it to its JSON counterpart, we must make sure the classname
is used within the CSS selector. To do so, we can use marker.accent
or simply
.accent
as its CSS selector.
/**
* User defined CSS
*/
marker.accent {
/**
* accent
* *abc*
* <marker class="accent">abc</marker>
*/
color: hsla(230, 60%, 70%, 1);
font-style: unset;
font-weight: 400;
text-decoration: unset;
background-color: unset;
}
Assuming we have a field named Expression
, and the accent
marker defined
above, we can convert our input string into two different forms, marked
and unmarked
, by using field filters. A marked
filter converts the string
into its HTML equivalent while an unmarked
filter strips all the markup.
For example, if we start with the string Il est *blindé* ce type.
, we can
have one of three output strings based on the syntax we use when calling the
Expression
field
Filter | Field Syntax | Resulting String |
---|---|---|
- | {{Expression}} |
Il est *blindé* ce type. |
marked |
{{marked:Expression}} |
Il est <marker class="accent">blindé</marker> ce type. |
unmarked |
{{unmarked:Expression}} |
Il est blindé ce type. |
An example config can be found at: tnahs/anki-addon-configs:AnkiMarker.
-
Install the required
[python-version]
. See the Anki development docs for more information.pyenv install [python-version]
-
Clone this repository.
git clone [email protected]:tnahs/AnkiMarker.git
-
Set
[python-version]
as the local version:cd ./AnkiMarker pyenv local [python-version]
-
Create and enter a virtual environment:
python -m venv .venv source .venv/bin/activate pip install --upgrade pip
-
Install required packages:
pip install -r requirements.txt
-
Set development environment variables. See Anki development | Environment Variables for more information.
Required:
export ANKI_ADDON_DEVELOPMENT=1
Optional:
export ANKIDEV=1 export LOGTERM=1 export DISABLE_QT5_COMPAT=1
-
Run Anki from the terminal.
anki