git.iko.soy/typeable/pandoc
on master help sign in
Org reader: end footnotes after two blank lines
f176ad6Albert Krewinkel
src/Text/Pandoc/Readers/Org/Blocks.hs+5−4
@@ -724,13 +724,14 @@ latexEnd envName = try $
724noteBlock :: PandocMonad m => OrgParser m (F Blocks)
724noteBlock :: PandocMonad m => OrgParser m (F Blocks)
725noteBlock = try $ do
725noteBlock = try $ do
726 ref <- noteMarker <* skipSpaces <* updateLastPreCharPos
726 ref <- noteMarker <* skipSpaces <* updateLastPreCharPos
727− content <- mconcat <$> blocksTillHeaderOrNote
727+ content <- mconcat <$> many1Till block endOfFootnote
728 addToNotesTable (ref, content)
728 addToNotesTable (ref, content)
729 return mempty
729 return mempty
730 where
730 where
731− blocksTillHeaderOrNote =
731+ endOfFootnote = eof
732− many1Till block (eof <|> () <$ lookAhead noteMarker
732+ <|> () <$ lookAhead noteMarker
733− <|> () <$ lookAhead headerStart)
733+ <|> () <$ lookAhead headerStart
734+ <|> () <$ lookAhead (try $ blankline *> blankline)
734
735
735-- Paragraphs or Plain text
736-- Paragraphs or Plain text
736paraOrPlain :: PandocMonad m => OrgParser m (F Blocks)
737paraOrPlain :: PandocMonad m => OrgParser m (F Blocks)
test/Tests/Readers/Org.hs+74−59
@@ -1086,67 +1086,82 @@ tests =
1086 para (image "guess.jpg" "fig:" "")
1086 para (image "guess.jpg" "fig:" "")
1087 ]
1087 ]
1088
1088
1089+ , testGroup "Footnotes"
1089− , "Footnote" =:
1090+ [ "Footnote" =:
1090− T.unlines [ "A footnote[1]"
1091+ T.unlines [ "A footnote[1]"
1091− , ""
1092+ , ""
1092− , "[1] First paragraph"
1093+ , "[1] First paragraph"
1093− , ""
1094+ , ""
1094− , "second paragraph"
1095+ , "second paragraph"
1095− ] =?>
1096+ ] =?>
1096− para (mconcat
1097+ para (mconcat
1097− [ "A", space, "footnote"
1098+ [ "A", space, "footnote"
1098− , note $ mconcat [ para ("First" <> space <> "paragraph")
1099+ , note $ mconcat [ para ("First" <> space <> "paragraph")
1099− , para ("second" <> space <> "paragraph")
1100+ , para ("second" <> space <> "paragraph")
1100− ]
1101+ ]
1101− ])
1102−
1103− , "Two footnotes" =:
1104− T.unlines [ "Footnotes[fn:1][fn:2]"
1105− , ""
1106− , "[fn:1] First note."
1107− , ""
1108− , "[fn:2] Second note."
1109− ] =?>
1110− para (mconcat
1111− [ "Footnotes"
1112− , note $ para ("First" <> space <> "note.")
1113− , note $ para ("Second" <> space <> "note.")
1114− ])
1115−
1116− , "Emphasized text before footnote" =:
1117− T.unlines [ "/text/[fn:1]"
1118− , ""
1119− , "[fn:1] unicorn"
1120− ] =?>
1121− para (mconcat
1122− [ emph "text"
1123− , note . para $ "unicorn"
1124− ])
1125−
1126− , "Footnote that starts with emphasized text" =:
1127− T.unlines [ "text[fn:1]"
1128− , ""
1129− , "[fn:1] /emphasized/"
1130− ] =?>
1131− para (mconcat
1132− [ "text"
1133− , note . para $ emph "emphasized"
1134− ])
1102+ ])
1135
1103
1136− , "Footnote followed by header" =:
1104+ , "Two footnotes" =:
1137− T.unlines [ "Another note[fn:yay]"
1105+ T.unlines [ "Footnotes[fn:1][fn:2]"
1138− , ""
1106+ , ""
1139− , "[fn:yay] This is great!"
1107+ , "[fn:1] First note."
1140− , ""
1108+ , ""
1141− , "** Headline"
1109+ , "[fn:2] Second note."
1142− ] =?>
1110+ ] =?>
1143− mconcat
1144− [ para (mconcat
1111+ para (mconcat
1145− [ "Another", space, "note"
1112+ [ "Footnotes"
1146− , note $ para ("This" <> space <> "is" <> space <> "great!")
1113+ , note $ para ("First" <> space <> "note.")
1114+ , note $ para ("Second" <> space <> "note.")
1147 ])
1115 ])
1116+
1117+ , "Emphasized text before footnote" =:
1118+ T.unlines [ "/text/[fn:1]"
1119+ , ""
1120+ , "[fn:1] unicorn"
1121+ ] =?>
1122+ para (mconcat
1123+ [ emph "text"
1124+ , note . para $ "unicorn"
1125+ ])
1126+
1127+ , "Footnote that starts with emphasized text" =:
1128+ T.unlines [ "text[fn:1]"
1129+ , ""
1130+ , "[fn:1] /emphasized/"
1131+ ] =?>
1132+ para (mconcat
1133+ [ "text"
1134+ , note . para $ emph "emphasized"
1135+ ])
1136+
1137+ , "Footnote followed by header" =:
1138+ T.unlines [ "Another note[fn:yay]"
1139+ , ""
1140+ , "[fn:yay] This is great!"
1141+ , ""
1142+ , "** Headline"
1143+ ] =?>
1144+ mconcat
1145+ [ para (mconcat
1146+ [ "Another", space, "note"
1147+ , note $ para ("This" <> space <> "is" <> space <> "great!")
1148+ ])
1148− , headerWith ("headline", [], []) 2 "Headline"
1149+ , headerWith ("headline", [], []) 2 "Headline"
1150+ ]
1151+
1152+ , "Footnote followed by two blank lines" =:
1153+ T.unlines [ "footnote[fn:blanklines]"
1154+ , ""
1155+ , "[fn:blanklines] followed by blank lines"
1156+ , ""
1157+ , ""
1158+ , "next"
1159+ ] =?>
1160+ mconcat
1161+ [ para ("footnote" <> note (para "followed by blank lines"))
1162+ , para "next"
1163+ ]
1149− ]
1164+ ]
1150 ]
1165 ]
1151
1166
1152 , testGroup "Lists" $
1167 , testGroup "Lists" $