mirror of
https://github.com/Ascyii/typstar.git
synced 2026-01-01 13:34:24 -05:00
docs: anki usage and installation
This commit is contained in:
52
README.md
52
README.md
@@ -1,10 +1,10 @@
|
|||||||
# Typstar
|
# Typstar
|
||||||
Neovim plugin for efficient note taking in typst
|
Neovim plugin for efficient note taking in Typst
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Powerful autosnippets using [LuaSnip](https://github.com/L3MON4D3/LuaSnip/) and [Tree-sitter](https://tree-sitter.github.io/) (inspired by [fastex.nvim](https://github.com/lentilus/fastex.nvim))
|
- Powerful autosnippets using [LuaSnip](https://github.com/L3MON4D3/LuaSnip/) and [Tree-sitter](https://tree-sitter.github.io/) (inspired by [fastex.nvim](https://github.com/lentilus/fastex.nvim))
|
||||||
- Easy insertion of drawings using [Obsidian Excalidraw](https://github.com/zsviczian/obsidian-excalidraw-plugin)
|
- Easy insertion of drawings using [Obsidian Excalidraw](https://github.com/zsviczian/obsidian-excalidraw-plugin)
|
||||||
- \[WIP\] Export of [Anki](https://apps.ankiweb.net/) flashcards
|
- Export of [Anki](https://apps.ankiweb.net/) flashcards \[No Neovim required\]
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ Available snippets can mostly be intuitively derived from [here](././lua/typstar
|
|||||||
|
|
||||||
- Alphanumeric characters: `:<char>` → `$<char>$ ` in markup (e.g. `:X` → `$X$ `, `:5` → `$5$ `)
|
- Alphanumeric characters: `:<char>` → `$<char>$ ` in markup (e.g. `:X` → `$X$ `, `:5` → `$5$ `)
|
||||||
- Greek letters: `;<latin>` → `<greek>` in math and `$<greek>$ ` in markup (e.g. `;a` → `alpha`/`$alpha$ `)
|
- Greek letters: `;<latin>` → `<greek>` in math and `$<greek>$ ` in markup (e.g. `;a` → `alpha`/`$alpha$ `)
|
||||||
- Common indices (numbers and letters `i-m`): `<letter><index>` → `<letter>_<index>` in math and `$<letter>$<index> ` → `$<letter>_<index>$ ` in markup (e.g `A314` → `A_314`, `$alpha$n ` → `$alpha_n$ `)
|
- Common indices (numbers and letters `i-n`): `<letter><index>` → `<letter>_<index>` in math and `$<letter>$<index> ` → `$<letter>_<index>$ ` in markup (e.g `A314` → `A_314`, `$alpha$n ` → `$alpha_n$ `)
|
||||||
- Wrapping of any mathematical expression (see [operations](./lua/typstar/snippets/visual.lua), works nested, multiline and in visual mode via the [selection key](#installation)): `<expression><operation>` → `<operation>(<expression>)` (e.g. `(a^2+b^2)rt` → `sqrt(a^2+b^2)`, `lambdatd` → `tilde(lambda)`, `(1+1)sQ` → `[1+1]`, `(1+1)sq` → `[(1+1)]`)
|
- Wrapping of any mathematical expression (see [operations](./lua/typstar/snippets/visual.lua), works nested, multiline and in visual mode via the [selection key](#installation)): `<expression><operation>` → `<operation>(<expression>)` (e.g. `(a^2+b^2)rt` → `sqrt(a^2+b^2)`, `lambdatd` → `tilde(lambda)`, `(1+1)sQ` → `[1+1]`, `(1+1)sq` → `[(1+1)]`)
|
||||||
- Matrices: `<size>ma` and `<size>lma` (e.g. `23ma` → 2x3 matrix)
|
- Matrices: `<size>ma` and `<size>lma` (e.g. `23ma` → 2x3 matrix)
|
||||||
- [ctheorems shorthands](./lua/typstar/snippets/document.lua) (e.g. `tem` → empty theorem, `exa` → empty example)
|
- [ctheorems shorthands](./lua/typstar/snippets/document.lua) (e.g. `tem` → empty theorem, `exa` → empty example)
|
||||||
@@ -23,14 +23,47 @@ Available snippets can mostly be intuitively derived from [here](././lua/typstar
|
|||||||
Note that you can enable and disable collections of snippets in the [config](#configuration).
|
Note that you can enable and disable collections of snippets in the [config](#configuration).
|
||||||
|
|
||||||
### Excalidraw
|
### Excalidraw
|
||||||
Use `:TypstarInsertExcalidraw` to create a new drawing using the configured template, insert a figure displaying it and open it in Obsidian.
|
- Use `:TypstarInsertExcalidraw` to create a new drawing using the configured template, insert a figure displaying it and open it in Obsidian.
|
||||||
To open an inserted drawing in Obsidian, simply run `:TypstarOpenExcalidraw` while your cursor is on a line referencing the drawing.
|
- To open an inserted drawing in Obsidian, simply run `:TypstarOpenExcalidraw` while your cursor is on a line referencing the drawing.
|
||||||
|
|
||||||
### Anki
|
### Anki
|
||||||
WIP
|
Use the `flA` snippet to create a new flashcard
|
||||||
|
```typst
|
||||||
|
#flashcard(0, "My first flashcard")[
|
||||||
|
Typst is awesome $a^2+b^2=c^2$
|
||||||
|
]
|
||||||
|
```
|
||||||
|
or the `fla` snippet to add a more complex front
|
||||||
|
```typst
|
||||||
|
#flashcard(0)[I love Typst $pi$][
|
||||||
|
This is the back of my second flashcard
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
To render the flashcard in your document as well add some code like this
|
||||||
|
```typst
|
||||||
|
#let flashcard(id, front, back) = {
|
||||||
|
strong(front)
|
||||||
|
[\ ]
|
||||||
|
back
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- Add a comment like `// ANKI: MY::DECK` to your document to set a deck used for all flashcards after this comment (You can use multiple decks per file)
|
||||||
|
- Add a file named `.anki.typ` to define a preamble on a directory base. You can find the default preamble [here](./src/anki/typst_compiler.py).
|
||||||
|
- Tip: Despite the use of SVGs you can still search your flashcards in Anki as the typst source is added into an invisible html paragraph
|
||||||
|
|
||||||
|
#### Neovim
|
||||||
|
- Use `:TypstarAnkiScan` to scan the current nvim working directory and compile all flashcards in its context, unchanged files will be ignored
|
||||||
|
- Use `:TypstarAnkiForce` to force compilation of all flashcards in the current working directory even if the files haven't changed since the last scan (e.g. on preamble change)
|
||||||
|
- Use `:TypstarAnkiForceCurrent` to force compilation of all flashcards in the file currently edited
|
||||||
|
|
||||||
|
#### Standalone
|
||||||
|
- Run `typstar-anki --help` to show the available options
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Install the plugin in neovim and set the `typstarRoot` config or alternatively clone typstar into `~/typstar`.
|
Install the plugin in Neovim and set the `typstarRoot` config or alternatively clone typstar into `~/typstar`.
|
||||||
```lua
|
```lua
|
||||||
require('typstar').setup({
|
require('typstar').setup({
|
||||||
typstarRoot = '/path/to/typstar/repo' -- depending on your nvim plugin system
|
typstarRoot = '/path/to/typstar/repo' -- depending on your nvim plugin system
|
||||||
@@ -49,7 +82,10 @@ require('typstar').setup({
|
|||||||
3. Have the `xdg-open` command working or set a different command at `uriOpenCommand` in the [config](#configuration)
|
3. Have the `xdg-open` command working or set a different command at `uriOpenCommand` in the [config](#configuration)
|
||||||
|
|
||||||
### Anki
|
### Anki
|
||||||
WIP
|
1. Install [Anki](https://apps.ankiweb.net/#download)
|
||||||
|
2. Install [Anki-Connect](https://ankiweb.net/shared/info/2055492159) and make sure `http://localhost` is added to `webCorsOriginList` in the Add-on config (should be added by default)
|
||||||
|
3. Install the typstar python package (I recommend using [pipx](https://github.com/pypa/pipx) via `pipx install git+https://github.com/arne314/typstar`) [Note: this may take a while]
|
||||||
|
4. Make sure the `typstar-anki` command is available in your `PATH` or modify the `typstarAnkiCmd` option in the [config](#configuration)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
Configuration options can be intuitively derived from the table [here](./lua/typstar/config.lua).
|
Configuration options can be intuitively derived from the table [here](./lua/typstar/config.lua).
|
||||||
|
|||||||
@@ -30,5 +30,7 @@ end
|
|||||||
return {
|
return {
|
||||||
start('dm', '$\n\t<>\n$', { i(1) }, markup),
|
start('dm', '$\n\t<>\n$', { i(1) }, markup),
|
||||||
snip('ll', ' $<>$', { i(1, '1+1') }, markup),
|
snip('ll', ' $<>$', { i(1, '1+1') }, markup),
|
||||||
|
start('fla', '#flashcard(0)[<>][\n\t<>\n]', { i(1, "flashcard"), i(2) }, markup),
|
||||||
|
start('flA', '#flashcard(0, "<>")[\n\t<>\n]', { i(1, "flashcard"), i(2) }, markup),
|
||||||
unpack(document_snippets),
|
unpack(document_snippets),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user