orgmode-parse 0.2.0 → 0.2.1
raw patch · 5 files changed
+29/−4 lines, 5 files
Files
- README.md +5/−0
- orgmode-parse.cabal +2/−1
- src/Data/OrgMode/Parse/Attoparsec/Drawer/Generic.hs +1/−1
- test/Document.hs +20/−1
- test/Headline.hs +1/−1
README.md view
@@ -8,6 +8,8 @@ - [What's Finished](#whats-finished) - [What's Planned](#whats-planned) - [Building](#building)++You can find the package on [Hackage](https://hackage.haskell.org/package/orgmode-parse). ## What's Finished We have built attoparsec parsers for parsing org-mode document structures and@@ -62,6 +64,9 @@ $ nix-shell --attr orgmode-parse.env release.nix $ cabal build ```++## Projects that use this package:+https://github.com/volhovm/orgstat # License [BSD3 Open Source Software License](https://github.com/digitalmentat/orgmode-parse/blob/master/LICENSE)
orgmode-parse.cabal view
@@ -1,9 +1,10 @@ Name: orgmode-parse-Version: 0.2.0+Version: 0.2.1 Author: Parnell Springmeyer <parnell@digitalmentat.com> Maintainer: Parnell Springmeyer <parnell@digitalmentat.com> License: BSD3 License-File: LICENSE+bug-reports: https://github.com/ixmatus/orgmode-parse/issues Category: Data Synopsis: A collection of Attoparsec combinators for parsing org-mode flavored documents.
src/Data/OrgMode/Parse/Attoparsec/Drawer/Generic.hs view
@@ -61,7 +61,7 @@ parseDrawerDelim v = skipSpace *> skip (== ':') *> asciiCI v <*- skip (== ':') <* skipSpace+ skip (== ':') <* Util.skipOnlySpace -- | Parse the @:END:@ of a drawer. drawerEnd :: Attoparsec.Parser Text Text
test/Document.hs view
@@ -8,6 +8,7 @@ import qualified Data.Text.IO as TextIO import Test.Tasty import Test.Tasty.HUnit+import Data.HashMap.Strict import Data.OrgMode.Parse.Attoparsec.Document import Data.OrgMode.Parse.Attoparsec.Time@@ -33,13 +34,28 @@ , testCase "Parse Document from File" $ testDocFile++ , testCase "Parse Document with Subtree List Items" $+ testSubtreeListItemDocFile ] where testDocS s r = expectParse (parseDocument kw) s (Right r)+ testDocFile = do doc <- TextIO.readFile "test/test-document.org"- assertBool "Expected to parse document" . parseSucceeded $ parseOnly (parseDocument kw) doc++ let testDoc = parseOnly (parseDocument kw) doc++ assertBool "Expected to parse document" (parseSucceeded testDoc)++ testSubtreeListItemDocFile = do+ doc <- TextIO.readFile "test/subtree-list-items.org"++ let subtreeListItemsDoc = parseOnly (parseDocument []) doc++ assertBool "Expected to parse document" (subtreeListItemsDoc == goldenSubtreeListItemDoc)+ kw = ["TODO", "CANCELED", "DONE"] pText = "Paragraph text\n.No headline here.\n##--------\n" parseSucceeded (Right _) = True@@ -97,3 +113,6 @@ emptySection :: Section emptySection = Section Nothing (Plns mempty) mempty mempty mempty mempty mempty++goldenSubtreeListItemDoc :: Either String Document+goldenSubtreeListItemDoc = Right (Document {documentText = "", documentHeadlines = [Headline {depth = Depth 1, stateKeyword = Nothing, priority = Nothing, title = "Header1", timestamp = Nothing, stats = Nothing, tags = [], section = Section {sectionTimestamp = Nothing, sectionPlannings = Plns (fromList []), sectionClocks = [], sectionProperties = Properties {unProperties = fromList []}, sectionLogbook = Logbook {unLogbook = []}, sectionDrawers = [], sectionParagraph = ""}, subHeadlines = [Headline {depth = Depth 2, stateKeyword = Nothing, priority = Nothing, title = "Header2", timestamp = Nothing, stats = Nothing, tags = [], section = Section {sectionTimestamp = Nothing, sectionPlannings = Plns (fromList []), sectionClocks = [], sectionProperties = Properties {unProperties = fromList []}, sectionLogbook = Logbook {unLogbook = []}, sectionDrawers = [], sectionParagraph = ""}, subHeadlines = [Headline {depth = Depth 3, stateKeyword = Nothing, priority = Nothing, title = "Header3", timestamp = Nothing, stats = Nothing, tags = [], section = Section {sectionTimestamp = Nothing, sectionPlannings = Plns (fromList []), sectionClocks = [], sectionProperties = Properties {unProperties = fromList [("ONE","two")]}, sectionLogbook = Logbook {unLogbook = []}, sectionDrawers = [], sectionParagraph = "\n * Item1\n * Item2\n"}, subHeadlines = []}]},Headline {depth = Depth 2, stateKeyword = Nothing, priority = Nothing, title = "Header4", timestamp = Nothing, stats = Nothing, tags = [], section = Section {sectionTimestamp = Nothing, sectionPlannings = Plns (fromList []), sectionClocks = [], sectionProperties = Properties {unProperties = fromList []}, sectionLogbook = Logbook {unLogbook = []}, sectionDrawers = [], sectionParagraph = ""}, subHeadlines = []}]}]})
test/Headline.hs view
@@ -20,7 +20,7 @@ , (testCase "Parse Headline w/ Keywords" $ testHeadline "* An important heading :WITH:KEYWORDS:\n") , (testCase "Parse Headline Full" $ testHeadline "* DONE [#B] A heading : with [[http://somelink.com][a link]] :WITH:KEYWORDS:\n") , (testCase "Parse Headline All But Title" $ testHeadline "* DONE [#A] :WITH:KEYWORDS:\n")- , (testCase "Parse Headline w/ Timestamp" $ testHeadline "* TODO [#A] Pickup groceris on <2017-08-24 22:00>\n")+ , (testCase "Parse Headline w/ Timestamp" $ testHeadline "* TODO [#A] <2017-08-24 22:00> Pickup groceris on\n") ] where testHeadline = testParser (headlineBelowDepth ["TODO","CANCELED","DONE"] 0)