patat: Terminal-based presentations using Pandoc

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

Terminal-based presentations using Pandoc.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.3.1.0, 0.3.2.0, 0.3.3.0, 0.4.0.0, 0.4.2.0, 0.4.3.0, 0.4.4.0, 0.4.5.0, 0.4.6.0, 0.4.7.0, 0.4.7.1, 0.5.0.0, 0.5.1.0, 0.5.1.1, 0.5.1.2, 0.5.2.0, 0.5.2.1, 0.5.2.2, 0.6.0.0, 0.6.1.0, 0.6.1.1, 0.7.0.0, 0.7.2.0, 0.8.0.0, 0.8.1.1, 0.8.1.2, 0.8.1.3, 0.8.2.0, 0.8.2.1, 0.8.2.2, 0.8.2.3, 0.8.2.4, 0.8.2.5, 0.8.3.0, 0.8.4.0, 0.8.4.3, 0.8.5.0, 0.8.6.0, 0.8.6.1, 0.8.7.0, 0.8.8.0, 0.8.9.0, 0.8.9.0, 0.9.0.0, 0.9.2.0, 0.10.0.0, 0.10.1.0, 0.10.1.1, 0.11.0.0, 0.12.0.0, 0.12.0.1, 0.13.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.0 && <2.2), ansi-terminal (>=0.6 && <0.12), ansi-wl-pprint (>=0.6 && <0.7), async (>=2.2 && <2.3), base (>=4.9 && <5), base64-bytestring (>=1.0 && <1.3), bytestring (>=0.10 && <0.12), colour (>=2.3 && <2.4), containers (>=0.6 && <0.7), directory (>=1.2 && <1.4), doctemplates (>=0.8 && <0.12), filepath (>=1.4 && <1.5), mtl (>=2.2 && <2.3), network (>=2.6), network-uri (>=2.6), optparse-applicative (>=0.16 && <0.19), pandoc (>=3.1 && <3.2), pandoc-types (>=1.23 && <1.24), patat, process (>=1.6 && <1.7), semigroups (>=0.16 && <0.19), skylighting (>=0.10 && <0.14), terminal-size (>=0.3 && <0.4), text (>=1.2 && <2.1), time (>=1.6 && <1.13), unordered-containers (>=0.2 && <0.3), wcwidth (>=0.0 && <0.1), yaml (>=0.8 && <0.12) [details]
License GPL-2.0-only
Copyright 2016 Jasper Van der Jeugt
Author Jasper Van der Jeugt <m@jaspervdj.be>
Maintainer Jasper Van der Jeugt <m@jaspervdj.be>
Category Text
Home page http://github.com/jaspervdj/patat
Source repo head: git clone git://github.com/jaspervdj/patat.git
Uploaded by JasperVanDerJeugt at 2023-07-15T02:05:12Z

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
patat-make-man

Build the executable to generate the man page

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for patat-0.8.9.0

[back to package description]

patat

CI Hackage GitHub tag

patat (Presentations Atop The ANSI Terminal) is a small tool that allows you to show presentations using only an ANSI terminal. It does not require ncurses.

Features:

screenshot

Table of Contents

Installation

Pre-built-packages

You can also find generic Linux and Mac OS binaries here: https://github.com/jaspervdj/patat/releases.

Homebrew

Homebrew packages are offered by a third-party repository:

  1. Install Homebrew for your platform.
  2. Run brew tap nicholasdille/tap.
  3. Run brew install patat-bin to receive the official binaries or brew install patat for pre-built ("bottled") binaries.

For issues and feedback please refer to nicholasdille/homebrew-tap.

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.

For people unfamiliar with the Haskell ecosystem, this means you can do either of the following:

Using stack

  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.

Using cabal

  1. Install cabal for your platform.
  2. Run cabal install patat.
  3. Make sure $HOME/.cabal/bin is in your $PATH.

Running

patat [*options*] file

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

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.

Input format

The input format can be anything that Pandoc supports. Plain markdown is usually the most simple solution:

---
title: This is my presentation
author: Jane Doe
...

# This is a slide

Slide contents.  Yay.

---

# Important title

Things I like:

- Markdown
- Haskell
- Pandoc

Horizontal rulers (---) are used to split slides.

However, if you prefer not use these since they are a bit intrusive in the markdown, you can also start every slide with a header. In that case, the file should not contain a single horizontal ruler.

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:

---
title: This is my presentation
author: Jane Doe
...

# This is a slide

Slide contents.  Yay.

# Important title

Things I like:

- Markdown
- Haskell
- Pandoc

And that following document contains three slides: a title slide, followed by two content slides.

---
title: This is my presentation
author: Jane Doe
...

# Chapter 1

## This is a slide

Slide contents.  Yay.

## Another slide

Things I like:

- Markdown
- Haskell
- Pandoc

For more information, see Advanced slide splitting.

Patat supports comments which can be used as speaker notes.

