packages feed

pandoc-csv2table 1.0.6 → 1.0.7

raw patch · 4 files changed

+43/−7 lines, 4 files

Files

CHANGELOG.md view
@@ -6,6 +6,13 @@  ## [Unreleased] +## [1.0.7] - 2019-06-02++- Export `tablifyCSVLinksPure` for cases where no IO is required.+- Handle change in Pandoc markdown reader default options in pandoc-csv2table+  See <https://github.com/jgm/pandoc/commit/a58369a7e65075800>+- Update stack version+ ## [1.0.6] - 2018-11-29  - Made compatibile with Pandoc 2.0+ (Merged pull request by @vmandela)
pandoc-csv2table.cabal view
@@ -1,5 +1,5 @@ Name:                 pandoc-csv2table-Version:              1.0.6+Version:              1.0.7 Synopsis:             Convert CSV to Pandoc Table Markdown Description:          A Pandoc filter that replaces image inline or fenced code                       blocks with pandoc table markdown. CSV contents will be@@ -9,8 +9,8 @@ License:              MIT License-File:         LICENSE Author:               Wasif Hasan Baig <pr.wasif@gmail.com>-Maintainer:           Wasif Hasan Baig <pr.wasif@gmail.com>-Copyright:            (c) 2015 Wasif Hasan Baig+Maintainer:           Venkateswara Rao Mandela <venkat.mandela@gmail.com>+Copyright:            (c) 2015-2019 Wasif Hasan Baig, Venkateswara Rao Mandela Stability:            alpha Category:             Text Build-Type:           Simple
src/Text/Table/Helper.hs view
@@ -51,7 +51,8 @@  import Text.CSV (CSV) import Data.List (isInfixOf)-import Text.Pandoc (readMarkdown, def, ReaderOptions)+import Text.Pandoc (readMarkdown, def, ReaderOptions, readerExtensions)+import Text.Pandoc.Extensions import qualified Text.Pandoc.JSON as J -- Local imports import Text.Table.Definition@@ -135,6 +136,22 @@ getAtr a (_:xs)               = getAtr a xs getAtr a []                   = "" +ropt :: ReaderOptions+ropt = def+    {+      -- In the below Pandoc commit,+      --+      -- https://github.com/jgm/pandoc/commit/a58369a7e65075800+      --+      -- the default reader options were changed from pandocExtensions to+      -- empty. This resulted in the markdown to Pandoc AST conversion+      -- failing+      --+      -- To fix this issue, we enable the required reader options in+      -- pandoc-csv2table.+      readerExtensions = pandocExtensions+    }+ -- The conversion happens in three stages -- 1. Convert the CSV to an internal table representation -- 2. Convert internal table representation to markdown@@ -150,13 +167,13 @@ -- | Make Pandoc Table from Image Inline  tableFromImageInline :: [J.Inline] -> CSV -> J.Pandoc tableFromImageInline l = addInlineLabel (removeConfigString l) .-                         readMarkdown' def .+                         readMarkdown' ropt .                          toMarkdown (getTableType l) AfterTable .                          mkTable "" (getAligns l) (isHeaderPresent l)  -- | Make Pandoc Table from Code Block  tableFromCodeBlock :: Atrs -> CSV -> J.Pandoc-tableFromCodeBlock as = readMarkdown' def .+tableFromCodeBlock as = readMarkdown' ropt .                         toMarkdown (toTableType $ getAtr "type" as) AfterTable .                         mkTable (getAtr "caption" as)                                 (toAlign $ getAtr "aligns" as)
src/Text/Table/Tablify.hs view
@@ -35,7 +35,8 @@ -}  module Text.Table.Tablify (-    tablifyCsvLinks+    tablifyCsvLinks,+    tablifyCsvLinksPure   ) where  import Text.CSV         (parseCSV, parseCSVFromFile)@@ -84,3 +85,14 @@                                xss -- Return input unchanged in case of no match tablifyCsvLinks x = return [x]++tablifyCsvLinksPure :: Block -> [Block]+tablifyCsvLinksPure b@(CodeBlock (_, cs, as) s) | "table" `elem` cs = do+  case s of+    "" -> return b+    _  -> case (parseCSV "" s) of+            (Left _)    -> return b+            (Right xss) -> toBlocks .+                           tableFromCodeBlock as $+                           xss+tablifyCsvLinksPure x = return x