packages feed

orchid 0.0.7 → 0.0.8

raw patch · 6 files changed

+146/−98 lines, 6 filesdep +fclabelsdep +salvia-extrasdep −directorydep −utf8-stringdep ~QuickCheckdep ~basedep ~bytestring

Dependencies added: fclabels, salvia-extras

Dependencies removed: directory, utf8-string

Dependency ranges changed: QuickCheck, base, bytestring, containers, encoding, extensible-exceptions, filestore, hscolour, mtl, nano-md5, parsec, process, salvia, stm, time, unix, xml

Files

orchid.cabal view
@@ -1,33 +1,33 @@ Name:             orchid-Version:          0.0.7+Version:          0.0.8 Description:      Haskell Wiki Library Synopsis:         Haskell Wiki Library Category:         Network, Web+Cabal-version:    >= 1.6 License:          BSD3 License-file:     LICENSE Author:           Sebastiaan Visser Maintainer:       sfvisser@cs.uu.nl Build-Type:       Simple-Build-Depends:    base,-                  bytestring,-                  salvia == 0.0.5,-                  xml,-                  extensible-exceptions,-                  containers,-                  QuickCheck,-                  parsec <= 2.1.0.1,-                  time,-                  mtl ==1.1.0.2,-                  stm,-                  process,-                  unix,-                  nano-md5,-                  filestore,-                  hscolour,-                  encoding,-                  utf8-string,-                  directory-+Build-Depends:    base ==3.0.*,+                  bytestring == 0.9.*,+                  salvia == 0.1.*,+                  salvia-extras == 0.1.*,+                  xml ==1.3.*,+                  extensible-exceptions ==0.1.*,+                  containers ==0.2.*,+                  QuickCheck ==2.1.*,+                  parsec ==3.0.*,+                  fclabels ==0.1.*,+                  mtl ==1.1.*,+                  filestore ==0.2.*,+                  encoding ==0.5.*,+                  time ==1.1.*,+                  stm ==2.1.*,+                  process ==1.0.*,+                  unix ==2.3.*,+                  nano-md5 ==0.1.*,+                  hscolour ==1.11.* GHC-Options:      -fglasgow-exts -threaded Extensions:       CPP HS-Source-Dirs:   src
src/Network/Orchid/Core/Handler.hs view
@@ -16,16 +16,16 @@ import Network.Orchid.FormatRegister (wikiFormats) import Network.Protocol.Http (Method (..), Status (..), uri) import Network.Protocol.Uri ((/+), URI(..), path)-import Network.Salvia.Advanced.ExtendedFileSystem (hExtendedFileSystem)-import Network.Salvia.Handlers.Directory (hDirectory, hDirectoryResource)-import Network.Salvia.Handlers.Error (hError)-import Network.Salvia.Handlers.File (hFileResource)-import Network.Salvia.Handlers.File (hUri)-import Network.Salvia.Handlers.FileSystem (hFileSystem, hFileTypeDispatcher)-import Network.Salvia.Handlers.Login-import Network.Salvia.Handlers.MethodRouter (hPOST, hMethodRouter)-import Network.Salvia.Handlers.PathRouter (hPrefix, hPath, hPathRouter)-import Network.Salvia.Handlers.Rewrite (hWithoutDir)+import Network.Salvia.Handler.ExtendedFileSystem (hExtendedFileSystem)+import Network.Salvia.Handler.Directory (hDirectory, hDirectoryResource)+import Network.Salvia.Handler.Error (hError)+import Network.Salvia.Handler.File (hFileResource)+import Network.Salvia.Handler.File (hUri)+import Network.Salvia.Handler.FileSystem (hFileSystem, hFileTypeDispatcher)+import Network.Salvia.Handler.Login+import Network.Salvia.Handler.MethodRouter (hPOST, hMethodRouter)+import Network.Salvia.Handler.PathRouter (hPrefix, hPath, hPathRouter)+import Network.Salvia.Handler.Rewrite (hWithoutDir) import Network.Salvia.Httpd (Handler, request) import Paths_orchid @@ -41,12 +41,13 @@ hRepository :: Show a => FileStoreType -> FilePath -> FilePath -> UserDatabase b -> TUserSession a -> Handler () hRepository kind repo workDir userdb session =   let fs = mkFileStore kind repo in-    hPath "/search" (hAuthorized userdb "search" (\_ -> hPOST $ hWikiSearch fs) session)+    hPath "/search" (hAuthorized userdb "search" (\_ -> const () `fmap` (hPOST $ hWikiSearch fs)) session)   $ hPrefix "/_" (hFileSystem (repo /+ "_"))-  $ hFileTypeDispatcher repo hDirectoryResource-  $ const+  $ hFileTypeDispatcher hDirectoryResource+  ( const   $ hWithoutDir repo-  $ hWikiREST workDir userdb session fs+  $ hWikiREST workDir userdb session fs)+  repo   hViewer :: FilePath -> Handler () hViewer dir = do@@ -72,10 +73,10 @@ authHandlers tuserdb session handler = do   userdb <- lift . atomically $ readTVar tuserdb   hPathRouter [-      ("/loginfo", hAuthorized userdb "loginfo" (const $ hLoginfo session) session)-    , ("/login",   hPOST $ hLogin userdb session)-    , ("/logout",  hPOST $ hLogout session)-    , ("/signup",  hAuthorized userdb "signup" (const $ hPOST $ hSignup tuserdb ["loginfo", "show", "edit", "create"]) session)+      ("/loginfo", (hAuthorized userdb "loginfo" (const $ hLoginfo session) session) >> return ())+    , ("/login",   (hPOST $ hLogin userdb session) >> return ())+    , ("/logout",  (hPOST $ hLogout session) >> return ())+    , ("/signup",   hAuthorized userdb "signup" (const (hPOST (hSignup tuserdb ["loginfo", "show", "edit", "create"]) >> return ())) session)     ] handler  -------- REST interface -------------------------------------------------------
src/Network/Orchid/Core/Liaison.hs view
@@ -8,7 +8,7 @@ import Control.Applicative ((<$>)) import Control.Exception.Extensible (try) import Control.Monad.State (gets, lift)-import Data.Encoding (encodeLazy)+import Data.Encoding (encodeLazyByteString) import Data.Encoding.UTF8 (UTF8 (..)) import Data.FileStore hiding (NotFound) import Data.List (find, intercalate)@@ -17,11 +17,11 @@ import Network.Orchid.FormatRegister import Network.Protocol.Http import Network.Protocol.Uri-import Network.Salvia.Handlers.Error (safeIO, hError, hCustomError)-import Network.Salvia.Handlers.File ()-import Network.Salvia.Handlers.Login (User, username, email)-import Network.Salvia.Handlers.MethodRouter ()-import Network.Salvia.Handlers.PathRouter ()+import Network.Salvia.Handler.Error (safeIO, hError, hCustomError)+import Network.Salvia.Handler.File ()+import Network.Salvia.Handler.Login (User, username, email)+import Network.Salvia.Handler.MethodRouter ()+import Network.Salvia.Handler.PathRouter () import Network.Salvia.Httpd (Handler, UriHandler, sendBs, sendStr, request, response, contentsUtf8, uriEncodedPostParamsUTF8) import Misc.Commons (safeRead) import qualified Data.ByteString.Lazy as B@@ -61,7 +61,7 @@     Just s -> do       b <- lift $ (handler fmt) filestore workDir src s       (body, enc) <- return $ case b of-        TextOutput   s  -> (encodeLazy UTF8 s, Just utf8)+        TextOutput   s  -> (encodeLazyByteString UTF8 s, Just utf8)         BinaryOutput bs -> (bs, Nothing)        enterM response $ do
src/Text/Document/Core/Type.hs view
@@ -13,7 +13,10 @@ import Misc.Commons (fmap2, intersperseS, concatMapS, unlinesS, concatS, eolS, ss) import qualified Text.Xhtml.Xhtml as H -data LinkType = Internal | External | Reference+data LinkType =+    Internal+  | External+  | Reference   deriving (Eq, Show)  @@ -28,6 +31,7 @@ mapping    = Block_Mapping verbatim   = Block_Verbatim comment    = Block_Comment+include    = Block_Include anchor_    = Block_Anchor caption    = Block_Caption plugin     = Block_Plugin@@ -319,6 +323,8 @@          child comment        : {String}       alternative Enum:          child items          : Blocks +      alternative Include:+         child document       : {String}       alternative List:          child items          : Blocks        alternative Mapping:@@ -326,8 +332,7 @@       alternative Paragraph:          child paragraph      : Inline        alternative Plugin:-         child plugin         : {( PrettyPrinter Document-                             , Processor Document Syn_Document)}+         child plugin         : {(PrettyPrinter Document, Processor Document Syn_Document)}       alternative Verbatim:          child verbatim       : Block  -}@@ -336,11 +341,11 @@             | Block_Caption (Inline) (Block)              | Block_Comment (String)              | Block_Enum (Blocks) +            | Block_Include (String)              | Block_List (Blocks)              | Block_Mapping (Pairs)              | Block_Paragraph (Inline) -            | Block_Plugin (( PrettyPrinter Document-                                                         , Processor Document Syn_Document)) +            | Block_Plugin ((PrettyPrinter Document, Processor Document Syn_Document))              | Block_Verbatim (Block)              deriving ( Eq,Show) -- cata@@ -356,6 +361,8 @@     (sem_Block_Comment _comment ) sem_Block (Block_Enum _items )  =     (sem_Block_Enum (sem_Blocks _items ) )+sem_Block (Block_Include _document )  =+    (sem_Block_Include _document ) sem_Block (Block_List _items )  =     (sem_Block_List (sem_Blocks _items ) ) sem_Block (Block_Mapping _pairs )  =@@ -392,10 +399,10 @@               _contentsIprocessors :: ([Processor Document Syn_Document])               _contentsIxhtml :: Node               _contentsIxml :: (XL.Content)-              -- "src/Text/Document/Printer/Xhtml.ag"(line 89, column 16)+              -- "src/Text/Document/Printer/Xhtml.ag"(line 90, column 16)               _lhsOxhtml =                   nameAnchor name_ _contentsIxhtml-              -- "src/Text/Document/Printer/Xml.ag"(line 87, column 16)+              -- "src/Text/Document/Printer/Xml.ag"(line 88, column 16)               _lhsOxml =                   xmlElem "anchor"    [xmlText name_, _contentsIxml]               -- "src/Text/Document/Printer/Latex.ag"(line 108, column 16)@@ -458,10 +465,10 @@               _contentsIprocessors :: ([Processor Document Syn_Document])               _contentsIxhtml :: Node               _contentsIxml :: (XL.Content)-              -- "src/Text/Document/Printer/Xhtml.ag"(line 90, column 16)+              -- "src/Text/Document/Printer/Xhtml.ag"(line 91, column 16)               _lhsOxhtml =                   classDiv "caption" $ nodeset [(classDiv "caption-label" _captionIxhtml), _contentsIxhtml]-              -- "src/Text/Document/Printer/Xml.ag"(line 88, column 16)+              -- "src/Text/Document/Printer/Xml.ag"(line 89, column 16)               _lhsOxml =                   xmlElem "caption"   [_captionIxml, _contentsIxml]               -- "src/Text/Document/Printer/Latex.ag"(line 109, column 16)@@ -489,10 +496,10 @@               -- "src/Text/Document/Printer/Xhtml.ag"(line 88, column 16)               _lhsOxhtml =                   H.text comment_-              -- "src/Text/Document/Printer/Xml.ag"(line 86, column 16)+              -- "src/Text/Document/Printer/Xml.ag"(line 87, column 16)               _lhsOxml =                   xmlElem "comment"   [xmlText comment_]-              -- "src/Text/Document/Printer/Latex.ag"(line 110, column 16)+              -- "src/Text/Document/Printer/Latex.ag"(line 111, column 16)               _lhsOlatex =                   ss comment_               -- use rule "src/Text/Document/Core/Processing.ag"(line 9, column 20)@@ -530,6 +537,27 @@               ( _itemsIlatex,_itemsIprocessors,_itemsIxhtml,_itemsIxml) =                   (items_ _itemsOsem )           in  ( _lhsOlatex,_lhsOprocessors,_lhsOxhtml,_lhsOxml)))+sem_Block_Include :: String ->+                     T_Block +sem_Block_Include document_  =+    (\ _lhsIsem ->+         (let _lhsOxhtml :: Node+              _lhsOxml :: (XL.Content)+              _lhsOlatex :: ShowS+              _lhsOprocessors :: ([Processor Document Syn_Document])+              -- "src/Text/Document/Printer/Xhtml.ag"(line 89, column 16)+              _lhsOxhtml =+                  classDiv "include" $ nodeset [H.text document_]+              -- "src/Text/Document/Printer/Xml.ag"(line 86, column 16)+              _lhsOxml =+                  xmlElem "include"   [xmlText document_]+              -- "src/Text/Document/Printer/Latex.ag"(line 110, column 16)+              _lhsOlatex =+                  ss "-- todo Include --"+              -- use rule "src/Text/Document/Core/Processing.ag"(line 9, column 20)+              _lhsOprocessors =+                  []+          in  ( _lhsOlatex,_lhsOprocessors,_lhsOxhtml,_lhsOxml))) sem_Block_List :: T_Blocks  ->                   T_Block  sem_Block_List items_  =@@ -617,8 +645,7 @@               ( _paragraphIlatex,_paragraphIxhtml,_paragraphIxml) =                   (paragraph_ )           in  ( _lhsOlatex,_lhsOprocessors,_lhsOxhtml,_lhsOxml)))-sem_Block_Plugin :: (( PrettyPrinter Document-                                                  , Processor Document Syn_Document)) ->+sem_Block_Plugin :: ((PrettyPrinter Document, Processor Document Syn_Document)) ->                     T_Block  sem_Block_Plugin plugin_  =     (\ _lhsIsem ->@@ -626,13 +653,13 @@               _lhsOxml :: (XL.Content)               _lhsOlatex :: ShowS               _lhsOprocessors :: ([Processor Document Syn_Document])-              -- "src/Text/Document/Printer/Xhtml.ag"(line 91, column 16)+              -- "src/Text/Document/Printer/Xhtml.ag"(line 92, column 16)               _lhsOxhtml =                   xhtmlPlugin (fst plugin_) _lhsIsem-              -- "src/Text/Document/Printer/Xml.ag"(line 89, column 16)+              -- "src/Text/Document/Printer/Xml.ag"(line 90, column 16)               _lhsOxml =                   xmlElem "plugin"    [xmlPlugin (fst plugin_) _lhsIsem]-              -- "src/Text/Document/Printer/Latex.ag"(line 111, column 16)+              -- "src/Text/Document/Printer/Latex.ag"(line 112, column 16)               _lhsOlatex =                   texPlugin (fst plugin_) _lhsIsem               -- "src/Text/Document/Core/Processing.ag"(line 11, column 20)@@ -1109,13 +1136,13 @@          _emphIlatex :: ShowS          _emphIxhtml :: Node          _emphIxml :: (XL.Content)-         -- "src/Text/Document/Printer/Xhtml.ag"(line 97, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 98, column 16)          _lhsOxhtml =              H.emph _emphIxhtml-         -- "src/Text/Document/Printer/Xml.ag"(line 98, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 99, column 16)          _lhsOxml =              xmlElem "emph"   [_emphIxml]-         -- "src/Text/Document/Printer/Latex.ag"(line 117, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 118, column 16)          _lhsOlatex =              texEmph _emphIlatex          ( _emphIlatex,_emphIxhtml,_emphIxml) =@@ -1130,13 +1157,13 @@          _fixedIlatex :: ShowS          _fixedIxhtml :: Node          _fixedIxml :: (XL.Content)-         -- "src/Text/Document/Printer/Xhtml.ag"(line 99, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 100, column 16)          _lhsOxhtml =              tt _fixedIxhtml-         -- "src/Text/Document/Printer/Xml.ag"(line 100, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 101, column 16)          _lhsOxml =              xmlElem "fixed"  [_fixedIxml]-         -- "src/Text/Document/Printer/Latex.ag"(line 119, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 120, column 16)          _lhsOlatex =              texFixed _fixedIlatex          ( _fixedIlatex,_fixedIxhtml,_fixedIxml) =@@ -1151,13 +1178,13 @@          _noteIlatex :: ShowS          _noteIxhtml :: Node          _noteIxml :: (XL.Content)-         -- "src/Text/Document/Printer/Xhtml.ag"(line 101, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 102, column 16)          _lhsOxhtml =              classSpan "footnote" _noteIxhtml-         -- "src/Text/Document/Printer/Xml.ag"(line 106, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 107, column 16)          _lhsOxml =              xmlElem "footnote" [_noteIxml]-         -- "src/Text/Document/Printer/Latex.ag"(line 123, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 124, column 16)          _lhsOlatex =              texFootnote _noteIlatex          ( _noteIlatex,_noteIxhtml,_noteIxml) =@@ -1170,16 +1197,16 @@     (let _lhsOxhtml :: Node          _lhsOxml :: (XL.Content)          _lhsOlatex :: ShowS-         -- "src/Text/Document/Printer/Xhtml.ag"(line 95, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 96, column 16)          _lhsOxhtml =              img source_ description_-         -- "src/Text/Document/Printer/Xml.ag"(line 93, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 94, column 16)          _lhsOxml =              xmlElem "image" [                xmlElem "source"      [xmlText source_]              , xmlElem "description" [xmlText description_]              ]-         -- "src/Text/Document/Printer/Latex.ag"(line 115, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 116, column 16)          _lhsOlatex =              ss "todo"      in  ( _lhsOlatex,_lhsOxhtml,_lhsOxml))@@ -1192,13 +1219,13 @@          _linesIlatex :: ([ShowS])          _linesIxhtml :: NodeSet          _linesIxml :: ([XL.Content])-         -- "src/Text/Document/Printer/Xhtml.ag"(line 94, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 95, column 16)          _lhsOxhtml =              nodeset _linesIxhtml-         -- "src/Text/Document/Printer/Xml.ag"(line 92, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 93, column 16)          _lhsOxml =              xmlElem "lines" _linesIxml-         -- "src/Text/Document/Printer/Latex.ag"(line 114, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 115, column 16)          _lhsOlatex =              concatS _linesIlatex          ( _linesIlatex,_linesIxhtml,_linesIxml) =@@ -1215,17 +1242,17 @@          _descriptionIlatex :: ShowS          _descriptionIxhtml :: Node          _descriptionIxml :: (XL.Content)-         -- "src/Text/Document/Printer/Xhtml.ag"(line 100, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 101, column 16)          _lhsOxhtml =              xhtmlLink kind_ (linkAnchor kind_ ref_) _descriptionIxhtml-         -- "src/Text/Document/Printer/Xml.ag"(line 101, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 102, column 16)          _lhsOxml =              xmlElem "link" [                xmlElem "ref"         [xmlText ref_]              , xmlElem "kind"        [xmlText (show kind_)]              , xmlElem "description" [_descriptionIxml]              ]-         -- "src/Text/Document/Printer/Latex.ag"(line 120, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 121, column 16)          _lhsOlatex =              if kind_ == External              then texLink ref_ _descriptionIlatex@@ -1242,13 +1269,13 @@          _quoteIlatex :: ShowS          _quoteIxhtml :: Node          _quoteIxml :: (XL.Content)-         -- "src/Text/Document/Printer/Xhtml.ag"(line 102, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 103, column 16)          _lhsOxhtml =              cite _quoteIxhtml-         -- "src/Text/Document/Printer/Xml.ag"(line 107, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 108, column 16)          _lhsOxml =              xmlElem "quote"    [_quoteIxml]-         -- "src/Text/Document/Printer/Latex.ag"(line 124, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 125, column 16)          _lhsOlatex =              ss "-- todo Quote --"          ( _quoteIlatex,_quoteIxhtml,_quoteIxml) =@@ -1263,13 +1290,13 @@          _strongIlatex :: ShowS          _strongIxhtml :: Node          _strongIxml :: (XL.Content)-         -- "src/Text/Document/Printer/Xhtml.ag"(line 98, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 99, column 16)          _lhsOxhtml =              H.strong _strongIxhtml-         -- "src/Text/Document/Printer/Xml.ag"(line 99, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 100, column 16)          _lhsOxml =              xmlElem "strong" [_strongIxml]-         -- "src/Text/Document/Printer/Latex.ag"(line 118, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 119, column 16)          _lhsOlatex =              texStrong _strongIlatex          ( _strongIlatex,_strongIxhtml,_strongIxml) =@@ -1281,13 +1308,13 @@     (let _lhsOxhtml :: Node          _lhsOxml :: (XL.Content)          _lhsOlatex :: ShowS-         -- "src/Text/Document/Printer/Xhtml.ag"(line 96, column 16)+         -- "src/Text/Document/Printer/Xhtml.ag"(line 97, column 16)          _lhsOxhtml =              H.text text_-         -- "src/Text/Document/Printer/Xml.ag"(line 97, column 16)+         -- "src/Text/Document/Printer/Xml.ag"(line 98, column 16)          _lhsOxml =              xmlText text_-         -- "src/Text/Document/Printer/Latex.ag"(line 116, column 16)+         -- "src/Text/Document/Printer/Latex.ag"(line 117, column 16)          _lhsOlatex =              ss (escapeTex text_)      in  ( _lhsOlatex,_lhsOxhtml,_lhsOxml))
src/Text/Document/Parser/Wiki.hs view
@@ -103,14 +103,12 @@     either (text . show) id   $ parse pLines "" ('\0' : xs ++ "\0") -pInline :: Level -> GenParser Char st (Int, Inline)+pInline :: Int -> GenParser Char st (Int, Inline) pInline n = fmap2 id (parseInline . trimText) <$> pText n  -------[ structural parsers ]-------------------------------------------------- -type Level = Int--pSections :: Level -> Bool -> GenParser Char () (Level, SectionContents)+pSections :: Int -> Bool -> GenParser Char () (Int, SectionContents) pSections n forceTitle = do    -- Based on the `forceTitle' flag we parse or try to parse a title.@@ -149,6 +147,7 @@  pBlock n =       try (pPlugin        n)+  <|> try (pInclude       n)   <|> try (pAnchor        n)   <|> try (pCaption       n)   <|> try (pMapping       n)@@ -180,6 +179,16 @@   (_, i) <- pInline 0   (_, b) <- pBlock n'   return $ (n', caption i b)++pInclude n = do+  n' <- pIndent' n+  i <- pInclude'+  many pEmptyLineEol+  return $ (n', i)++pInclude' = (\a f -> include (f a))+       <$> (string "[*" *> many (noneOf "|]")) <*> href <* char ']'+  where href = option id (const <$> (char '|' *> many (noneOf "]")))  pParagraph n = fmap2 id paragraph <$> pInline n 
src/Text/Document/Parser/WikiHelper.hs view
@@ -2,7 +2,9 @@  import Control.Applicative import Data.List (intercalate)-import Text.ParserCombinators.Parsec hiding (many, optional, (<|>))+import Text.Parsec.Char+import Text.Parsec.Combinator+import Text.Parsec.Prim hiding (many, (<|>))  import Network.Protocol.Uri import Misc.Commons@@ -44,35 +46,43 @@ wss  = ws ++ eols  -- Parse end of line, \r\n or \n.+pEol :: Stream s m Char => ParsecT s u m String pEol = snoc <$> option "" (string "\r") <*> char '\n'  -- Parse a chunk of whitespace, no line endings.+pSpace :: Stream s m Char => ParsecT s u m String pSpace = many $ oneOf ws +-- Parse an empty line including the line ending.+pEmptyLineEol :: Stream s m Char => ParsecT s u m String+pEmptyLineEol = try ((++) <$> many (oneOf ws) <*> pEol)+ -- Try to parse at least level n indentation.+pIndent :: Stream s m Char => Int -> ParsecT s u m (Int, String) pIndent n = do   h <- try (many pEmptyLineEol)   i <- try (pMin n (oneOf ws))   return (length i, concat h ++ i) -- (\a -> (length a, a)) <$>  +pIndent' :: Stream s m Char => Int -> ParsecT s u m Int pIndent' n = fst <$> pIndent n --- Parse an empty line including the line ending.-pEmptyLineEol = try ((++) <$> many (oneOf ws) <*> pEol)- -- Parse a non empty line excluding the EOL character. +pNonEmptyLine :: Stream s m Char => ParsecT s u m String pNonEmptyLine = (++) <$> many (oneOf ws) <*> ((:) <$> noneOf wss <*> many (noneOf eols))  -- Parse a non empty line including the line ending.+pNonEmptyLineEol :: Stream s m Char => ParsecT s u m String pNonEmptyLineEol = (++) <$> pNonEmptyLine <*> (pEol <|> ("" <$ eof))  -- A string identifier not containing any whitespace.+pString :: Stream s m Char => ParsecT s u m String pString = many $ noneOf wss  -- Parse a block of text terminated by an empty line. -- todo: include ident space and reuse this function in pLevel. -pText :: Int -> GenParser Char st (Int, String)+pText :: Stream s m Char => Int -> ParsecT s u m (Int, String) pText n = do   h <- many pEmptyLineEol   (m, i) <- pIndent n@@ -81,5 +91,6 @@   return (m, concat (h ++ (i:b) ++ f))  -- Parse a block of text terminated by an empty line.+pLevel :: Stream s m Char => Int -> ParsecT s u m String pLevel n = concat . map snd <$> many (pText n)