---
title: This is my presentation
author: Jane Doe
...

# Chapter 1

<!--
Note: I should not bore the audience with my thoughts on powerpoint but
just get straight to the point.
-->

Slide contents.  Yay.

<!-- TODO: Finish the rest of the presentation. -->

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

For example, we set an option key to val by using the following file:

---
title: Presentation with options
author: John Doe
patat:
    key: val
...

Hello world.

Or we can use a normal presentation and have the following $HOME/.patat.yaml:

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.

Margins

Margins can be enabled by setting a margins entry in the configuration:

---
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 along with this feature.

Auto advancing

By setting autoAdvanceDelay to a number of seconds, patat will automatically advance to the next slide.

---
title: Auto-advance, yes please
author: John Doe
patat:
    autoAdvanceDelay: 2
...

Hello World!

---

This slide will be shown two seconds after the presentation starts.

Note that changes to autoAdvanceDelay are not picked up automatically if you are running patat --watch. This requires restarting patat.

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:

# This is a slide

## This is a nested header

This is some content

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:

---
patat:
  slideLevel: 1
...

# This is a slide

## This is a nested header

This is some content

Now, we will only see one slide, which contains a nested header.

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:

---
title: Presentation with incremental lists
author: John Doe
patat:
    incrementalLists: true
...

- This list
- is displayed
- item by item

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).

---
title: Presentation with incremental lists
author: John Doe
patat:
    incrementalLists: true
...

- This list
- is displayed

    * item
    * by item

- Or sometimes

    > * all at
    > * once

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:

Legen

. . .

wait for it

. . .

Dary!

Theming

Colors and other properties can also be changed using this configuration. For example, we can have:

---
author: 'Jasper Van der Jeugt'
title: 'This is a test'
patat:
    wrap: true
    theme:
        emph: [vividBlue, onVividBlack, italic]
        strong: [bold]
        imageTarget: [onDullWhite, vividRed]
...

# This is a presentation

This is _emph_ text.

![Hello](foo.png)

The properties that can be given a list of styles are:

blockQuote, borders, bulletList, codeBlock, code, definitionList, definitionTerm, emph, header, imageTarget, imageText, linkTarget, linkText, math, orderedList, quoted, strikeout, strong, tableHeader, tableSeparator, underline

The accepted styles are:

bold, italic, 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

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.

Syntax Highlighting

As part of theming, syntax highlighting is also configurable. This can be configured like this:

---
patat:
  theme:
    syntaxHighlighting:
      decVal: [bold, onDullRed]
...

...

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.

Note that in order to get syntax highlighting to work, you should annotate code blocks with the language, e.g. using a fenced code block:

```ruby
puts "Hello, world!"
```

Pandoc Extensions

Pandoc comes with a fair number of extensions on top of markdown, listed here.

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:

---
patat:
  pandocExtensions:
    - patat_extensions
    - autolink_bare_uris
...

Document content...

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:

---
patat:
  pandocExtensions:
    - autolink_bare_uris
    - emoji
...

...

Document content...

If you don't want to enable any extensions, simply set pandocExtensions to the empty list [].

Images

patat-0.8.0.0 and newer include images support for some terminal emulators.

---
patat:
  images:
    backend: auto
...

# A slide with only an image.

![](matterhorn.jpg)

patat can display full-size images on slides. For this to work images must be enabled in the configuration and the slide needs to contain only a single image and no other content. The image will be centered and resized to fit the terminal window.

images is off by default in the configuration.

patat supports the following image drawing backends:

By default, patat will print a breadcrumbs-style header, e.g.:

example.md > This is a title > This is a subtitle

This feature can be turned off by using:

patat:
  breadcrumbs: false

Slide numbers

By default, patat will display slide number in bottom-right corner

This feature can be turned off by using:

patat:
  slideNumber: false

Evaluating code

patat can evaluate code blocks and show the result. You can register an evaluator by specifying this in the YAML metadata:

---
patat:
  eval:
    ruby:
      command: irb --noecho --noverbose
      fragment: true  # Optional
      replace: false  # Optional
...

Here is an example of a code block that is evaluated:

```ruby
puts "Hi"
```

An arbitrary amount of evaluators can be specified, and whenever a a class attribute on a code block matches the evaluator, it will be used.

Note that executing arbitrary code is always dangerous, so double check the code of presentations downloaded from the internet before running them if they contain eval settings.

Aside from the command, there are two more options:

Setting fragment: false and replace: true offers a way to "filter" code blocks, which can be used to render ASCII graphics.

---
patat:
  eval:
    figlet:
      command: figlet
      fragment: false
      replace: true
...

```figlet
Fancy Font
```

This feature works by simply by:

  1. Spawn a process with the provided command
  2. Write the contents of the code block to the stdin of the process
  3. Wait for the process to exit
  4. Render the stdout of the process

Trivia

"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".

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. Lastly, I also prefer not to install Node.js on my machine if I can avoid it.