diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-23 00:19:37 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-23 00:19:37 +0000 |
commit | 1296273c8577465a1bb17161909c2596f84c8bd8 (patch) | |
tree | 513616ccf4b72844262f43b76f820f9cff1cecfb /src/Text/Pandoc | |
parent | caef362065f3965107b0d5619b5d7bbb3d3b1889 (diff) | |
download | pandoc-1296273c8577465a1bb17161909c2596f84c8bd8.tar.gz |
Added support for definition lists to LaTeX reader.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@780 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 471417458..91462caca 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -39,6 +39,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Shared import Data.Maybe ( fromMaybe ) import Data.Char ( chr ) +import Data.List ( isPrefixOf, isSuffixOf ) -- | Parse LaTeX from string and return 'Pandoc' document. readLaTeX :: ParserState -- ^ Parser state, including options for parser @@ -228,33 +229,45 @@ mathBlockWith start end = try (do -- list blocks -- -list = bulletList <|> orderedList <?> "list" +list = bulletList <|> orderedList <|> definitionList <?> "list" -listItem = try (do - ("item", _, _) <- command +listItem = try $ do + ("item", _, args) <- command spaces state <- getState let oldParserContext = stateParserContext state updateState (\state -> state {stateParserContext = ListItemState}) blocks <- many block updateState (\state -> state {stateParserContext = oldParserContext}) - return blocks) + opt <- case args of + ([x]) | "[" `isPrefixOf` x && "]" `isSuffixOf` x -> + parseFromString (many inline) $ tail $ init x + _ -> return [] + return (opt, blocks) -orderedList = try (do +orderedList = try $ do begin "enumerate" spaces items <- many listItem end "enumerate" spaces - return (OrderedList items)) + return (OrderedList $ map snd items) -bulletList = try (do +bulletList = try $ do begin "itemize" spaces items <- many listItem end "itemize" spaces - return (BulletList items)) + return (BulletList $ map snd items) + +definitionList = try $ do + begin "description" + spaces + items <- many listItem + end "description" + spaces + return (DefinitionList items) -- -- paragraph block @@ -353,9 +366,8 @@ unknownEnvironment = try (do return result) unknownCommand = try (do - notFollowedBy' (string "\\end{itemize}") - notFollowedBy' (string "\\end{enumerate}") - notFollowedBy' (string "\\end{document}") + notFollowedBy' $ choice $ map end + ["itemize", "enumerate", "description", "document"] (name, star, args) <- command spaces let argStr = concat args |