pandoc-placetable 0.5.1 → 0.6
raw patch · 4 files changed
+18/−13 lines, 4 filesdep ~pandocdep ~pandoc-types
Dependency ranges changed: pandoc, pandoc-types
Files
- README.md +3/−0
- pandoc-placetable.cabal +3/−3
- pandoc-placetable.hs +11/−9
- stack.yaml +1/−1
README.md view
@@ -47,6 +47,9 @@ $ cat foo.csv | pandoc-placetable --widths="0.2 0.8" | pandoc -f json -o output.html +(For this use-case, you might not even need pandoc-placetable; pandoc 2.9.2 and later ships+with a simple built-in csv-reader: `pandoc foo.csv -o output.html`)+ All options are optional and are specified as follows (cf. `pandoc-placetable -h`): - **csv**: The path or URL to the CSV file that is appended to the code block's content
pandoc-placetable.cabal view
@@ -1,5 +1,5 @@ Name: pandoc-placetable-Version: 0.5.1+Version: 0.6 Build-Type: Simple Synopsis: Pandoc filter to include CSV files Description: A Pandoc filter that replaces code blocks (that have the class `table`)@@ -37,9 +37,9 @@ http-conduit >= 2.1.11, spreadsheet >= 0.1.3, explicit-exception >= 0.1.0,- pandoc-types >= 1.12.0.0+ pandoc-types >= 1.20 If flag(inlineMarkdown)- Build-Depends: pandoc >= 2.1+ Build-Depends: pandoc >= 2.9 cpp-options: -DINLINE_MARKDOWN Buildable: True Default-Language: Haskell2010
pandoc-placetable.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-} module Main where import Data.Aeson (encode)@@ -184,9 +185,9 @@ -- flatten key-value tuples to commandline argument-like strings-kvsToArgs :: [(String, String)] -> [String]+kvsToArgs :: [(T.Text, T.Text)] -> [String] kvsToArgs [] = []-kvsToArgs ((k,v):rest) = ("--" ++ k) : v : (kvsToArgs rest)+kvsToArgs ((k,v):rest) = ("--" ++ T.unpack k) : T.unpack v : (kvsToArgs rest) httpConduitManager :: IO Manager@@ -197,16 +198,17 @@ placeTable (CodeBlock (ident, cls, kvs) txt) | "table" `elem` cls = do (opts, _) <- rawArgsToOpts $ kvsToArgs kvs csv <- fromMaybe (return "") (optCsv opts)- let s = if null txt+ let s = if T.null txt then csv- else txt ++ "\n" ++ csv+ else T.unpack txt ++ "\n" ++ csv let csvTable = csvToTable opts s- return $ toList $ if null ident && null kvs'+ return $ toList $ if T.null ident && null kvs' then csvTable else divWith (ident,cls,kvs') csvTable where- kvs' = filter (\(k,_) -> not $ elem k $ concatMap getNames options) kvs- getNames (Option _ ns _ _) = ns+ kvs' = filter (\(k,_) -> k `notElem` optWhitelist) kvs+ optWhitelist = concatMap getNames options+ getNames (Option _ ns _ _) = map T.pack ns placeTable a = return [a] @@ -264,7 +266,7 @@ else plain $ str s #else strToInlines [] = mempty- strToInlines s = str s+ strToInlines s = str $ T.pack s strToBlocks [] = mempty- strToBlocks s = plain $ str s+ strToBlocks s = plain $ str $ T.pack s #endif
stack.yaml view
@@ -1,4 +1,4 @@-resolver: lts-11.7+resolver: lts-15.4 packages: - '.'