diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 0608701ed..a393df6d0 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -666,13 +666,15 @@ blockToHtml opts (Div (ident, "section":dclasses, dkvs)
   let inDiv zs = RawBlock (Format "html") ("<div class=\""
                        <> fragmentClass <> "\">") :
                    (zs ++ [RawBlock (Format "html") "</div>"])
+  let breakOnPauses zs = case splitBy isPause zs of
+                           []   -> []
+                           y:ys -> y ++ concatMap inDiv ys
   let (titleBlocks, innerSecs) =
         if titleSlide
            -- title slides have no content of their own
-           then break isSec xs
-           else case splitBy isPause xs of
-                     []     -> ([],[])
-                     (z:zs) -> ([],z ++ concatMap inDiv zs)
+           then let (as, bs) = break isSec xs
+                in  (breakOnPauses as, bs)
+           else ([], breakOnPauses xs)
   let secttag  = if html5
                     then H5.section
                     else H.div
diff --git a/test/command/5819.md b/test/command/5819.md
new file mode 100644
index 000000000..235d7838e
--- /dev/null
+++ b/test/command/5819.md
@@ -0,0 +1,18 @@
+```
+% pandoc -t revealjs --slide-level=2
+# Heading
+
+one
+
+. . .
+
+two
+^D
+<section id="heading" class="title-slide slide level1">
+<h1>Heading</h1>
+<p>one</p>
+<div class="fragment">
+<p>two</p>
+</div>
+</section>
+```