mirror of
https://github.com/mfontanini/presenterm.git
synced 2025-05-07 16:33:01 +00:00
chore: update docs with 0.9.0 changes
This commit is contained in:
parent
e5868f4b62
commit
dec21d51cf
@ -47,6 +47,7 @@ Code highlighting is supported for the following languages:
|
|||||||
* sql
|
* sql
|
||||||
* swift
|
* swift
|
||||||
* svelte
|
* svelte
|
||||||
|
* toml
|
||||||
* terraform
|
* terraform
|
||||||
* typescript
|
* typescript
|
||||||
* xml
|
* xml
|
||||||
@ -112,11 +113,30 @@ See this real example of how this looks like.
|
|||||||
|
|
||||||
[](https://asciinema.org/a/iCf4f6how1Ux3H8GNzksFUczI)
|
[](https://asciinema.org/a/iCf4f6how1Ux3H8GNzksFUczI)
|
||||||
|
|
||||||
|
### Including external code snippets
|
||||||
|
|
||||||
|
The `file` snippet type can be used to specify an external code snippet that will be included and highlighted as usual.
|
||||||
|
|
||||||
|
~~~markdown
|
||||||
|
```file +exec +line_numbers
|
||||||
|
path: snippet.rs
|
||||||
|
language: rust
|
||||||
|
```
|
||||||
|
~~~
|
||||||
|
|
||||||
|
### Showing a snippet without a background
|
||||||
|
|
||||||
|
Using the `+no_background` flag will cause the snippet to have no background. This is useful when combining it with the
|
||||||
|
`+exec_replace` flag described further down.
|
||||||
|
|
||||||
|
## Snippet execution
|
||||||
|
|
||||||
### Executing code blocks
|
### Executing code blocks
|
||||||
|
|
||||||
Annotating a code block with a `+exec` attribute will make it executable. Once you're in a slide that contains an
|
Annotating a code block with a `+exec` attribute will make it executable. Pressing `control+e` when viewing a slide that
|
||||||
executable block, press `control+e` to execute it. The output of the execution will be displayed on a box below the
|
contains an executable block, the code in the snippet will be executed and the output of the execution will be displayed
|
||||||
code. The code execution is stateful so if you switch to another slide and then go back, you will still see the output.
|
on a box below it. The code execution is stateful so if you switch to another slide and then go back, you will still see
|
||||||
|
the output.
|
||||||
|
|
||||||
~~~markdown
|
~~~markdown
|
||||||
```bash +exec
|
```bash +exec
|
||||||
@ -145,10 +165,12 @@ The list of languages that support execution are:
|
|||||||
* lua
|
* lua
|
||||||
* nushell
|
* nushell
|
||||||
* perl
|
* perl
|
||||||
|
* php
|
||||||
* python
|
* python
|
||||||
* ruby
|
* ruby
|
||||||
* rust-script
|
|
||||||
* rust
|
* rust
|
||||||
|
* rust-script: this highlights as normal Rust but uses [rust-script](https://rust-script.org/) to execute the snippet so
|
||||||
|
it lets you use dependencies.
|
||||||
* sh
|
* sh
|
||||||
* zsh
|
* zsh
|
||||||
|
|
||||||
@ -161,6 +183,46 @@ file](configuration.html#custom-snippet-executors).
|
|||||||
|
|
||||||
> **Note**: because this is spawning a process and executing code, you should use this at your own risk.
|
> **Note**: because this is spawning a process and executing code, you should use this at your own risk.
|
||||||
|
|
||||||
|
### Executing and replacing
|
||||||
|
|
||||||
|
Similar to `+exec`, `+exec_replace` causes a snippet to be executable but:
|
||||||
|
|
||||||
|
* Execution happens automatically without user intervention.
|
||||||
|
* The snippet will be automatically replaced with its execution output.
|
||||||
|
|
||||||
|
This can be useful to run programs that generate some form of ASCII art that you'd like to generate dynamically.
|
||||||
|
|
||||||
|
[](https://asciinema.org/a/hklQARZKb5sP5mavL4cGgbYXD)
|
||||||
|
|
||||||
|
Because of the risk involved in `+exec_replace`, where code gets automatically executed when running a presentation,
|
||||||
|
this requires users to explicitly opt in to it. This can be done by either passing in the `-X` command line parameter
|
||||||
|
or setting the `snippet.exec_replace.enable` flag in your configuration file to `true`.
|
||||||
|
|
||||||
|
### Executing snippets that need a TTY
|
||||||
|
|
||||||
|
If you're trying to execute a program like `top` that needs to run on a TTY as it renders text, clears the screen, etc,
|
||||||
|
you can use the `+acquire_terminal` modifier on a code already marked as executable with `+exec`. Executing snippets
|
||||||
|
tagged with these two attributes will cause _presenterm_ to suspend execution, the snippet will be invoked giving it the
|
||||||
|
raw terminal to do whatever it needs, and upon its completion _presenterm_ will resume its execution.
|
||||||
|
|
||||||
|
[](https://asciinema.org/a/AHfuJorCNRR8ZEnfwQSDR5vPT)
|
||||||
|
|
||||||
|
### Styled execution output
|
||||||
|
|
||||||
|
Snippets that generate output which contains escape codes that change the colors or styling of the text will be parsed
|
||||||
|
and displayed respecting those styles. Do note that you may need to force certain tools to use colored output as they
|
||||||
|
will likely not use it by default.
|
||||||
|
|
||||||
|
For example, to get colored output when invoking `ls` you can use:
|
||||||
|
|
||||||
|
~~~markdown
|
||||||
|
```bash +exec
|
||||||
|
ls /tmp --color=always
|
||||||
|
```
|
||||||
|
~~~
|
||||||
|
|
||||||
|
The parameter or way to enable this will depend on the tool being invoked.
|
||||||
|
|
||||||
### Hiding code lines
|
### Hiding code lines
|
||||||
|
|
||||||
When you mark a code snippet as executable via the `+exec` flag, you may not be interested in showing _all the lines_ to
|
When you mark a code snippet as executable via the `+exec` flag, you may not be interested in showing _all the lines_ to
|
||||||
@ -192,8 +254,8 @@ golang code snippet that starts with a `/// ` will be hidden.
|
|||||||
### Pre-rendering
|
### Pre-rendering
|
||||||
|
|
||||||
Some languages support pre-rendering. This means the code block is transformed into something else when the presentation
|
Some languages support pre-rendering. This means the code block is transformed into something else when the presentation
|
||||||
is loaded. The languages that currently support this are _LaTeX_ and _typst_ where the contents of the code block is
|
is loaded. The languages that currently support this are _mermaid_, _LaTeX_, and _typst_ where the contents of the code
|
||||||
transformed into an image, allowing you to define formulas as text in your presentation. This can be done by using the
|
block is transformed into an image, allowing you to define formulas as text in your presentation. This can be done by
|
||||||
`+render` attribute on a code block.
|
using the `+render` attribute on a code block.
|
||||||
|
|
||||||
See the [LaTeX and typst](latex.html) and [mermaid](mermaid.html) docs for more information.
|
See the [LaTeX and typst](latex.html) and [mermaid](mermaid.html) docs for more information.
|
||||||
|
@ -254,6 +254,9 @@ bindings:
|
|||||||
|
|
||||||
# the key binding to close the application.
|
# the key binding to close the application.
|
||||||
exit: ["<c-c>", "q"]
|
exit: ["<c-c>", "q"]
|
||||||
|
|
||||||
|
# the key binding to suspend the application.
|
||||||
|
suspend: ["<c-z>"]
|
||||||
```
|
```
|
||||||
|
|
||||||
You can choose to override any of them. Keep in mind these are overrides so if for example you change `next`, the
|
You can choose to override any of them. Keep in mind these are overrides so if for example you change `next`, the
|
||||||
@ -263,8 +266,9 @@ default won't apply anymore and only what you've defined will be used.
|
|||||||
|
|
||||||
### Snippet execution
|
### Snippet execution
|
||||||
|
|
||||||
Snippet execution is disabled by default for security reasons. Besides passing in the `-x` command line parameter every
|
[Snippet execution](code-highlight.html#executing-code-blocks) is disabled by default for security reasons. Besides
|
||||||
time you run _presenterm_, you can also configure this globally for all presentations by setting:
|
passing in the `-x` command line parameter every time you run _presenterm_, you can also configure this globally for all
|
||||||
|
presentations by setting:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
snippet:
|
snippet:
|
||||||
@ -274,6 +278,21 @@ snippet:
|
|||||||
|
|
||||||
**Use this at your own risk**, especially if you're running someone else's presentations!
|
**Use this at your own risk**, especially if you're running someone else's presentations!
|
||||||
|
|
||||||
|
### Snippet execution + replace
|
||||||
|
|
||||||
|
[Snippet execution + replace](code-highlight.html#executing-and-replacing) is disabled by default for security reasons.
|
||||||
|
Similar to `+exec`, this can be enabled by passing in the `-X` command line parameter or configuring it globally by
|
||||||
|
setting:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
snippet:
|
||||||
|
exec_replace:
|
||||||
|
enable: true
|
||||||
|
```
|
||||||
|
|
||||||
|
**Use this at your own risk**. This will cause _presenterm_ to execute code without user intervention so don't blindly
|
||||||
|
enable this and open a presentation unless you trust its origin!
|
||||||
|
|
||||||
### Custom snippet executors
|
### Custom snippet executors
|
||||||
|
|
||||||
If _presenterm_ doesn't support executing code snippets for your language of choice, please [create an
|
If _presenterm_ doesn't support executing code snippets for your language of choice, please [create an
|
||||||
@ -293,6 +312,10 @@ snippet:
|
|||||||
environment:
|
environment:
|
||||||
MY_FAVORITE_ENVIRONMENT_VAR: foo
|
MY_FAVORITE_ENVIRONMENT_VAR: foo
|
||||||
|
|
||||||
|
# A prefix that indicates a line that starts with it should not be visible but should be executed if the
|
||||||
|
# snippet is marked with `+exec`.
|
||||||
|
hidden_line_prefix: "/// "
|
||||||
|
|
||||||
# A list of commands that will be ran one by one in the same directory as the snippet is in.
|
# A list of commands that will be ran one by one in the same directory as the snippet is in.
|
||||||
commands:
|
commands:
|
||||||
# Compile if first
|
# Compile if first
|
||||||
|
@ -249,9 +249,17 @@ footer:
|
|||||||
|
|
||||||
#### Template
|
#### Template
|
||||||
|
|
||||||
A template footer that lets you put something on the left, center and/or right of the screen. The template strings have
|
A template footer that lets you put something on the left, center and/or right of the screen. The template strings
|
||||||
access to `{author}` as specified in the front matter, `{current_slide}` and `{total_slides}` which will point to the
|
can reference `{current_slide}` and `{total_slides}` which will be replaced with the current and total number of slides.
|
||||||
current and total number of slides:
|
|
||||||
|
Besides those special variables, any of the attributes defined in the front matter can also be used:
|
||||||
|
|
||||||
|
* `title`.
|
||||||
|
* `sub_title`.
|
||||||
|
* `event`.
|
||||||
|
* `location`.
|
||||||
|
* `date`.
|
||||||
|
* `author`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
footer:
|
footer:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user