Image lookup directories. When processing images, the program will try to find the image in them first. Always looks for images in the same folder as the markdown
Image lookup directories. When processing images, the program will try to find the image in them first. Always looks for images in the same folder
Directory to put processed images into. The program will not overwrite existing images. (default: public)
Directory to put processed images into. The program will overwrite images, whose dependencies are newer. (default: public)
-c IMG_CACHE_DIR, --img-cache-dir IMG_CACHE_DIR
Directory to cache processed images and intermediate products. The program will overwrite files, whose dependencies are newer. (default: cache)
-i IMG_WEB_PATH, --img-web-path IMG_WEB_PATH
-i IMG_WEB_PATH, --img-web-path IMG_WEB_PATH
Path where the processed images are available on the website. (default: /)
Path where the processed images are available on the website. (default: /)
-w OUTPUT_HTML, --output-html OUTPUT_HTML
-w OUTPUT_HTML, --output-html OUTPUT_HTML
The HTML file (for Web) to write into. (default: output.html)
The HTML file (for Web) to write into. (default: None)
-t OUTPUT_TEX, --output-tex OUTPUT_TEX
-t OUTPUT_TEX, --output-tex OUTPUT_TEX
The TEX file to write into. (default: output.tex)
The TEX file to write into. (default: None)
-m OUTPUT_MD, --output-md OUTPUT_MD
The Markdown file to write into. (Uses pandoc to generate markdown) (default: None)
-j OUTPUT_JSON, --output-json OUTPUT_JSON
The JSON file to dump the pandoc-compatible AST into. (default: None)
--katex-server Starts a KaTeX server and prints the socket filename onto stdout. Useful for running formatitko many times without starting the KaTeX server each
time. (default: False)
-k KATEX_SOCKET, --katex-socket KATEX_SOCKET
The KaTeX server socket filename obtained by running with `--katex-server`. (default: None)
--debug
```
```
## Format
## Format
@ -69,12 +82,28 @@ There are two ways of including files.
#### Importing
#### Importing
The first is importing, which only takes the state (defined commands, metadata,
The first is importing, which only takes the state (defined commands, metadata,
etc.) from the file and any content is omitted. This is useful for creating
etc.) from the file and any content is omitted. This is useful for creating
libraries of commands. The syntax is as follows:
libraries of commands.
[#test/empty.md]{}
There are three types of imports:
The curly braces are required for pandoc to parse the import properly and should
##### Python Module (the default)
be left empty.
```markdown
[#ksp_formatitko as ksp]{}
```
or
```markdown
[#ksp_formatitko]{}
```
with an optional `type=module` in the curly brackets, tries to import a python
module as a set of formatitko commands. See below for more details about
commands.
##### JSON Metadata
[#test/test.json]{type=metadata key=orgs}
This will import metadata from a JSON file. THe optional `key` argument sets the
key under which the whole JSON file will be placed. Dictionaries are merged,
others overwritten.
#### Partials
#### Partials
Partials are the very opposite of imports, they have their own context, which
Partials are the very opposite of imports, they have their own context, which
@ -95,12 +124,19 @@ partial to `tex` or `html`.
### Groups
### Groups
Groups are pieces of markdown with their own sandboxed context, in other words,
Groups are pieces of markdown with their own sandboxed context, in other words,
inline partials. They function exactly the same as partials, namely can have
inline partials. Syntax-wise they are pandoc Divs with the `.group` class. All
their own front matter.
attributes of the Div will be passed down as metadata to the group.
::: {.group lang=cs}
OOOoo český mód
:::
If you want to have more fancy metadata, that can only be specified in a front
matter, you can use the following syntax:
```markdown {.group}
```markdown {.group}
---
---
language: cs
lang: cs
---
---
OOOoo český mód
OOOoo český mód
```
```
@ -114,6 +150,9 @@ fmt.Pritln("owo")
```
```
````
````
Note however, that when this syntax is used, pandoc is executed for each of
these blocks which could get slow. Using divs is preferred.
Groups and partials are also enclosed in `\begingroup` and `\endgroup` in the
Groups and partials are also enclosed in `\begingroup` and `\endgroup` in the
output TeX.
output TeX.
@ -138,15 +177,38 @@ pandoc feature.]
### Running python code
### Running python code
Formátítko allows you to run Python code directly from your MD file. Any
Formátítko allows you to run Python code directly from your MD file. Any
`python` code block with the class `run` will be executed:
`python` code block with the class `run` will be executed.
#### Context
#### Command environment
You can access the current context using the `ctx` variable. The context
The commands will be executed as functions with the following signature: