Skip to content

Commit c162d9d

Browse files
author
Rubaiyat Khondaker
authored
Merge pull request #12 from Pseudonium/develop
v1.0 Update
2 parents 08b8d0a + 63ba938 commit c162d9d

5 files changed

Lines changed: 345 additions & 119 deletions

File tree

Markdown_example_back.png

183 KB
Loading

Markdown_example_front.png

153 KB
Loading

README.md

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Obsidian_to_Anki
2-
Script to add flashcards from an Obsidian markdown file to Anki.
2+
Script to add flashcards from a properly-formatted file to Anki. Run from the command line. Built with Obsidian markdown syntax in mind.
33

44
## Setup
55
1. Install [Python](https://www.python.org/downloads/). Note that the script was written in Python3.8 - I don't think it would work on older versions (confirmed that it doesn't work on Python2 via [this issue](https://github.com/Pseudonium/Obsidian_to_Anki/issues/6#issue-690905446))
66
2. Download the desired release.
77
3. Place the script "obsidian_to_anki.py" in a convenient folder. You may wish to consider placing it in a Scripts folder, and adding the folder to your PATH
8-
4. Start up Anki, and navigate to your desired profile
8+
4. Start up [Anki](https://apps.ankiweb.net/), and navigate to your desired profile
99
5. Ensure that you've installed [AnkiConnect](https://github.com/FooSoft/anki-connect).
1010
6. Install the `python-markdown` library - see installation instructions [here](https://github.com/Python-Markdown/markdown). `pip install markdown` should work.
1111
7. Check the Permissions tab below to ensure the script is able to run.
@@ -20,16 +20,35 @@ The script needs to be able to:
2020
* Rename files in the directory the script is used
2121
* Remove a backup file in the directory the script is used
2222

23+
## Features
24+
25+
Current features:
26+
* [Custom note types](#note-formatting)
27+
* Updating notes from file
28+
* Substitutions - see [Config](#config)
29+
* [Tags](#tag-formatting)
30+
* Adding to user-specified [decks](#deck-formatting), on a *per-file* basis
31+
* [Markdown](https://www.markdownguide.org/getting-started/) formatting - see [this](#markdown-formatting) for examples
32+
* [Embedded images](#image-formatting) (GIFs should work too)
33+
* [Auto-deleting notes](#deleting-notes) from the file
34+
* Reading from all files in a directory automatically - not recursively however.
35+
36+
Not available:
37+
* Audio
38+
39+
2340
## Usage
2441
For simple documentation, run the script with the `-h` flag.
2542

26-
To edit the config file, run `obsidian_to_anki.py -c`. This will attempt to open the config file for editing, but isn't guaranteed to work. If it doesn't work, you'll have to navigate to the config file and edit it manually. For more information, see [Config](#config)
43+
**Apart from editing the config file, all operations of the script require Anki to be running.**
2744

28-
**All other operations of the script require Anki to be running.**
45+
To add notes to Anki from a properly-formatted file, or a directory of files, run `obsidian_to_anki.py [path]`, replacing `[path]` with the path to the file or directory.
46+
For example, running `obsidian_to_anki.py .` should add notes from all properly-formatted files in the current directory.
47+
To avoid unexpected behaviour, the script will only scan files from a directory if they have either a `.md` or `.txt` extension. If you feel like this will be a major issue, please let me know, and I can add this as something to be configured.
2948

30-
To update the config file with new note types from Anki, run `obsidian_to_anki -u`
49+
To edit the config file, run `obsidian_to_anki.py -c`. This will attempt to open the config file for editing, but isn't guaranteed to work. If it doesn't work, you'll have to navigate to the config file and edit it manually. For more information, see [Config](#config)
3150

32-
To add appropriately-formatted notes from a file, run `obsidian_to_anki -f {FILENAME}`
51+
To update the config file with new note types from Anki, run `obsidian_to_anki.py -u`
3352

3453
## Deck formatting
3554
Anywhere within the file, format the deck that you want the notes to go into as follows:
@@ -40,7 +59,7 @@ For example:
4059
> TARGET DECK
4160
> Mathematics
4261
43-
You may place more than one TARGET DECK, but only the first instance will be read and used.
62+
You may place more than one TARGET DECK in the same file, but only the first instance will be read and used.
4463

4564
## Note formatting
4665

@@ -54,7 +73,12 @@ In the markdown file, you must format your notes as follows:
5473
5574
### Markdown formatting
5675

57-
Standard markdown formatting is supported. GitHub-flavoured code blocks are supported (but Anki won't show syntax highlighting)
76+
Standard markdown formatting is supported.
77+
You can check [test.md](./test.md) as an example.
78+
Front produced:
79+
![front](./Markdown_example_front.png)
80+
Back produced:
81+
![back](./Markdown_example_back.png)
5882

5983
### Image formatting
6084

@@ -64,6 +88,14 @@ Embedded images are supported if the following criteria are met:
6488

6589
### Tag formatting
6690

91+
For reference, the note formatting style is:
92+
93+
> START
94+
> {Note Type}
95+
> {Note Fields}
96+
> Tags:
97+
> END
98+
6799
Note that the Tags: line is optional - if you don't want tags, you may leave out the line.
68100

69101
Tags should be formatted as such:
@@ -82,7 +114,7 @@ Apart from the first field, each field must have a prefix to indicate to the pro
82114
> Back: Test successful!
83115
> END
84116
85-
When the script successfully adds a note, it will append an ID to the Note Data. This allows you to update existing notes by running the script again.
117+
When the script successfully adds a note, it will append an ID to the Note Data. This allows you to *update existing notes by running the script again*.
86118

87119
Example output:
88120

@@ -93,6 +125,21 @@ Example output:
93125
> ID: 1566052191670
94126
> END
95127
128+
### Deleting notes
129+
130+
The script can delete notes that *it has added* automatically. To do this:
131+
1. Find the formatted note in your file:
132+
> START
133+
> {Note Type}
134+
> {Note Data}
135+
> ID: {Identifier}
136+
> END
137+
2. Change this to read:
138+
> START
139+
> ID: {Identifier}
140+
> END
141+
3. If you run the script on the file, it will interpret this as "delete the note with ID {identifier}". For convenience, it will also delete the unnecessary START END block from the file.
142+
96143
### Default
97144
By default, the script:
98145
- Adds notes with the tag "Obsidian_to_Anki" (+ other specified tags, if applicable)
@@ -137,20 +184,3 @@ Then you now format your notes like this:
137184
> B
138185
> {Note Data}
139186
> END
140-
141-
## Features
142-
143-
Current features:
144-
* Custom note types
145-
* Updating notes from Obsidian
146-
* Substitutions (see above)
147-
* Auto-convert math formatting
148-
* Tags
149-
* Adding to decks other than Default
150-
* Markdown formatting
151-
* Embedded images (GIFs should work too)
152-
153-
Not available:
154-
* Audio
155-
* Deleting notes from Obsidian
156-
* Reading from all files in a directory automatically - script works on a per-file basis

0 commit comments

Comments
 (0)