2016-09-24 09:23:28 +03:00
patat
=====
2017-12-19 17:58:56 +03:00
[![Build Status ](https://img.shields.io/circleci/project/github/jaspervdj/patat.svg )](https://circleci.com/gh/jaspervdj/patat) [![Hackage ](https://img.shields.io/hackage/v/patat.svg )](https://hackage.haskell.org/package/patat) [![GitHub tag ](https://img.shields.io/github/tag/jaspervdj/patat.svg )]()
2016-10-02 07:39:49 +03:00
2016-10-13 12:00:03 +03:00
`patat` (**P**resentations **A**top **T**he **A**NSI **T**erminal) is a small
2016-09-24 09:51:17 +03:00
tool that allows you to show presentations using only an ANSI terminal. It does
not require `ncurses` .
2016-10-14 12:25:26 +03:00
Features:
- Leverages the great [Pandoc] library to support many input formats including
[Literate Haskell].
- Supports [smart slide splitting ](#input-format ).
2016-11-15 15:28:58 +03:00
- Slides can be split up into [multiple fragments ](#fragmented-slides )
2016-10-14 12:25:26 +03:00
- There is a [live reload ](#running ) mode.
2018-08-25 16:37:05 +03:00
- [Theming ](#theming ) support including 24-bit RGB.
2016-11-15 15:28:58 +03:00
- [Auto advancing ](#auto-advancing ) with configurable delay.
2016-11-18 14:38:04 +03:00
- Optionally [re-wrapping ](#line-wrapping ) text to terminal width with proper
2016-10-14 12:25:26 +03:00
indentation.
2016-10-17 14:03:02 +03:00
- Syntax highlighting for nearly one hundred languages generated from [Kate]
syntax files.
2018-08-31 17:12:28 +03:00
- Experimental [images ](#images ) support.
2016-10-14 12:25:26 +03:00
- Written in [Haskell].
2016-09-24 09:23:28 +03:00
2016-10-14 12:25:26 +03:00
![screenshot ](extra/screenshot.png?raw=true )
2016-09-24 09:23:28 +03:00
2016-10-17 14:03:02 +03:00
[Kate]: https://kate-editor.org/
2016-09-24 09:23:28 +03:00
[Haskell]: http://haskell.org/
[Pandoc]: http://pandoc.org/
2016-09-24 09:45:00 +03:00
2016-09-24 10:49:29 +03:00
Table of Contents
-----------------
2016-11-18 14:38:04 +03:00
- [Table of Contents ](#table-of-contents )
2016-09-24 10:49:29 +03:00
- [Installation ](#installation )
2016-11-18 14:38:04 +03:00
- [Pre-built-packages ](#pre-built-packages )
2016-11-15 15:51:45 +03:00
- [From source ](#from-source )
2016-09-24 10:49:29 +03:00
- [Running ](#running )
2016-11-18 14:38:04 +03:00
- [Options ](#options )
- [Controls ](#controls )
2016-09-24 10:49:29 +03:00
- [Input format ](#input-format )
2016-10-13 14:26:53 +03:00
- [Configuration ](#configuration )
2016-11-18 14:38:04 +03:00
- [Line wrapping ](#line-wrapping )
2016-11-15 15:11:31 +03:00
- [Auto advancing ](#auto-advancing )
2017-01-23 17:34:56 +03:00
- [Advanced slide splitting ](#advanced-slide-splitting )
2016-11-14 14:55:24 +03:00
- [Fragmented slides ](#fragmented-slides )
2016-10-13 14:26:53 +03:00
- [Theming ](#theming )
2016-10-17 14:03:02 +03:00
- [Syntax Highlighting ](#syntax-highlighting )
2017-12-19 20:41:02 +03:00
- [Pandoc Extensions ](#pandoc-extensions )
2018-08-31 17:12:28 +03:00
- [Images ](#images )
2016-09-24 10:49:29 +03:00
- [Trivia ](#trivia )
2016-09-24 10:42:33 +03:00
Installation
------------
2016-11-15 15:51:45 +03:00
### Pre-built-packages
2018-08-31 19:43:29 +03:00
- Archlinux: < https: // aur . archlinux . org / packages / patat-bin >
2017-09-11 12:38:46 +03:00
- Debian: < https: // packages . debian . org / unstable / patat >
- Ubuntu: < https: // packages . ubuntu . com / artful / patat >
- openSUSE: < https: // build . opensuse . org / package / show / openSUSE:Factory:ARM / patat >
2016-11-15 15:51:45 +03:00
2017-12-26 14:13:55 +03:00
You can also find generic linux binaries here:
2017-12-25 13:47:15 +03:00
< https: / / github . com / jaspervdj / patat / releases > .
2016-11-15 15:51:45 +03:00
### From source
Installation from source is very easy. You can build from source using `stack
install` or `cabal install` . `patat` is also available from [Hackage].
2016-09-24 10:42:33 +03:00
[Hackage]: https://hackage.haskell.org/package/patat
2016-10-06 11:28:14 +03:00
For people unfamiliar with the Haskell ecosystem, this means you can do either
of the following:
2016-11-15 15:51:45 +03:00
#### Using stack
2016-10-06 11:28:14 +03:00
1. Install [stack] for your platform.
2. Clone this repository.
3. Run `stack setup` (if you're running stack for the first time) and
`stack install` .
4. Make sure `$HOME/.local/bin` is in your `$PATH` .
[stack]: https://docs.haskellstack.org/en/stable/README/
2016-11-15 15:51:45 +03:00
#### Using cabal
2016-10-06 11:28:14 +03:00
1. Install [cabal] for your platform.
2. Run `cabal install patat` .
3. Make sure `$HOME/.cabal/bin` is in your `$PATH` .
[cabal]: https://www.haskell.org/cabal/
2016-09-24 10:42:33 +03:00
Running
-------
2016-11-18 14:38:04 +03:00
`patat [*options*] file`
2016-09-24 10:42:33 +03:00
2016-11-18 14:38:04 +03:00
Options
-------
`-w` , `--watch`
: If you provide the `--watch` flag, `patat` will watch the presentation file
for changes and reload automatically. This is very useful when you are
writing the presentation.
`-f` , `--force`
: Run the presentation even if the terminal claims it does not support ANSI
features.
`-d` , `--dump`
: Just dump all the slides to stdout. This is useful for debugging.
`--version`
: Display version information.
Controls
--------
2016-09-24 11:28:57 +03:00
2017-05-16 14:29:53 +03:00
- **Next slide**: `space` , `enter` , `l` , `→` , `PageDown`
- **Previous slide**: `backspace` , `h` , `←` , `PageUp`
2016-09-24 11:28:57 +03:00
- **Go forward 10 slides**: `j` , `↓`
- **Go backward 10 slides**: `k` , `↑`
- **First slide**: `0`
- **Last slide**: `G`
- **Reload file**: `r`
- **Quit**: `q`
2016-09-25 12:08:46 +03:00
The `r` key is very useful since it allows you to preview your slides while you
are writing them. You can also use this to fix artifacts when the terminal is
resized.
2016-09-24 10:42:33 +03:00
Input format
------------
The input format can be anything that Pandoc supports. Plain markdown is
usually the most simple solution:
2018-08-27 01:52:35 +03:00
```markdown
---
title: This is my presentation
author: Jane Doe
...
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
# This is a slide
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
Slide contents. Yay.
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
---
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
# Important title
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
Things I like:
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
- Markdown
- Haskell
- Pandoc
```
2016-09-24 10:42:33 +03:00
Horizontal rulers (`---`) are used to split slides.
However, if you prefer not use these since they are a bit intrusive in the
2017-01-23 17:34:56 +03:00
markdown, you can also start every slide with a header. In that case, the file
should not contain a single horizontal ruler.
2016-09-24 10:42:33 +03:00
2017-01-23 17:34:56 +03:00
`patat` will pick the most deeply nested header (e.g. `h2` ) as the marker for a
new slide. Headers _above_ the most deeply nested header (e.g. `h1` ) will turn
into title slides, which are displayed as as a slide containing only the
centered title.
This means the following document is equivalent to the one we saw before:
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
```markdown
---
title: This is my presentation
author: Jane Doe
...
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
# This is a slide
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
Slide contents. Yay.
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
# Important title
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
Things I like:
2016-09-24 10:42:33 +03:00
2018-08-27 01:52:35 +03:00
- Markdown
- Haskell
- Pandoc
```
2016-09-24 10:42:33 +03:00
2017-01-23 17:34:56 +03:00
And that following document contains three slides: a title slide, followed by
two content slides.
2018-08-27 01:52:35 +03:00
```markdown
---
title: This is my presentation
author: Jane Doe
...
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
# Chapter 1
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
## This is a slide
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
Slide contents. Yay.
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
## Another slide
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
Things I like:
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
- Markdown
- Haskell
- Pandoc
```
2017-01-23 17:34:56 +03:00
For more information, see [Advanced slide splitting ](#advanced-slide-splitting ).
2018-05-04 15:45:00 +03:00
Patat supports comments which can be used as speaker notes.
2018-08-27 01:52:35 +03:00
```markdown
---
title: This is my presentation
author: Jane Doe
...
2018-05-04 15:45:00 +03:00
2018-08-27 01:52:35 +03:00
# Chapter 1
2018-05-04 15:45:00 +03:00
2018-08-27 01:52:35 +03:00
<!--
Note: I should not bore the audience with my thoughts on powerpoint but
just get straight to the point.
-->
2018-05-04 15:45:00 +03:00
2018-08-27 01:52:35 +03:00
Slide contents. Yay.
2018-05-04 15:45:00 +03:00
2018-08-27 01:52:35 +03:00
<!-- TODO: Finish the rest of the presentation. -->
```
2018-05-04 15:45:00 +03:00
2016-10-13 14:26:53 +03:00
Configuration
-------------
`patat` is fairly configurable. The configuration is done using [YAML]. There
are two places where you can put your configuration:
1. In the presentation file itself, using the [Pandoc metadata header].
2. In `$HOME/.patat.yaml`
[YAML]: http://yaml.org/
[Pandoc metadata header]: http://pandoc.org/MANUAL.html#extension-yaml_metadata_block
2016-11-18 14:38:04 +03:00
For example, we set an option `key` to `val` by using the following file:
2016-10-13 14:26:53 +03:00
2018-08-27 01:52:35 +03:00
```markdown
---
title: Presentation with options
author: John Doe
patat:
key: val
...
2016-10-13 14:26:53 +03:00
2018-08-27 01:52:35 +03:00
Hello world.
```
2016-10-13 14:26:53 +03:00
Or we can use a normal presentation and have the following `$HOME/.patat.yaml` :
2016-11-18 14:38:04 +03:00
key: val
### Line wrapping
Line wrapping can be enabled by setting `wrap: true` in the configuration. This
will re-wrap all lines to fit the terminal width better.
2016-10-13 14:26:53 +03:00
2018-08-27 01:52:35 +03:00
### Margins
Margins can be enabled by setting a `margins` entry in the configuration:
```markdown
---
title: Presentation with margins
author: John Doe
patat:
wrap: true
margins:
left: 10
right: 10
...
Lorem ipsum dolor sit amet, ...
```
This example configuration will generate slides with a margin of 10 characters on the left,
and break lines 10 characters before they reach the end of the terminal's width.
It is recommended to enable [line wrapping ](#line-wrapping ) along with this feature.
2016-11-15 15:11:31 +03:00
### Auto advancing
By setting `autoAdvanceDelay` to a number of seconds, `patat` will automatically
advance to the next slide.
2018-08-27 01:52:35 +03:00
```markdown
---
title: Auto-advance, yes please
author: John Doe
patat:
autoAdvanceDelay: 2
...
2016-11-15 15:11:31 +03:00
2018-08-27 01:52:35 +03:00
Hello World!
2016-11-15 15:11:31 +03:00
2018-08-27 01:52:35 +03:00
---
2016-11-15 15:11:31 +03:00
2018-08-27 01:52:35 +03:00
This slide will be shown two seconds after the presentation starts.
```
2016-11-15 15:11:31 +03:00
2016-12-29 22:49:08 +03:00
Note that changes to `autoAdvanceDelay` are not picked up automatically if you
are running `patat --watch` . This requires restarting `patat` .
2017-01-23 17:34:56 +03:00
### Advanced slide splitting
You can control the way slide splitting works by setting the `slideLevel`
variable. This variable defaults to the least header that occurs before a
non-header, but it can also be explicitly defined. For example, in the
following document, the `slideLevel` defaults to **2** :
2018-08-27 01:52:35 +03:00
```markdown
# This is a slide
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
## This is a nested header
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
This is some content
```
2017-01-23 17:34:56 +03:00
With `slideLevel` 2, the `h1` will turn into a "title slide", and the `h2` will
be displayed at the top of the second slide. We can customize this by setting
`slideLevel` manually:
2018-08-27 01:52:35 +03:00
```markdown
---
patat:
slideLevel: 1
...
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
# This is a slide
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
## This is a nested header
2017-01-23 17:34:56 +03:00
2018-08-27 01:52:35 +03:00
This is some content
```
2017-01-23 17:34:56 +03:00
Now, we will only see one slide, which contains a nested header.
2016-11-14 14:55:24 +03:00
### Fragmented slides
By default, slides are always displayed "all at once". If you want to display
them fragment by fragment, there are two ways to do that. The most common
case is that lists should be displayed incrementally.
This can be configured by settings `incrementalLists` to `true` in the metadata
block:
2018-08-27 01:52:35 +03:00
```markdown
---
title: Presentation with incremental lists
author: John Doe
patat:
incrementalLists: true
...
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
- This list
- is displayed
- item by item
```
2016-11-14 14:55:24 +03:00
Setting `incrementalLists` works on _all_ lists in the presentation. To flip
the setting for a specific list, wrap it in a block quote. This will make the
list incremental if `incrementalLists` is not set, and it will display the list
all at once if `incrementalLists` is set to `true` .
This example contains a sublist which is also displayed incrementally, and then
a sublist which is displayed all at once (by merit of the block quote).
2018-08-27 01:52:35 +03:00
```markdown
---
title: Presentation with incremental lists
author: John Doe
patat:
incrementalLists: true
...
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
- This list
- is displayed
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
* item
* by item
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
- Or sometimes
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
> * all at
> * once
```
2016-11-14 14:55:24 +03:00
Another way to break up slides is to use a pagraph only containing three dots
separated by spaces. For example, this slide has two pauses:
2018-08-27 01:52:35 +03:00
```markdown
Legen
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
. . .
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
wait for it
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
. . .
2016-11-14 14:55:24 +03:00
2018-08-27 01:52:35 +03:00
Dary!
```
2016-11-14 14:55:24 +03:00
2016-10-13 14:26:53 +03:00
### Theming
Colors and other properties can also be changed using this configuration. For
example, we can have:
2018-08-27 01:52:35 +03:00
```markdown
---
author: 'Jasper Van der Jeugt'
title: 'This is a test'
patat:
wrap: true
theme:
emph: [vividBlue, onVividBlack, bold]
imageTarget: [onDullWhite, vividRed]
...
2016-10-13 14:26:53 +03:00
2018-08-27 01:52:35 +03:00
# This is a presentation
2016-10-13 14:26:53 +03:00
2018-08-27 01:52:35 +03:00
This is _emph_ text.
2016-10-13 14:26:53 +03:00
2018-08-27 01:52:35 +03:00
![Hello ](foo.png )
```
2016-10-13 14:26:53 +03:00
The properties that can be given a list of styles are:
2016-11-18 14:55:13 +03:00
`blockQuote` , `borders` , `bulletList` , `codeBlock` , `code` , `definitionList` ,
`definitionTerm` , `emph` , `header` , `imageTarget` , `imageText` , `linkTarget` ,
`linkText` , `math` , `orderedList` , `quoted` , `strikeout` , `strong` ,
`tableHeader` , `tableSeparator`
2016-10-13 14:26:53 +03:00
The accepted styles are:
2016-11-18 14:55:13 +03:00
`bold` , `dullBlack` , `dullBlue` , `dullCyan` , `dullGreen` , `dullMagenta` ,
`dullRed` , `dullWhite` , `dullYellow` , `onDullBlack` , `onDullBlue` , `onDullCyan` ,
`onDullGreen` , `onDullMagenta` , `onDullRed` , `onDullWhite` , `onDullYellow` ,
`onVividBlack` , `onVividBlue` , `onVividCyan` , `onVividGreen` , `onVividMagenta` ,
`onVividRed` , `onVividWhite` , `onVividYellow` , `underline` , `vividBlack` ,
`vividBlue` , `vividCyan` , `vividGreen` , `vividMagenta` , `vividRed` ,
`vividWhite` , `vividYellow`
2016-10-13 14:26:53 +03:00
2018-08-25 16:37:05 +03:00
Also accepted are styles of the form `rgb#RrGgBb` and `onRgb#RrGgBb` , where `Rr`
`Gg` and `Bb` are hexadecimal bytes (e.g. `rgb#f08000` for an orange foreground,
and `onRgb#101060` for a deep purple background). Naturally, your terminal
needs to support 24-bit RGB for this to work. When creating portable
presentations, it might be better to stick with the named colours listed above.
2018-08-25 16:27:30 +03:00
2016-10-17 14:03:02 +03:00
### Syntax Highlighting
As part of theming, syntax highlighting is also configurable. This can be
configured like this:
2018-08-27 01:52:35 +03:00
```
---
patat:
theme:
syntaxHighlighting:
decVal: [bold, onDullRed]
...
2016-10-17 14:03:02 +03:00
2018-08-27 01:52:35 +03:00
...
```
2016-10-17 14:03:02 +03:00
`decVal` refers to "decimal values". This is known as a "token type". For a
full list of token types, see [this list] -- the names are derived from there in
an obvious way.
[this list]: https://hackage.haskell.org/package/highlighting-kate-0.6.3/docs/Text-Highlighting-Kate-Types.html#t:TokenType
2017-12-19 20:41:02 +03:00
### Pandoc Extensions
2018-08-27 01:52:35 +03:00
Pandoc comes with a fair number of extensions on top of markdown, listed [here ](https://hackage.haskell.org/package/pandoc-2.0.5/docs/Text-Pandoc-Extensions.html ).
2017-12-19 20:41:02 +03:00
`patat` enables a number of them by default, but this is also customizable.
In order to enable an additional extensions, e.g. `autolink_bare_uris` , add it
to the `pandocExtensions` field in the YAML metadata:
2018-08-27 01:52:35 +03:00
```markdown
---
patat:
pandocExtensions:
- patat_extensions
- autolink_bare_uris
...
2017-12-19 20:41:02 +03:00
2018-08-27 01:52:35 +03:00
Document content...
```
2017-12-19 20:41:02 +03:00
The `patat_extensions` in the above snippet refers to the default set of
extensions enabled by `patat` . If you want to disable those and only use a
select few extensions, simply leave it out and choose your own:
2018-08-27 01:52:35 +03:00
```markdown
---
patat:
pandocExtensions:
- autolink_bare_uris
- emoji
...
2017-12-19 20:41:02 +03:00
2018-08-27 01:52:35 +03:00
...
2017-12-19 20:41:02 +03:00
2018-08-27 01:52:35 +03:00
Document content...
```
2017-12-19 20:41:02 +03:00
If you don't want to enable any extensions, simply set `pandocExtensions` to the
empty list `[]` .
2018-08-31 17:12:28 +03:00
### Images
`patat-0.8.0.0` and newer include images support for some terminal emulators.
```markdown
---
patat:
images:
backend: auto
...
# A slide with only an image.
![](matterhorn.jpg)
```
If `images` is enabled (not by default), `patat` will draw slides that consist
only of a single image just by drawing the image, centered and resized to fit
the terminal window.
`patat` supports the following image drawing backends:
- `backend: iterm2` : uses [iTerm2 ](https://iterm2.com/ )'s special escape
sequence to render the image. This even works with animated GIFs!
- `backend: w3m` : uses the `w3mimgdisplay` executable to draw directly onto
the window. This has been tested in `urxvt` and `xterm` , but is known to
produce weird results in `tmux` .
If `w3mimgdisplay` is in a non-standard location, you can specify that using
`path` :
```yaml
backend: 'w3m
path: '/home/jasper/.local/bin/w3mimgdisplay'
```
2016-09-24 10:33:02 +03:00
Trivia
------
2016-09-24 09:45:00 +03:00
_"Patat"_ is the Flemish word for a simple potato. Dutch people also use it to
refer to French Fries but I don't really do that -- in Belgium we just call
fries _"Frieten"_ .
2016-09-24 10:33:02 +03:00
The idea of `patat` is largely based upon [MDP] which is in turn based upon
[VTMC]. I wanted to write a clone using Pandoc because I ran into a markdown
parsing bug in MDP which I could not work around. A second reason to do a
Pandoc-based tool was that I would be able to use [Literate Haskell] as well.
2016-09-24 10:42:33 +03:00
Lastly, I also prefer not to install Node.js on my machine if I can avoid it.
2016-09-24 10:33:02 +03:00
[MDP]: https://github.com/visit1985/mdp
[VTMC]: https://github.com/jclulow/vtmc
[Literate Haskell]: https://wiki.haskell.org/Literate_programming