Fixed bug with $else$ in templates module.
We need to be sure we parse the else block even if the if condition is satisfied. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1724 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
dd210437f6
commit
f4e738a6a9
1 changed files with 11 additions and 11 deletions
|
@ -149,21 +149,21 @@ conditional = try $ do
|
|||
string ")$"
|
||||
-- if newline after the "if", then a newline after "endif" will be swallowed
|
||||
multiline <- option False $ try $ skipEndline >> return True
|
||||
ifContents <- liftM concat parseTemplate
|
||||
-- reset state for else block
|
||||
setState $ TemplateState pos vars
|
||||
elseContents <- option "" $ do try (string "$else$")
|
||||
when multiline $ optional skipEndline
|
||||
liftM concat parseTemplate
|
||||
string "$endif$"
|
||||
when multiline $ optional skipEndline
|
||||
let conditionSatisfied = case lookup id' vars of
|
||||
Nothing -> False
|
||||
Just "" -> False
|
||||
Just _ -> True
|
||||
contents <- if conditionSatisfied
|
||||
then liftM concat parseTemplate
|
||||
else do
|
||||
parseTemplate -- skip if part, then reset position
|
||||
setState $ TemplateState pos vars
|
||||
option "" $ do try (string "$else$")
|
||||
when multiline $ optional skipEndline
|
||||
liftM concat parseTemplate
|
||||
string "$endif$"
|
||||
when multiline $ optional skipEndline
|
||||
return contents
|
||||
return $ if conditionSatisfied
|
||||
then ifContents
|
||||
else elseContents
|
||||
|
||||
for :: GenParser Char TemplateState String
|
||||
for = try $ do
|
||||
|
|
Loading…
Add table
Reference in a new issue