Feat: add example
This commit is contained in:
parent
90067b4068
commit
7bbaf1132d
30
README.md
30
README.md
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
Pytex is a simple package which make a bridge between Latex and Python.
|
Pytex is a simple package which make a bridge between Latex and Python.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pip install mypytex
|
||||||
|
```
|
||||||
|
|
||||||
## texenv: Bring Python inside latex
|
## texenv: Bring Python inside latex
|
||||||
|
|
||||||
*texenv* is a jinja2 environment which allow to use python commands inside latex.
|
*texenv* is a jinja2 environment which allow to use python commands inside latex.
|
||||||
@ -9,6 +15,30 @@ Pytex is a simple package which make a bridge between Latex and Python.
|
|||||||
- **\Block{#}** is the equivalent of **{% block #%}** in Jinja2. Every python's commands will be run like in a script. **%-** is also available for line statement.
|
- **\Block{#}** is the equivalent of **{% block #%}** in Jinja2. Every python's commands will be run like in a script. **%-** is also available for line statement.
|
||||||
- **\Var{#}** is the equivalent of **{{#}}** which print the statment.
|
- **\Var{#}** is the equivalent of **{{#}}** which print the statment.
|
||||||
|
|
||||||
|
Use the environment with a string template.
|
||||||
|
|
||||||
|
``` python
|
||||||
|
>>> from pytex import texenv
|
||||||
|
|
||||||
|
>>> text = "Hello"
|
||||||
|
>>> template = """\
|
||||||
|
\Var{text}
|
||||||
|
\Block{set a = 2}
|
||||||
|
%-set b = 3
|
||||||
|
\Var{a}
|
||||||
|
\Var{b}
|
||||||
|
"""
|
||||||
|
|
||||||
|
>>> template = texenv.from_string(template)
|
||||||
|
>>> print(template.render(text = text)
|
||||||
|
Hello
|
||||||
|
|
||||||
|
2
|
||||||
|
3
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## feed: converting template into tex files
|
## feed: converting template into tex files
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user