diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 9e6e22283..8162da66a 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -919,7 +919,7 @@ tableToHtml opts (Ann.Table attr caption colspecs thead tbodies tfoot) = do
nl opts
coltags <- colSpecListToHtml opts colspecs
head' <- tableHeadToHtml opts thead
- body' <- mconcat <$> mapM (tableBodyToHtml opts) tbodies
+ bodies <- intersperse (nl opts) <$> mapM (tableBodyToHtml opts) tbodies
foot' <- tableFootToHtml opts tfoot
let (ident,classes,kvs) = attr
-- When widths of columns are < 100%, we need to set width for the whole
@@ -940,7 +940,7 @@ tableToHtml opts (Ann.Table attr caption colspecs thead tbodies tfoot) = do
captionDoc
coltags
head'
- body'
+ mconcat bodies
foot'
nl opts
@@ -948,8 +948,14 @@ tableBodyToHtml :: PandocMonad m
=> WriterOptions
-> Ann.TableBody
-> StateT WriterState m Html
-tableBodyToHtml opts (Ann.TableBody attr _rowHeadCols _intm rows) =
- addAttrs opts attr . H.tbody =<< bodyRowsToHtml opts rows
+tableBodyToHtml opts (Ann.TableBody attr _rowHeadCols inthead rows) =
+ addAttrs opts attr . H.tbody =<< do
+ intermediateHead <-
+ if null inthead
+ then return mempty
+ else headerRowsToHtml opts Thead inthead
+ bodyRows <- bodyRowsToHtml opts rows
+ return $ intermediateHead <> bodyRows
tableHeadToHtml :: PandocMonad m
=> WriterOptions
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs
index fc5721edb..d1d27d9a5 100644
--- a/test/Tests/Old.hs
+++ b/test/Tests/Old.hs
@@ -272,7 +272,7 @@ extendedWriterTests pandocPath format
opts
("tables" > name <.> "native")
("tables" > name <.> format)
- in map testForTable ["planets", "nordics"]
+ in map testForTable ["planets", "nordics", "students"]
where
opts = ["-r", "native", "-w", format, "--columns=78",
"--variable", "pandoc-version="]
diff --git a/test/tables/students.html4 b/test/tables/students.html4
new file mode 100644
index 000000000..b02b0aba8
--- /dev/null
+++ b/test/tables/students.html4
@@ -0,0 +1,55 @@
+
+List of Students
+
+
+
+
+
+
+
+
+
+Computer Science |
+
+
+
+3741255 |
+Jones, Martha |
+
+
+4077830 |
+Pierce, Benjamin |
+
+
+5151701 |
+Kirk, James |
+
+
+
+
+Russian Literature |
+
+
+
+3971244 |
+Nim, Victor |
+
+
+
+
+Astrophysics |
+
+
+
+4100332 |
+Petrov, Alexandra |
+
+
+4100332 |
+Toyota, Hiroko |
+
+
+
diff --git a/test/tables/students.html5 b/test/tables/students.html5
new file mode 100644
index 000000000..af9e088fb
--- /dev/null
+++ b/test/tables/students.html5
@@ -0,0 +1,55 @@
+
+List of Students
+
+
+
+
+
+
+
+
+
+Computer Science |
+
+
+
+3741255 |
+Jones, Martha |
+
+
+4077830 |
+Pierce, Benjamin |
+
+
+5151701 |
+Kirk, James |
+
+
+
+
+Russian Literature |
+
+
+
+3971244 |
+Nim, Victor |
+
+
+
+
+Astrophysics |
+
+
+
+4100332 |
+Petrov, Alexandra |
+
+
+4100332 |
+Toyota, Hiroko |
+
+
+
diff --git a/test/tables/students.native b/test/tables/students.native
new file mode 100644
index 000000000..13122ede2
--- /dev/null
+++ b/test/tables/students.native
@@ -0,0 +1,37 @@
+[Table ("students",[],[("source","mdn")]) (Caption Nothing
+ [Para [Str "List", Space, Str "of", Space, Str "Students"]])
+ [(AlignLeft,ColWidth 0.5)
+ ,(AlignLeft,ColWidth 0.5)]
+ (TableHead ("",[],[])
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignCenter (RowSpan 1) (ColSpan 1) [Plain [Str "Student", Space, Str "ID"]]
+ ,Cell ("",[],[]) AlignCenter (RowSpan 1) (ColSpan 1) [Plain [Str "Name"]]]])
+ [TableBody ("",["souvereign-states"],[]) (RowHeadColumns 0)
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 2) [Plain [Str "Computer", Space, Str "Science"]]]]
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "3741255"]]
+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Jones,", Space, Str "Martha"]]]
+ ,Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "4077830"]]
+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Pierce,", Space, Str "Benjamin"]]]
+ ,Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "5151701"]]
+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Kirk,", Space, Str "James"]]]]
+ ,TableBody ("",[],[]) (RowHeadColumns 0)
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 2) [Plain [Str "Russian", Space, Str "Literature"]]]]
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "3971244"]]
+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Nim,", Space, Str "Victor"]]]]
+ ,TableBody ("",[],[]) (RowHeadColumns 0)
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 2) [Plain [Str "Astrophysics"]]]]
+ [Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "4100332"]]
+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Petrov,", Space, Str "Alexandra"]]]
+ ,Row ("",[],[])
+ [Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "4100332"]]
+ ,Cell ("",[],[]) AlignDefault (RowSpan 1) (ColSpan 1) [Plain [Str "Toyota,", Space, Str "Hiroko"]]]]]
+ (TableFoot ("",[],[]) [])
+]