• Stars
    star
    2,376
  • Rank 19,364 (Top 0.4 %)
  • Language
    Haskell
  • License
    GNU General Publi...
  • Created about 8 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terminal-based presentations using Pandoc

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

  • Next slide: space, enter, l, , PageDown
  • Previous slide: backspace, h, , PageUp
  • Go forward 10 slides: j,
  • Go backward 10 slides: k,
  • First slide: 0
  • Last slide: G
  • Jump to slide N: N followed by enter
  • Reload file: r
  • Quit: q

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:

  • backend: iterm2: uses iTerm2's special escape sequence to render the image. This even works with animated GIFs!

  • backend: kitty: uses Kitty's icat command.

  • 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:

    backend: 'w3m'
    path: '/home/jasper/.local/bin/w3mimgdisplay'

Breadcrumbs

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:

  • fragment: Introduce a pause (see fragments) in between showing the original code block and the output. Defaults to true.
  • replace: Remove the original code block and replace it with the output rather than appending the output in a new code block. Defaults to false.

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.

More Repositories

1

hakyll

A static website compiler library in Haskell
Haskell
2,700
star
2

websockets

A Haskell library for creating WebSocket-capable servers
Haskell
406
star
3

blaze-html

A blazingly fast HTML combinator library for Haskell.
Haskell
238
star
4

profiteur

Visualiser for Haskell (GHC) prof files
JavaScript
190
star
5

digestive-functors

A general way to consume input using applicative functors
Haskell
149
star
6

fugacious

An example Haskell web application
Haskell
147
star
7

lorem-markdownum

A lorem ipsum generator for markdown
Haskell
145
star
8

jaspervdj

Source code of my personal home page.
Haskell
117
star
9

turnstyle

Turnstyle is a graphical esoteric programming language based on lambda calculus
Haskell
70
star
10

psqueues

Priority Search Queues in three different flavors for Haskell
Haskell
64
star
11

talks

Slides & demos for talks I do
TeX
60
star
12

JVGS

JVGS is a free, minimalistic platform game that is not like the others.
C++
58
star
13

goldplate

a cute and simple golden test runner for CLI applications
Haskell
44
star
14

dcpu16-hs

Haskell implementation of Notch's dcpu-16 specification (assembler, emulator)
Haskell
42
star
15

beeraffe

PureScript
41
star
16

planet-wars-haskell

Unofficial Haskell starter package for the Planet Wars AI contest
Haskell
33
star
17

websockets-snap

Snap integration for the websockets library
Haskell
33
star
18

number-six

Number Six is a Haskell IRC bot.
Haskell
27
star
19

tweetov

Haskell webapp to generate random tweets using Markov chains
Haskell
27
star
20

cabal-dependency-licenses

Compose a list of a project's transitive dependencies with their licenses
Haskell
27
star
21

hakyll-examples

Examples for the Hakyll static site generator
Haskell
22
star
22

blaze-markup

Core modules for a blazing fast markup combinator library
Haskell
21
star
23

uplcg

Untitled PL Card Game
Haskell
20
star
24

indents

Simple indentation sensitive parser-combinators for parsec
Haskell
20
star
25

acme-cofunctor

A Cofunctor is a structure from category theory dual to Functor
Haskell
14
star
26

markdown-to-confluence

"Meh, good enough" markdown to confluence convertor
Haskell
13
star
27

b-tree

A fast B-tree library for Haskell
Haskell
12
star
28

sysfunboost.sh

More fun with your linux system.
Shell
12
star
29

dotfiles

Shell
10
star
30

firefly

Lightweight, fast and easy 2D game library for Haskell
Haskell
10
star
31

hakyll-contrib

Extra pre-made configurations and useful modules for hakyll
Haskell
9
star
32

advent-of-code

My solutions to AdventOfCode
Haskell
8
star
33

haskell-irc

IRC client in Haskell and CoffeeScript
Haskell
7
star
34

zurical

Some PureScript to render the ZuriHac calendar
PureScript
6
star
35

blaze-from-html

Code for the blaze-from-html tool
Haskell
6
star
36

blaze-html-hexpat

Hexpat renderer for blaze-html
Haskell
6
star
37

hart

Haskell prettifier
Haskell
5
star
38

redis-simple

Simplified redis wrapper for Haskell
Haskell
5
star
39

download-media-content

Simple tool to download images from RSS feeds (e.g. Flickr, Picasa)
Haskell
5
star
40

gnome-socket-applet

Gnome panel applet that reads from a pipe and displays the result
C
5
star
41

string-search

Ghent University project: Implementation of several string matching algorithms in C
C
5
star
42

hakyll-citeproc-example

How to use hakyll together with citeproc for bibliographies on your website
TeX
4
star
43

fast-aleck-hs

Bindings to the fast-aleck library, a smart typography enhancer
Haskell
4
star
44

IRCFileNotify

A simple bot that detects new files in a given directory and says this in an IRC channel.
Ruby
4
star
45

Genus

Algorithms & Data structures project
Java
4
star
46

glob-intersection

Haskell
4
star
47

hakyll-init

Very simple program to generate a hakyll sample blog
Haskell
4
star
48

copypasta

A source we can copy-paste from during programming contests.
Java
4
star
49

mandelbrot-lovejoy-rain

Haskell
4
star
50

snap-blaze

blaze-html integration for Snap
Haskell
4
star
51

euler

Haskell
3
star
52

sup-host

Check if hosts are up, and wake them
Haskell
3
star
53

omnomnom

Simple Haskell webapp to order food
Haskell
3
star
54

PhitSolver

Haskell program to solve PhitDroid (http://www.mtoy.biz/phitdroid2ndEdition.html) puzzles
Haskell
3
star
55

hstyle

A Haskell style checker
Haskell
3
star
56

hakyll-snippets

Include code snippets from another project
Haskell
2
star
57

bestphotoblog

Haskell
2
star
58

AstroBot

Software Design I Project
C++
2
star
59

google-forms-to-plaintext

Turn google (long) forms responses into readable plaintext files
Haskell
2
star
60

fpy-mvp

MVP for a Format-Preserving YAML Parser
Haskell
2
star
61

xrandr-config

Quick and dirty tool to switch xrandr configs
Haskell
2
star
62

hakyll-bibtex

Example of using hakyll & bibtex
Haskell
2
star
63

what-morphism

Msc. Thesis code: GHC Plugin to detect and transform catamorphisms and apply fold/build fusion
Haskell
2
star
64

criterion-to-html

Convert criterion output to HTML reports
Haskell
2
star
65

NonSense

A basic counterexample finder using semantic tableaux
Haskell
2
star
66

sihemo

Simple Heartbeat Monitoring
Haskell
2
star
67

programming-languages-assignment

My solution to the assignment for the programming languages course at UGent, 2010-2011
Haskell
2
star
68

snaptic-cli

Simple command line interface to snaptic.com
Haskell
2
star
69

Musique

College project from first year bachelor computer science.
Java
1
star
70

burningwheelstour.ch

Source code of burningwheelstour.ch
HTML
1
star
71

samplecount-blog

Haskell
1
star
72

xke-tweetcloud

XKE Twitter Cloud session code for 21st jun, 2011
JavaScript
1
star
73

powerdot-template

Custom stuff I use for latex/powerdot presentations
1
star
74

dir-metadata

Simple CLI tool to add, list and manipulate metadata for humans per directory
Haskell
1
star
75

swipl-block

An implementation of the block declaration for SWI-Prolog
Prolog
1
star
76

thesis

My Msc. thesis
Haskell
1
star
77

veravd

My mother's website
JavaScript
1
star