summaryrefslogtreecommitdiff
path: root/Text/Pandoc/Readers/Plain.hs
blob: 600e5f854589101a0dcd5f507b73fd4e9a20fd35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{- |
Module      :  Text.Pandoc.Readers.Plain
Maintainer  :  defanor <defanor@uberspace.net>
Stability   :  unstable
Portability :  portable
-}

{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Readers.Plain ( readPlain ) where

import Text.Pandoc.Definition
import Text.Pandoc.Error
import Data.List

-- | Reads plain text, always succeeding and producing a single
-- 'Plain' block.
readPlain :: String -> Either PandocError Pandoc
readPlain = Right . Pandoc mempty . pure . Plain .
  concatMap (\l -> (intersperse Space $ map Str $ words l) ++ [LineBreak]) . lines
  -- or Right . Pandoc mempty . pure . RawBlock "plain"