pandoc-columns (empty) → 0.2.0.5
raw patch · 5 files changed
+158/−0 lines, 5 filesdep +basedep +pandocdep +pandoc-columns
Dependencies added: base, pandoc, pandoc-columns, pandoc-types
Files
- CHANGELOG.md +9/−0
- LICENSE +29/−0
- app/Main.hs +17/−0
- pandoc-columns.cabal +45/−0
- src/Text/Pandoc/Filters/Columns.hs +58/−0
+ CHANGELOG.md view
@@ -0,0 +1,9 @@+# Changelog++0.2.0.5 Package as flake.++0.2.0.4 Updated dependencies.++0.2.0.3 Reformatted source code.++0.1.0.0 Initial release
+ LICENSE view
@@ -0,0 +1,29 @@+BSD 3-Clause License++Copyright (c) 2022-2023, Amy de Buitléir+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice,+ this list of conditions and the following disclaimer in the documentation+ and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its+ contributors may be used to endorse or promote products derived from+ this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ app/Main.hs view
@@ -0,0 +1,17 @@+{-|+Module : Main+Description : An easy way to create tables with wrapped text in Markdown.+Copyright : (c) 2020-2023 Amy de Buitléir+License : BSD--3+Maintainer : amy@nualeargais.ie+Stability : experimental+Portability : POSIX++See <https://github.com/mhwombat/pandoc-columns> for information+on how to use this filter.+-}+import Text.Pandoc.Filters.Columns (formatColumns)+import Text.Pandoc.JSON (toJSONFilter)++main :: IO ()+main = toJSONFilter formatColumns
+ pandoc-columns.cabal view
@@ -0,0 +1,45 @@+cabal-version: 3.0+name: pandoc-columns+version: 0.2.0.5+synopsis:+ A pandoc filter that provides a Markdown extension for columns.+description:+ For more information and a tutorial on how to use this package,+ please see the README at <https://github.com/mhwombat/pandoc-columns#readme>.+homepage: https://github.com/mhwombat/pandoc-columns+bug-reports: https://github.com/mhwombat/pandoc-columns/issues+license: BSD-3-Clause+license-file: LICENSE+author: Amy de Buitléir+maintainer: amy@nualeargais.ie+copyright: (c) 2020-2023 Amy de Buitléir+category: Text+build-type: Simple+extra-doc-files: CHANGELOG.md++source-repository head+ type: git+ location: https://github.com/mhwombat/pandoc-columns.git++common common-stuff+ default-language: Haskell2010+ default-extensions: ImportQualifiedPost+ build-depends:+ base >= 4.16.4 && < 4.17,+ pandoc-types >= 1.22.2 && < 1.23+ ghc-options: -Wall -Wunused-packages++library+ import: common-stuff+ hs-source-dirs: src+ exposed-modules: Text.Pandoc.Filters.Columns+ build-depends:+ pandoc >= 2.19.2 && < 2.20++executable pandoc-columns+ import: common-stuff+ hs-source-dirs: app+ main-is: Main.hs+ build-depends:+ pandoc-columns+
+ src/Text/Pandoc/Filters/Columns.hs view
@@ -0,0 +1,58 @@+{-|+Module : Columns+Description : Pandoc filter to support columns in Markdown.+Copyright : (c) 2020-2023 Amy de Buitléir+License : BSD--3+Maintainer : amy@nualeargais.ie+Stability : experimental+Portability : POSIX++See <https://github.com/mhwombat/pandoc-linear-table> for information+on how to use this filter.+-}++{-# LANGUAGE OverloadedStrings #-}+module Text.Pandoc.Filters.Columns+ (+ transform,+ formatColumns+ ) where++import Text.Pandoc qualified as P+import Text.Pandoc.Walk (walk)+++-- | A transformation that can be used with Hakyll.+transform :: P.Pandoc -> P.Pandoc+transform = walk formatColumns++formatColumns :: P.Block -> P.Block+formatColumns (P.Div attr@(_,["columns"],_) bs)+ = P.Table attr defaultTableCaption colSpecs+ defaultTableHeader [body]+ defaultTableFooter+ where body = blocksToTableBody bs+ colSpecs = map (const defaultColSpec) bs+formatColumns b = b++blocksToTableBody :: [P.Block] -> P.TableBody+blocksToTableBody bs = P.TableBody P.nullAttr (P.RowHeadColumns 0) [] [row]+ where row = blocksToTableRow bs++blocksToTableRow :: [P.Block] -> P.Row+blocksToTableRow = P.Row P.nullAttr . map blockToCell++blockToCell :: P.Block -> P.Cell+blockToCell b = P.Cell P.nullAttr P.AlignDefault (P.RowSpan 1) (P.ColSpan 1) [b]++defaultColSpec :: P.ColSpec+defaultColSpec = (P.AlignDefault, P.ColWidthDefault)++defaultTableCaption :: P.Caption+defaultTableCaption = P.Caption Nothing []++defaultTableHeader :: P.TableHead+defaultTableHeader = P.TableHead P.nullAttr []++defaultTableFooter :: P.TableFoot+defaultTableFooter = P.TableFoot P.nullAttr []