diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2016-05-30 17:30:04 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2016-06-02 15:30:21 +0200 |
commit | 729fca311fed275a8000d2ce3789d985133c34fc (patch) | |
tree | 41df1ba370ee4b59b7e7fbb60b92c3e390b51939 /src/Text | |
parent | 512bf2eebf5d59916b1154ef2025d776b367c035 (diff) | |
download | pandoc-729fca311fed275a8000d2ce3789d985133c34fc.tar.gz |
Org reader: drop unused field from parser state
The `OrgParserState` contained both an `orgStateMeta` and
`orgStateMeta'` field, the former for plain meta information and the
latter for F-monad wrapped meta info. The plain meta info is only used
to make `OrgParserState` an instance of the `HasMeta` class, which in
turn is never used in the reader. The (F Meta) version is hence renamed
to the "un-primed" version while the other one is dropped.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Blocks.hs | 11 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/ParserState.hs | 15 |
2 files changed, 8 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs index e26beffdc..52db466a4 100644 --- a/src/Text/Pandoc/Readers/Org/Blocks.hs +++ b/src/Text/Pandoc/Readers/Org/Blocks.hs @@ -69,7 +69,7 @@ blockList = do meta :: OrgParser Meta meta = do st <- getState - return $ runF (orgStateMeta' st) st + return $ runF (orgStateMeta st) st blocks :: OrgParser (F Blocks) blocks = mconcat <$> manyTill block eof @@ -462,12 +462,11 @@ commentLine = commentLineStart *> anyLine *> pure mempty declarationLine :: OrgParser () declarationLine = try $ do - key <- metaKey - inlinesF <- metaInlines + key <- metaKey + value <- metaInlines updateState $ \st -> - let meta' = B.setMeta <$> pure key <*> inlinesF <*> pure nullMeta - in st { orgStateMeta' = orgStateMeta' st <> meta' } - return () + let meta' = B.setMeta key <$> value <*> pure nullMeta + in st { orgStateMeta = orgStateMeta st <> meta' } metaInlines :: OrgParser (F MetaValue) metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs index e648a883e..cadc9bfb7 100644 --- a/src/Text/Pandoc/Readers/Org/ParserState.hs +++ b/src/Text/Pandoc/Readers/Org/ParserState.hs @@ -54,8 +54,7 @@ import Data.Default (Default(..)) import qualified Data.Map as M import qualified Data.Set as Set -import Text.Pandoc.Builder ( Inlines, Blocks, HasMeta(..), - trimInlines ) +import Text.Pandoc.Builder ( Inlines, Blocks, trimInlines ) import Text.Pandoc.Definition ( Meta(..), nullMeta ) import Text.Pandoc.Options ( ReaderOptions(..) ) import Text.Pandoc.Parsing ( HasHeaderMap(..) @@ -96,8 +95,7 @@ data OrgParserState = OrgParserState , orgStateLastPreCharPos :: Maybe SourcePos , orgStateLastStrPos :: Maybe SourcePos , orgStateLinkFormatters :: OrgLinkFormatters - , orgStateMeta :: Meta - , orgStateMeta' :: F Meta + , orgStateMeta :: F Meta , orgStateNotes' :: OrgNoteTable , orgStateParserContext :: ParserContext , orgStateIdentifiers :: Set.Set String @@ -112,12 +110,6 @@ instance Default OrgParserLocal where instance HasReaderOptions OrgParserState where extractReaderOptions = orgStateOptions -instance HasMeta OrgParserState where - setMeta field val st = - st{ orgStateMeta = setMeta field val $ orgStateMeta st } - deleteMeta field st = - st{ orgStateMeta = deleteMeta field $ orgStateMeta st } - instance HasLastStrPosition OrgParserState where getLastStrPos = orgStateLastStrPos setLastStrPos pos st = st{ orgStateLastStrPos = Just pos } @@ -151,8 +143,7 @@ defaultOrgParserState = OrgParserState , orgStateLastPreCharPos = Nothing , orgStateLastStrPos = Nothing , orgStateLinkFormatters = M.empty - , orgStateMeta = nullMeta - , orgStateMeta' = return nullMeta + , orgStateMeta = return nullMeta , orgStateNotes' = [] , orgStateParserContext = NullState , orgStateIdentifiers = Set.empty |