pandoc-csv2table 1.0.1 → 1.0.2
raw patch · 3 files changed
+24/−40 lines, 3 files
Files
- README.md +14/−0
- pandoc-csv2table.cabal +5/−35
- src/Text/Table/Builder.hs +5/−5
README.md view
@@ -29,6 +29,8 @@ ## Usage +### Referencing or including CSV+ There are three ways to include CSV in your markdown. 1. **Referencing CSV file in Image Links:**@@ -56,6 +58,18 @@ CSV file or content can contain pandoc markdown. It will be parsed by the Pandoc Markdown Reader before being inserted as a table into the document.++### Running the filter++Given the filename `test.md`, run the filter using command++ pandoc --filter pandoc-csv2table -o test.html test.md++or++ pandoc -t json test.md | pandoc-csv2table | pandoc -f json -o test.html++## Examples See [example.md][md] and the rendered [pdf][] version in the Examples folder for more details on usage.
pandoc-csv2table.cabal view
@@ -1,39 +1,9 @@ Name: pandoc-csv2table-Version: 1.0.1+Version: 1.0.2 Synopsis: Convert CSV to Pandoc Table Markdown Description: A Pandoc filter that replaces image inline or fenced code- blocks with pandoc markdown tables.- .- Image links must have a "csv" extension.- Include the csv file in markdown as- .- @- - @- .- You can also use fenced code blocks to reference an- external CSV file using the "source" attribute.- .- > ```{.table caption="This is the **caption**" source="table.csv"}- > ```- .- You can include the CSV contents inside fenced code blocks- and omit the source attribute.- .- > ```{.table caption="This is the **caption**"}- > Fruit, Quantity, Price- > apples, 15, 3.24- > oranges, 12, 2.22- > ```- .- CSV contents will be parsed by the pandoc markdown reader.- .- You can see a rendered PDF file with tables generated from- CSV files at <https://github.com/baig/pandoc-csv2table-filter/blob/master/Examples/example.pdf Example>.- .- For more information, see <https://github.com/baig/pandoc-csv2table-filter/blob/master/README.md README>- at project's source repository.-+ blocks with pandoc table markdown. CSV contents will be+ parsed by the pandoc markdown reader. Homepage: https://github.com/baig/pandoc-csv2table-filter Bug-Reports: https://github.com/baig/pandoc-csv2table-filter/issues License: MIT@@ -52,7 +22,7 @@ location: git://github.com/baig/pandoc-csv2table-filter.git Library- Build-Depends: base >=4.8 && <4.9,+ Build-Depends: base >=4.6 && <4.9, csv >= 0.1.2, text >= 0.11 && < 1.3, pandoc >= 1.13.0.0,@@ -66,7 +36,7 @@ Default-Language: Haskell2010 Executable pandoc-csv2table- Build-Depends: base >=4.8 && <4.9,+ Build-Depends: base >=4.6 && <4.9, csv >= 0.1.2, pandoc >= 1.13.0.0, pandoc-types >= 1.12.0.0,
src/Text/Table/Builder.hs view
@@ -41,7 +41,7 @@ ) where import Data.List-import Data.Text (pack, unpack, justifyLeft, justifyRight, center)+import Data.Text (pack, unpack, strip, justifyLeft, justifyRight, center) -- Local import import Text.Table.Definition@@ -163,10 +163,10 @@ addGutter g (x:xs) = x : map ((replicate g ' ')++) xs alignText :: Width -> Align -> String -> String-alignText w (LeftAlign) = unpack . justifyLeft w ' ' . pack-alignText w (RightAlign) = unpack . justifyRight w ' ' . pack-alignText w (CenterAlign) = unpack . center w ' ' . pack-alignText w (DefaultAlign) = unpack . justifyLeft w ' ' . pack+alignText w (LeftAlign) = unpack . justifyLeft w ' ' . strip . pack+alignText w (RightAlign) = unpack . justifyRight w ' ' . strip . pack+alignText w (CenterAlign) = unpack . center w ' ' . strip . pack+alignText w (DefaultAlign) = unpack . justifyLeft w ' ' . strip . pack row2Md :: TableType -> Row -> String row2Md (Grid) (Row cs) = flatten $ transpose $ appendPipes $ map (cellToLines Grid) cs