Skip to content

Commit

Permalink
Docs: Fixed Jinja2 syntax table
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslrodri committed Aug 10, 2024
1 parent eb5a2e4 commit 11be3e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
11 changes: 7 additions & 4 deletions docs/usage/as-magic.md
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,10 @@ Since [version 0.5](https://jupyter-tikz.readthedocs.io/stable/about/changelog/)

| Standard Jinja2 Syntax | Jupyter TikZ Syntax | Example |
| :--------------------------------------: | :------------------: | :--------------------------: |
| `{% raw %}{{ expression }}{% endraw %}` | `(** expression **)` | `(** for n1 in range(n) **)` |
| `{% raw %}{% logic/block %}{% endraw %}` | `(* logic/block *)` | `\node at((* angle *):1);` |
| `{% raw %}{# comment #}{% endraw %}` | `(~ comment ~)` | `(~ This won’t render ~)` |
| `{% raw %}{{ expression }}{% endraw %}` | `(* expression *)` | `\node at((* angle *):1);` |
| `{% raw %}{% logic/block %}{% endraw %}` | `(** logic/block **)` | `(** for n1 in range(n) **)` |
| `{% raw %}{# comment #}{% endraw %}` | `(~ comment ~)` | `(~ This won’t render ~)` |



!!! tip
Expand All @@ -690,7 +691,7 @@ Since [version 0.5](https://jupyter-tikz.readthedocs.io/stable/about/changelog/)
\tikzstyle{every state}=[fill=mymagenta,draw=none,text=white]
% Nodes
(** for name, angle in nodes.items() **)(~ For expression ~)
(** for name, angle in nodes.items() **)(~ For block ~)
\node[color=magenta] (v(* loop.index0 *)) at ((* angle *):1) {$(* name *)$};
(** endfor **)
% Paths
Expand Down Expand Up @@ -809,12 +810,14 @@ Sometimes, you'll make mistakes. Debugging transpiled code is challenging, espec
### Disabling Jinja rendering

If you don't want to use Jinja2 rendering you can tell it using the flag `-nj` (or `--no-jinja`):

```latex
%%tikz -nj -sc=2
\begin{tikzpicture}
\node {(* Show `(*` because i'm not rendering Jinja*)};
\end{tikzpicture}
```

<div class="result" markdown>
![No jinja](../assets/tikz/no_jinja.svg)
</div>
Expand Down
13 changes: 7 additions & 6 deletions notebooks/GettingStarted.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2363,11 +2363,12 @@
"source": [
"Since [version 0.5](https://jupyter-tikz.readthedocs.io/stable/about/changelog/) we have modified the standard Jinja2 syntax because `{}` braces clash with LaTeX. The table below shows the differences between the standard Jinja2 syntax and the Jupyter TikZ Jinja syntax:\n",
"\n",
"| Standard Jinja2 Syntax | Jupyter TikZ | Example |\n",
"| :--------------------: | :------------------: | :--------------------------: |\n",
"| `{{ expression }}` | `(** expression **)` | `(** for n1 in range(n) **)` |\n",
"| `{% logic/block %}` | `(* logic/block *)` | `\\node at((* angle *):1);` |\n",
"| `{# comment #}` | `(~ comment ~)` | `(~ This won’t render ~)` |"
"\n",
"| Standard Jinja2 Syntax | Jupyter TikZ Syntax | Example |\n",
"| :--------------------: | :-------------------: | :--------------------------: |\n",
"| `{{ expression }}` | `(* expression *)` | `\\node at((* angle *):1);` |\n",
"| `{% logic/block %}` | `(** logic/block **)` | `(** for n1 in range(n) **)` |\n",
"| `{# comment #}` | `(~ comment ~)` | `(~ This won’t render ~)` |"
]
},
{
Expand Down Expand Up @@ -2471,7 +2472,7 @@
" \\tikzstyle{every state}=[fill=mymagenta,draw=none,text=white]\n",
"\n",
" % Nodes\n",
" (** for name, angle in nodes.items() **)(~ For expression ~)\n",
" (** for name, angle in nodes.items() **)(~ For block ~)\n",
" \\node[color=magenta] (v(* loop.index0 *)) at ((* angle *):1) {$(* name *)$}; \n",
" (** endfor **)\n",
" % Paths\n",
Expand Down

0 comments on commit 11be3e3

Please sign in to comment.