Search code examples
htmlrr-markdownslidy

Rmarkdown Slidy indented lists


I use Rmarkdown with slidy mostly. I like it because I can use html tags outside of r code chunks (perhaps it is do-able in other formats, no idea). However I run into trouble with indented lists.

---
title: "Test"
author: "Me"
date: "Today"
output: 
   slidy_presentation
---

## Test Slide
<ul>
 <li>One Bullet Point
</ul>

This works like a charm.

Output (html):

 <div id="test-slide" class="slide section level2">
  <h1>Test Slide</h1>
  <ul>
  <li>
  One Bullet Point
  </ul>
 </div>

However:

## Test Slide Indented
<ul>
 <li>One Bullet Point
   <ul>
      <li>One Indented Bullet Point
   </ul>
</ul>

Causes trouble. Output (html again):

<div id="test-slide-indented" class="slide section level2">
 <h1>Test Slide</h1>
 <ul>
 <li>
 One Bullet Point
 <ul>
 <pre><code>  &lt;li&gt;One Indented Bullet Point</code></pre>
 </ul>
 </ul>
 </div>

And thus "list within the list" appears as a code chunk rather than an indented list in the html document.


Solution

  • You have four spaces preceding the line with the list element. This means that pandoc will interpret that line as a code chunk. As far as I know there's no option to prevent this, so you will need to remove the indenting before the html tags.

    http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#verbatim-code-blocks

    I will also point out that markdown supports nested lists so there's no need to use html tags in your example:

    - One bullet point
        + One indented bullet