diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-04 20:02:00 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-04 20:02:00 -0800 |
commit | 4257b9aff59c800e86658a64bd59101b11719967 (patch) | |
tree | c3b5d74cbbccc4ef187c4cf35cdb6ab58fed89de /src/Text | |
parent | 1fc57ed250da2e2ac0a7e56aa068ada844381ba1 (diff) | |
download | pandoc-4257b9aff59c800e86658a64bd59101b11719967.tar.gz |
Handle \address and \signature in letter environment. Closes #393.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 356462c98..5e49c9cc5 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -205,6 +205,9 @@ blockCommands = M.fromList , ("title", mempty <$ (tok >>= addTitle)) , ("subtitle", mempty <$ (tok >>= addSubtitle)) , ("author", mempty <$ authors) + -- in letter class, temp. store address & sig as title, author + , ("address", mempty <$ (tok >>= addTitle)) + , ("signature", mempty <$ authors) , ("date", mempty <$ (tok >>= addDate)) , ("maketitle", pure mempty) -- \ignore{} is used conventionally in literate haskell for definitions @@ -345,7 +348,7 @@ inlineCommands = M.fromList , (".", option (str ".") $ try $ tok >>= accent dot) , ("=", option (str "=") $ try $ tok >>= accent macron) , ("i", lit "i") - , ("\\", linebreak <$ optional (bracketed inline *> optional sp)) + , ("\\", linebreak <$ (optional (bracketed inline) *> optional sp)) , (",", pure mempty) , ("@", pure mempty) , (" ", lit "\160") @@ -620,7 +623,7 @@ rawLaTeXInline = do environments :: M.Map String (LP Blocks) environments = M.fromList [ ("document", env "document" blocks) - , ("letter", env "letter" blocks) + , ("letter", env "letter" letter_contents) , ("center", env "center" blocks) , ("tabular", env "tabular" simpTable) , ("quote", blockQuote <$> env "quote" blocks) @@ -649,6 +652,20 @@ environments = M.fromList , ("alignat*", mathEnv (Just "aligned*") "alignat*") ] +letter_contents :: LP Blocks +letter_contents = do + bs <- blocks + st <- getState + -- add signature (author) and address (title) + let addr = case stateTitle st of + [] -> mempty + x -> para $ fromList x + let sigs = case stateAuthors st of + [] -> mempty + xs -> para $ fromList $ intercalate [LineBreak] xs + updateState $ \s -> s{ stateAuthors = [], stateTitle = [] } + return $ addr <> bs <> sigs + item :: LP Blocks item = blocks *> controlSeq "item" *> optional opt *> blocks |