git.iko.soy/typeable/pandoc
on master help sign in
Org reader: Fix parsing of footnotes
8e91d36Albert Krewinkel
src/Text/Pandoc/Readers/Org.hs+6−2
@@ -639,10 +639,14 @@ latexEnvName = try $ do
639--
639--
640noteBlock :: OrgParser (F Blocks)
640noteBlock :: OrgParser (F Blocks)
641noteBlock = try $ do
641noteBlock = try $ do
642− ref <- noteMarker
642+ ref <- noteMarker <* skipSpaces
643− content <- skipSpaces *> paraOrPlain
643+ content <- mconcat <$> blocksTillHeaderOrNote
644 addToNotesTable (ref, content)
644 addToNotesTable (ref, content)
645 return mempty
645 return mempty
646+ where
647+ blocksTillHeaderOrNote =
648+ many1Till block (eof <|> () <$ lookAhead noteMarker
649+ <|> () <$ lookAhead headerStart)
646
650
647-- Paragraphs or Plain text
651-- Paragraphs or Plain text
648paraOrPlain :: OrgParser (F Blocks)
652paraOrPlain :: OrgParser (F Blocks)
tests/Tests/Readers/Org.hs+42
@@ -383,6 +383,48 @@ tests =
383 ] =?>
383 ] =?>
384 para (image "the-red-queen.jpg" "fig:redqueen"
384 para (image "the-red-queen.jpg" "fig:redqueen"
385 "Used as a metapher in evolutionary biology.")
385 "Used as a metapher in evolutionary biology.")
386+
387+ , "Footnote" =:
388+ unlines [ "A footnote[1]"
389+ , ""
390+ , "[1] First paragraph"
391+ , ""
392+ , "second paragraph"
393+ ] =?>
394+ para (mconcat
395+ [ "A", space, "footnote"
396+ , note $ mconcat [ para ("First" <> space <> "paragraph")
397+ , para ("second" <> space <> "paragraph")
398+ ]
399+ ])
400+
401+ , "Two footnotes" =:
402+ unlines [ "Footnotes[fn:1][fn:2]"
403+ , ""
404+ , "[fn:1] First note."
405+ , ""
406+ , "[fn:2] Second note."
407+ ] =?>
408+ para (mconcat
409+ [ "Footnotes"
410+ , note $ para ("First" <> space <> "note.")
411+ , note $ para ("Second" <> space <> "note.")
412+ ])
413+
414+ , "Footnote followed by header" =:
415+ unlines [ "Another note[fn:yay]"
416+ , ""
417+ , "[fn:yay] This is great!"
418+ , ""
419+ , "** Headline"
420+ ] =?>
421+ mconcat
422+ [ para (mconcat
423+ [ "Another", space, "note"
424+ , note $ para ("This" <> space <> "is" <> space <> "great!")
425+ ])
426+ , header 2 "Headline"
427+ ]
386 ]
428 ]
387
429
388 , testGroup "Lists" $
430 , testGroup "Lists" $