commit 8b9afbbc7d564c414236fdcac598e70810263214
parent cf1d96209cbcb848cc4298af811f6be57d6d0649
Author: lumidify <nobody@lumidify.org>
Date: Thu, 24 Jun 2021 22:49:22 +0200
Fix scripts and README
Diffstat:
6 files changed, 98 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
@@ -12,12 +12,14 @@
### Flashcard structure:
-* Line 1 - Contains a "theorem number" or something similar this is what the
+* Line 1 - Contains a "theorem number" or something similar. This is what the
file is named after when using `addcard.pl`.
If this line contains '|' anywhere, the text after it is taken to be the
name of another flashcard that must be displayed before this one when it
is displayed using a viewer that supports this notation (useful for
- splitting cards into smaller parts).
+ splitting cards into smaller parts). Note that I am not aware of any viewer
+ which supports a feature like this, so I guess it's useless unless someone
+ wants to add that feature.
* Line 2 - Contains the front side of the card.
* Rest of the file - Contains the back side of the card.
@@ -34,9 +36,18 @@
* tmp_compile.sh <card name> - Compiles the given card in `flashcards/` to the
file `tmp_compile.pdf`.
* compile_all.sh - Compiles all flashcards in `flashcards/` into one big file.
-* gentsv.sh - Generates a TSV file suitable for importing into Mnemosyne.
+* mnemosyne.sh - Generates a TSV file suitable for importing into Mnemosyne.
Note that you still need to add the definitions (`defs.tex`) for the project
into the Mnemosyne config.
+ Note that Mnemosyne doesn't seem to allow updating existing flashcards when
+ importing a file, so it isn't possible to edit notes and then re-import to
+ apply the changes.
+ Note also that this script isn't tested because I updated it for the changes
+ to the flashcard format after I stopped using Mnemosyne and was too lazy to
+ test if it still worked properly. Please report any bugs you find.
+* anki.sh - Generates a TSV file suitable for importing into Anki.
+ Note that you still need to add the definitions (`defs.tex`) for the project
+ into the Anki config. See the section on Anki below for more information.
* notes_compile.sh <file> - Generates a regular PDF document from the LaTeX file
given as an argument, including all the definitions from `defs.tex`. This
is useful when some extra information is needed to understand the cards,
@@ -46,9 +57,42 @@
### Sample Workflow
Just add a new card with `addcard.pl`. When you're done editing it, run `make`
-(assuming you have the sample Makefile in the directory). This compiles the
-card to `tmp_compile.pdf`. If your PDF viewer supports reloading documents,
-you can just leave it open and reload every time you create a new card.
+(assuming you have the sample Makefile in the directory). I usually just type
+`!make` in vi or vim. This compiles the card to `tmp_compile.pdf`. If your PDF
+viewer supports reloading documents, you can just leave it open and reload
+every time you create a new card.
Once you're done adding all cards, you can use any of the other helper scripts
to compile the cards to one big file or do whatever.
+
+### Anki
+
+In order to use the TSV file in Anki, first create a new note type and add three
+fields to it: "ID", "Front", and "Back".
+
+Edit the options for the note type and add the following header, replacing
+`[defs.tex]` with the contents of `defs.tex`:
+
+```
+\documentclass[12pt]{article}
+\special{papersize=3in,5in}
+\pagestyle{empty}
+\setlength{\parindent}{0in}
+[defs.tex]
+\begin{document}
+```
+
+Then add the following footer:
+
+```
+\end{document}
+```
+
+The TSV file contains the card ID as the first field, so when importing the file,
+the option "Update existing notes when first field matches" can be used.
+
+### License
+
+CC0 (I mean, it's not like I care what people do with this)
+
+Report bugs to nobody@lumidify.org
diff --git a/addcard.pl b/addcard.pl
@@ -25,6 +25,7 @@ if (@groups) {
open $fh, ">", ".cur_card" or die "Fool.\n";
print $fh substr($filename, 11);
close $fh;
+ # Change this if you want a different editor
system("vi", $filename);
} else {
die "Idiot.\n";
diff --git a/anki.sh b/anki.sh
@@ -0,0 +1,8 @@
+rm -f anki.tsv
+for card in `ls flashcards`
+do
+ meta1=`head -n 1 "flashcards/$card" | tr -d '\n'`
+ meta2=`sed '2!d' "flashcards/$card" | tr -d '\n'`
+ body=`tail -n +3 "flashcards/$card" | sed 's/%.*$//g' | tr '\n' ' '`
+ printf '%s\t[latex]%s: %s[/latex]\t[latex]%s[/latex]\n' "$card" "${meta1%%\|*}" "$meta2" "$body" >> anki.tsv
+done
diff --git a/defs.sample.tex b/defs.sample.tex
@@ -0,0 +1,31 @@
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{amsfonts}
+\usepackage{mathrsfs}
+\usepackage{enumitem}
+\usepackage{tikz-cd}
+
+\newcommand{\Pol}{\mathop{\text{Pol}}}
+\newcommand{\ggT}{\mathop{\text{ggT}}}
+\newcommand{\Hom}{\mathop{\text{Hom}}}
+\newcommand{\End}{\mathop{\text{End}}}
+\newcommand{\Alt}{\mathop{\text{Alt}}}
+\newcommand{\sgn}{\mathop{\text{sgn}}}
+\newcommand{\Det}{\mathop{\text{Det}}}
+\newcommand{\Sym}{\mathop{\text{Sym}}}
+\newcommand{\spec}{\mathop{\text{spec}}}
+\newcommand{\Id}{\mathop{\text{Id}}}
+\newcommand{\GL}{\mathop{\text{GL}}}
+\newcommand{\diag}{\mathop{\text{diag}}}
+\newcommand{\K}{\mathop{\mathbb{K}}}
+\newcommand{\N}{\mathop{\mathbb{N}}}
+\newcommand{\Z}{\mathop{\mathbb{Z}}}
+\newcommand{\Prim}{\mathop{\mathbb{P}}}
+\newcommand{\Q}{\mathop{\mathbb{Q}}}
+\newcommand{\sB}{\mathop{\mathscr{B}}}
+\newcommand{\sG}{\mathop{\mathscr{G}}}
+\newcommand{\sP}{\mathop{\mathscr{P}}}
+\newcommand{\sT}{\mathop{\mathscr{T}}}
+\newcommand{\sL}{\mathop{\mathscr{L}}}
diff --git a/gentsv.sh b/gentsv.sh
@@ -1,9 +0,0 @@
-rm -f mnemosyne.tsv
-for i in `ls flashcards`
-do
- printf '<latex>' >> mnemosyne.tsv
- head -n 1 flashcards/$i | tr -d '\n' >> mnemosyne.tsv
- printf '</latex>\t<latex>' >> mnemosyne.tsv
- tail -n +2 flashcards/$i | sed 's/%.*$//g' | tr '\n' ' ' >> mnemosyne.tsv
- printf '</latex>\n' >> mnemosyne.tsv
-done
diff --git a/mnemosyne.sh b/mnemosyne.sh
@@ -0,0 +1,8 @@
+rm -f mnemosyne.tsv
+for card in `ls flashcards`
+do
+ meta1=`head -n 1 "flashcards/$card" | tr -d '\n'`
+ meta2=`sed '2!d' "flashcards/$card" | tr -d '\n'`
+ body=`tail -n +3 "flashcards/$card" | sed 's/%.*$//g' | tr '\n' ' '`
+ printf '<latex>%s: %s</latex>\t<latex>%s</latex>\n' "${meta1%%\|*}" "$meta2" "$body" >> mnemosyne.tsv
+done