-- |
-- SPDX-License-Identifier: BSD-3-Clause
--
-- Utilities for generating doc markup
module Swarm.Doc.Wiki.Util where

import Control.Arrow (left)
import Data.Text (Text)
import Text.Pandoc

pandocToText :: Pandoc -> Either Text Text
pandocToText :: Pandoc -> Either Text Text
pandocToText =
  (PandocError -> Text)
-> Either PandocError Text -> Either Text Text
forall b c d. (b -> c) -> Either b d -> Either c d
forall (a :: * -> * -> *) b c d.
ArrowChoice a =>
a b c -> a (Either b d) (Either c d)
left PandocError -> Text
renderError
    (Either PandocError Text -> Either Text Text)
-> (Pandoc -> Either PandocError Text)
-> Pandoc
-> Either Text Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PandocPure Text -> Either PandocError Text
forall a. PandocPure a -> Either PandocError a
runPure
    (PandocPure Text -> Either PandocError Text)
-> (Pandoc -> PandocPure Text) -> Pandoc -> Either PandocError Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WriterOptions -> Pandoc -> PandocPure Text
forall (m :: * -> *).
PandocMonad m =>
WriterOptions -> Pandoc -> m Text
writeMarkdown (WriterOptions
forall a. Default a => a
def {writerExtensions = extensionsFromList [Ext_pipe_tables]})