git.iko.soy/typeable/pandoc
on master help sign in
Org reader: rename `parseInlines` to `inlines`

Having a function starting with `parse` in a parsing library is overly redundant. Let's use a nicer, shorter name more in line with the rest of the library.

commitbc82123122d0bcd99f1cda07e87eca0b88fa8bbb authorAlbert Krewinkel <albert@zeitkraut.de> dateSun 29 May 2016, 14:39 (10 years ago) parentf54873d
2 files changed+11−10
src/Text/Pandoc/Readers/Org/Blocks.hs+7−7 src/Text/Pandoc/Readers/Org/Inlines.hs+4−3
src/Text/Pandoc/Readers/Org/Blocks.hs+7−7
@@ -116,7 +116,7 @@ blockAttributes = try $ do
116116 let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv
117117 let name = lookup "NAME" kv
118118 caption' <- maybe (return Nothing)
119− (fmap Just . parseFromString parseInlines)
119+ (fmap Just . parseFromString inlines)
120120 caption
121121 kvAttrs' <- parseFromString keyValues . (++ "\n") $ fromMaybe mempty kvAttrs
122122 return $ BlockAttributes
@@ -217,7 +217,7 @@ verseBlock blkProp = try $ do
217217 ignHeaders
218218 content <- rawBlockContent blkProp
219219 fmap B.para . mconcat . intersperse (pure B.linebreak)
220− <$> mapM (parseFromString parseInlines) (map (++ "\n") . lines $ content)
220+ <$> mapM (parseFromString inlines) (map (++ "\n") . lines $ content)
221221
222222exportsCode :: [(String, String)] -> Bool
223223exportsCode attrs = not (("rundoc-exports", "none") `elem` attrs
@@ -618,10 +618,10 @@ header = try $ do
618618 title <- manyTill inline (lookAhead $ optional headerTags <* newline)
619619 tags <- option [] headerTags
620620 newline
621+ let text = tagTitle title tags
621622 propAttr <- option nullAttr (keyValuesToAttr <$> propertiesDrawer)
622− inlines <- runF (tagTitle title tags) <$> getState
623− attr <- registerHeader propAttr inlines
624− return $ pure (B.headerWith attr level inlines)
623+ attr <- registerHeader propAttr (runF text def)
624+ return (B.headerWith attr level <$> text)
625625 where
626626 tagTitle :: [F Inlines] -> [String] -> F Inlines
627627 tagTitle title tags = trimInlinesF . mconcat $ title <> map tagToInlineF tags
@@ -799,7 +799,7 @@ noteBlock = try $ do
799799-- Paragraphs or Plain text
800800paraOrPlain :: OrgParser (F Blocks)
801801paraOrPlain = try $ do
802− ils <- parseInlines
802+ ils <- inlines
803803 nl <- option False (newline *> return True)
804804 -- Read block as paragraph, except if we are in a list context and the block
805805 -- is directly followed by a list item, in which case the block is read as
@@ -858,7 +858,7 @@ definitionListItem parseMarkerGetLength = try $ do
858858 line1 <- anyLineNewline
859859 blank <- option "" ("\n" <$ blankline)
860860 cont <- concat <$> many (listContinuation markerLength)
861− term' <- parseFromString parseInlines term
861+ term' <- parseFromString inlines term
862862 contents' <- parseFromString blocks $ line1 ++ blank ++ cont
863863 return $ (,) <$> term' <*> fmap (:[]) contents'
864864 where
src/Text/Pandoc/Readers/Org/Inlines.hs+4−3
@@ -28,8 +28,8 @@ Parsers for Org-mode inline elements.
2828-}
2929module Text.Pandoc.Readers.Org.Inlines
3030 ( inline
31+ , inlines
3132 , addToNotesTable
32− , parseInlines
3333 , isImageFilename
3434 , linkTarget
3535 ) where
@@ -145,8 +145,9 @@ inline =
145145 ] <* (guard =<< newlinesCountWithinLimits)
146146 <?> "inline"
147147
148−parseInlines :: OrgParser (F Inlines)
149−parseInlines = trimInlinesF . mconcat <$> many1 inline
148+-- | Read the rest of the input as inlines.
149+inlines :: OrgParser (F Inlines)
150+inlines = trimInlinesF . mconcat <$> many1 inline
150151
151152-- treat these as potentially non-text when parsing inline:
152153specialChars :: [Char]