Giter Site home page Giter Site logo

ankimarker's Introduction

AnkiMarker

Add custom Markdown-like highlighting to your Anki cards!

Installation

Download and run the latest AnkiMarker.ankiaddon release.

Usage

Configuration

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

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"
        }
    ]
}

markers.css

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;
}

Templates and Field Filters

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.

screenshot-01

Example Config

An example config can be found at: tnahs/anki-addon-configs:AnkiMarker.

Development

  1. Install the required [python-version]. See the Anki development docs for more information.

    pyenv install [python-version]
  2. Clone this repository.

    git clone [email protected]:tnahs/AnkiMarker.git
  3. Set [python-version] as the local version:

    cd ./AnkiMarker
    pyenv local [python-version]
  4. Create and enter a virtual environment:

    python -m venv .venv
    source .venv/bin/activate
    pip install --upgrade pip
  5. Install required packages:

    pip install -r requirements.txt
  6. 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
  7. Run Anki from the terminal.

    anki

ankimarker's People

Contributors

tnahs avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.