git.iko.soy/typeable/pandoc
on master help sign in
HTML, LaTeX writer: Don't print header row in headerless table.

Resolves Issue #210. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1856 788f1e2b-df1e-0410-8736-df70ead52e1b

commit66d2fe3dd2d8dfb28771794aee6118fa5506a9f7 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 1 Mar 2010, 02:28 (17 years ago) parentda9eb07
2 files changed+6−5
src/Text/Pandoc/Writers/HTML.hs+2−2 src/Text/Pandoc/Writers/LaTeX.hs+4−3
src/Text/Pandoc/Writers/HTML.hs+2−2
@@ -346,8 +346,7 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
346346 captionDoc <- if null capt
347347 then return noHtml
348348 else inlineListToHtml opts capt >>= return . caption
349− colHeads <- colHeadsToHtml opts alignStrings
350− widths headers
349+ colHeads <- colHeadsToHtml opts alignStrings widths headers
351350 rows'' <- zipWithM (tableRowToHtml opts alignStrings) (cycle ["odd", "even"]) rows'
352351 return $ table $ captionDoc +++ colHeads +++ rows''
353352
@@ -356,6 +355,7 @@ colHeadsToHtml :: WriterOptions
356355 -> [Double]
357356 -> [[Block]]
358357 -> State WriterState Html
358+colHeadsToHtml _ _ _ headers | all null headers = return noHtml
359359colHeadsToHtml opts alignStrings widths headers = do
360360 heads <- sequence $ zipWith3
361361 (\alignment columnwidth item -> tableItemToHtml opts th alignment columnwidth item)
src/Text/Pandoc/Writers/LaTeX.hs+4−3
@@ -213,13 +213,14 @@ blockToLaTeX (Header level lst) = do
213213 (False, 3) -> text "\\subsubsection" <> stuffing <> char '\n'
214214 _ -> txt <> char '\n'
215215blockToLaTeX (Table caption aligns widths heads rows) = do
216− headers <- tableRowToLaTeX heads
216+ headers <- if all null heads
217+ then return empty
218+ else liftM ($$ text "\\hline") $ tableRowToLaTeX heads
217219 captionText <- inlineListToLaTeX caption
218220 rows' <- mapM tableRowToLaTeX rows
219221 let colDescriptors = concat $ zipWith toColDescriptor widths aligns
220222 let tableBody = text ("\\begin{tabular}{" ++ colDescriptors ++ "}") $$
221− headers $$ text "\\hline" $$ vcat rows' $$
222− text "\\end{tabular}"
223+ headers $$ vcat rows' $$ text "\\end{tabular}"
223224 let centered txt = text "\\begin{center}" $$ txt $$ text "\\end{center}"
224225 modify $ \s -> s{ stTable = True }
225226 return $ if isEmpty captionText