1

I want to make incremental div elements, but pandoc is stripping out the incremental class name from them:

$ echo '<div class="incremental">hello</div>' | pandoc -f markdown -t slidy
<div class="slide section level6">

<div>
hello
</div>
</div>

This doesn't happen with p elements:

$ echo '<p class="incremental">hello</p>' | pandoc -f markdown -t slidy
<div class="slide section level6">

<p class="incremental">
hello
</p>
</div>

Nor does it happen with non-incremental class names:

$ echo '<div class="foo">hello</div>' | pandoc -f markdown -t slidy
<div class="slide section level6">

<div class="foo">
hello
</div>
</div>

This worked when I generated these slides five years ago, but it's not working anymore (pandoc 2.2.1). Was this considered an anti-pattern? Am I doing something wrong?

earldouglas
  • 13,265
  • 5
  • 41
  • 50

1 Answers1

3

The reason is that newer pandoc versions have a native div element in their internal document AST, which is handled slightly differently.

You can get back the old behaviour with:

pandoc -f markdown-native_divs

But what you'd probably want to do is also use the native div syntax. See also https://pandoc.org/MANUAL.html#incremental-lists

::: incremental

- Eat spaghetti
- Drink wine

:::
mb21
  • 34,845
  • 8
  • 116
  • 142
  • When using the native div syntax, the `
      ` gets an `incremental` class, but the enclosing `
      ` does not. Nor do other elements within it, such as `

      `. The docs indicate that most elements can be made incremental, but this looks like it's reserved for `

        `. Can I use a native div to make everything within it incremental?
    – earldouglas May 27 '20 at 14:21
  • yeah... I think using plain pandoc it's only `ul` and `ol`... – mb21 May 27 '20 at 14:25