@@ -693,139 +693,179 @@ tests =
693 "Paragraph\n" =?>
693 "Paragraph\n" =?>
694 para "Paragraph"
694 para "Paragraph"
696+ , testGroup "headers" $
696− , "First Level Header" =:
697+ [ "First Level Header" =:
697− "* Headline\n" =?>
698+ "* Headline\n" =?>
698− headerWith ("headline", [], []) 1 "Headline"
699+ headerWith ("headline", [], []) 1 "Headline"
700− , "Third Level Header" =:
701+ , "Third Level Header" =:
701− "*** Third Level Headline\n" =?>
702+ "*** Third Level Headline\n" =?>
702− headerWith ("third-level-headline", [], [])
703+ headerWith ("third-level-headline", [], [])
704− ("Third" <> space <> "Level" <> space <> "Headline")
705+ ("Third" <> space <> "Level" <> space <> "Headline")
706− , "Compact Headers with Paragraph" =:
707+ , "Compact Headers with Paragraph" =:
707− unlines [ "* First Level"
708+ unlines [ "* First Level"
708− , "** Second Level"
709+ , "** Second Level"
709− , " Text"
710+ , " Text"
711− mconcat [ headerWith ("first-level", [], [])
712+ mconcat [ headerWith ("first-level", [], [])
713− ("First" <> space <> "Level")
714+ ("First" <> space <> "Level")
714− , headerWith ("second-level", [], [])
715+ , headerWith ("second-level", [], [])
716− ("Second" <> space <> "Level")
717+ ("Second" <> space <> "Level")
717− , para "Text"
718+ , para "Text"
720− , "Separated Headers with Paragraph" =:
721+ , "Separated Headers with Paragraph" =:
721− unlines [ "* First Level"
722+ unlines [ "* First Level"
723− , "** Second Level"
724+ , "** Second Level"
725− , " Text"
726+ , " Text"
727− mconcat [ headerWith ("first-level", [], [])
728+ mconcat [ headerWith ("first-level", [], [])
729− ("First" <> space <> "Level")
730+ ("First" <> space <> "Level")
730− , headerWith ("second-level", [], [])
731+ , headerWith ("second-level", [], [])
732− ("Second" <> space <> "Level")
733+ ("Second" <> space <> "Level")
733− , para "Text"
734+ , para "Text"
736− , "Headers not preceded by a blank line" =:
737+ , "Headers not preceded by a blank line" =:
737− unlines [ "** eat dinner"
738+ unlines [ "** eat dinner"
738− , "Spaghetti and meatballs tonight."
739+ , "Spaghetti and meatballs tonight."
739− , "** walk dog"
740+ , "** walk dog"
741− mconcat [ headerWith ("eat-dinner", [], [])
742+ mconcat [ headerWith ("eat-dinner", [], [])
743− ("eat" <> space <> "dinner")
744+ ("eat" <> space <> "dinner")
744− , para $ spcSep [ "Spaghetti", "and", "meatballs", "tonight." ]
745+ , para $ spcSep [ "Spaghetti", "and", "meatballs", "tonight." ]
745− , headerWith ("walk-dog", [], [])
746+ , headerWith ("walk-dog", [], [])
747− ("walk" <> space <> "dog")
748+ ("walk" <> space <> "dog")
750− , "Tagged headers" =:
751+ , testGroup "Todo keywords"
751− unlines [ "* Personal :PERSONAL:"
752+ [ "Header with known todo keyword" =:
752− , "** Call Mom :@PHONE:"
753+ "* TODO header" =?>
753− , "** Call John :@PHONE:JOHN: "
754+ let todoSpan = spanWith ("", ["todo", "TODO"], []) "TODO"
754− ] =?>
755+ in headerWith ("header", [], []) 1 (todoSpan <> space <> "header")
755− let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty
756+
756− in mconcat [ headerWith ("personal", [], [])
757+ , "Header marked as done" =:
757− 1
758+ "* DONE header" =?>
758− ("Personal" <> tagSpan "PERSONAL")
759+ let todoSpan = spanWith ("", ["done", "DONE"], []) "DONE"
759− , headerWith ("call-mom", [], [])
760+ in headerWith ("header", [], []) 1 (todoSpan <> space <> "header")
761− ("Call Mom" <> tagSpan "@PHONE")
762+ , "Header with unknown todo keyword" =:
762− , headerWith ("call-john", [], [])
763+ "* WAITING header" =?>
763− 2
764+ headerWith ("waiting-header", [], []) 1 "WAITING header"
764− ("Call John" <> tagSpan "@PHONE" <> tagSpan "JOHN")
765+
765− ]
766+ , "Custom todo keywords" =:
766−
767+ unlines [ "#+TODO: WAITING CANCELLED"
767− , "Untagged header containing colons" =:
768+ , "* WAITING compile"
768− "* This: is not: tagged" =?>
769+ , "* CANCELLED lunch"
769− headerWith ("this-is-not-tagged", [], []) 1 "This: is not: tagged"
770+ ] =?>
770−
771+ let todoSpan = spanWith ("", ["todo", "WAITING"], []) "WAITING"
771− , "Header starting with strokeout text" =:
772+ doneSpan = spanWith ("", ["done", "CANCELLED"], []) "CANCELLED"
772− unlines [ "foo"
773+ in headerWith ("compile", [], []) 1 (todoSpan <> space <> "compile")
773− , ""
774+ <> headerWith ("lunch", [], []) 1 (doneSpan <> space <> "lunch")
774− , "* +thing+ other thing"
775+
776+ , "Custom todo keywords with multiple done-states" =:
777+ unlines [ "#+TODO: WAITING | DONE CANCELLED "
778+ , "* WAITING compile"
779+ , "* CANCELLED lunch"
780+ , "* DONE todo-feature"
776− mconcat [ para "foo"
782+ let waiting = spanWith ("", ["todo", "WAITING"], []) "WAITING"
777− , headerWith ("thing-other-thing", [], [])
783+ cancelled = spanWith ("", ["done", "CANCELLED"], []) "CANCELLED"
778− 1
784+ done = spanWith ("", ["done", "DONE"], []) "DONE"
779− ((strikeout "thing") <> " other thing")
785+ in headerWith ("compile", [], []) 1 (waiting <> space <> "compile")
786+ <> headerWith ("lunch", [], []) 1 (cancelled <> space <> "lunch")
787+ <> headerWith ("todo-feature", [], []) 1 (done <> space <> "todo-feature")
782− , "Comment Trees" =:
790+ , "Tagged headers" =:
783− unlines [ "* COMMENT A comment tree"
791+ unlines [ "* Personal :PERSONAL:"
784− , " Not much going on here"
792+ , "** Call Mom :@PHONE:"
785− , "** This will be dropped"
793+ , "** Call John :@PHONE:JOHN: "
786− , "* Comment tree above"
788− headerWith ("comment-tree-above", [], []) 1 "Comment tree above"
795+ let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty
796+ in mconcat [ headerWith ("personal", [], [])
798+ ("Personal" <> tagSpan "PERSONAL")
799+ , headerWith ("call-mom", [], [])
801+ ("Call Mom" <> tagSpan "@PHONE")
802+ , headerWith ("call-john", [], [])
804+ ("Call John" <> tagSpan "@PHONE" <> tagSpan "JOHN")
790− , "Nothing but a COMMENT header" =:
807+ , "Untagged header containing colons" =:
791− "* COMMENT Test" =?>
808+ "* This: is not: tagged" =?>
792− (mempty::Blocks)
809+ headerWith ("this-is-not-tagged", [], []) 1 "This: is not: tagged"
794− , "Tree with :noexport:" =:
811+ , "Header starting with strokeout text" =:
795− unlines [ "* Should be ignored :archive:noexport:old:"
812+ unlines [ "foo"
796− , "** Old stuff"
813+ , ""
797− , " This is not going to be exported"
814+ , "* +thing+ other thing"
816+ mconcat [ para "foo"
817+ , headerWith ("thing-other-thing", [], [])
819+ ((strikeout "thing") <> " other thing")
822+ , "Comment Trees" =:
823+ unlines [ "* COMMENT A comment tree"
824+ , " Not much going on here"
825+ , "** This will be dropped"
826+ , "* Comment tree above"
799− (mempty::Blocks)
828+ headerWith ("comment-tree-above", [], []) 1 "Comment tree above"
801− , "Subtree with :noexport:" =:
830+ , "Nothing but a COMMENT header" =:
802− unlines [ "* Exported"
831+ "* COMMENT Test" =?>
803− , "** This isn't exported :noexport:"
832+ (mempty::Blocks)
804− , "*** This neither"
807− mconcat [ headerWith ("exported", [], []) 1 "Exported"
808− , headerWith ("but-this-is", [], []) 2 "But this is"
811− , "Preferences are treated as header attributes" =:
834+ , "Tree with :noexport:" =:
812− unlines [ "* foo"
835+ unlines [ "* Should be ignored :archive:noexport:old:"
813− , " :PROPERTIES:"
836+ , "** Old stuff"
814− , " :custom_id: fubar"
837+ , " This is not going to be exported"
818− headerWith ("fubar", [], [("bar", "baz")]) 1 "foo"
839+ (mempty::Blocks)
841+ , "Subtree with :noexport:" =:
842+ unlines [ "* Exported"
843+ , "** This isn't exported :noexport:"
844+ , "*** This neither"
847+ mconcat [ headerWith ("exported", [], []) 1 "Exported"
848+ , headerWith ("but-this-is", [], []) 2 "But this is"
851+ , "Preferences are treated as header attributes" =:
854+ , " :custom_id: fubar"
858+ headerWith ("fubar", [], [("bar", "baz")]) 1 "foo"
821− , "Headers marked with a unnumbered property get a class of the same name" =:
822− unlines [ "* Not numbered"
827− headerWith ("not-numbered", ["unnumbered"], []) 1 "Not numbered"
861+ , "Headers marked with a unnumbered property get a class of the same name" =:
862+ unlines [ "* Not numbered"
867+ headerWith ("not-numbered", ["unnumbered"], []) 1 "Not numbered"
829 , "Paragraph starting with an asterisk" =:
869 , "Paragraph starting with an asterisk" =:
830 "*five" =?>
870 "*five" =?>
831 para "*five"
871 para "*five"