From 66d2fe3dd2d8dfb28771794aee6118fa5506a9f7 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Mon, 1 Mar 2010 02:28:03 +0000 Subject: 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 --- src/Text/Pandoc/Writers/HTML.hs | 4 ++-- src/Text/Pandoc/Writers/LaTeX.hs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index cca65751f..386fae6be 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -346,8 +346,7 @@ blockToHtml opts (Table capt aligns widths headers rows') = do captionDoc <- if null capt then return noHtml else inlineListToHtml opts capt >>= return . caption - colHeads <- colHeadsToHtml opts alignStrings - widths headers + colHeads <- colHeadsToHtml opts alignStrings widths headers rows'' <- zipWithM (tableRowToHtml opts alignStrings) (cycle ["odd", "even"]) rows' return $ table $ captionDoc +++ colHeads +++ rows'' @@ -356,6 +355,7 @@ colHeadsToHtml :: WriterOptions -> [Double] -> [[Block]] -> State WriterState Html +colHeadsToHtml _ _ _ headers | all null headers = return noHtml colHeadsToHtml opts alignStrings widths headers = do heads <- sequence $ zipWith3 (\alignment columnwidth item -> tableItemToHtml opts th alignment columnwidth item) diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 4ad55d7a1..f4375ad8c 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -213,13 +213,14 @@ blockToLaTeX (Header level lst) = do (False, 3) -> text "\\subsubsection" <> stuffing <> char '\n' _ -> txt <> char '\n' blockToLaTeX (Table caption aligns widths heads rows) = do - headers <- tableRowToLaTeX heads + headers <- if all null heads + then return empty + else liftM ($$ text "\\hline") $ tableRowToLaTeX heads captionText <- inlineListToLaTeX caption rows' <- mapM tableRowToLaTeX rows let colDescriptors = concat $ zipWith toColDescriptor widths aligns let tableBody = text ("\\begin{tabular}{" ++ colDescriptors ++ "}") $$ - headers $$ text "\\hline" $$ vcat rows' $$ - text "\\end{tabular}" + headers $$ vcat rows' $$ text "\\end{tabular}" let centered txt = text "\\begin{center}" $$ txt $$ text "\\end{center}" modify $ \s -> s{ stTable = True } return $ if isEmpty captionText -- cgit v1.2.3