-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A parser and writer for org-mode flavored documents. -- -- -- `orgmode-parse` is a parsing and writing library for the org-mode -- flavor of document markup. -- -- This library parses the human-readable and textual representation into -- an AST that can be used for output to another format (HTML? -- Markdown?), serialized for storage, etc... @package orgmode-parse @version 0.1.0 -- | Types and utility functions. module Data.OrgMode.Parse.Types data Document Document :: Text -> [Heading] -> Document -- | Text occurring before any Org headlines documentText :: Document -> Text -- | Toplevel Org headlines documentHeadings :: Document -> [Heading] data Section Section :: Plannings -> [Clock] -> Properties -> Text -> Section sectionPlannings :: Section -> Plannings sectionClocks :: Section -> [Clock] sectionProperties :: Section -> Properties sectionParagraph :: Section -> Text data Heading Heading :: Int -> Maybe StateKeyword -> Maybe Priority -> Text -> Maybe Stats -> [Tag] -> Section -> [Heading] -> Heading -- | Org headline nesting level (1 is at the top) level :: Heading -> Int -- | State of the headline (e.g. TODO, DONE) keyword :: Heading -> Maybe StateKeyword priority :: Heading -> Maybe Priority title :: Heading -> Text stats :: Heading -> Maybe Stats tags :: Heading -> [Tag] section :: Heading -> Section subHeadings :: Heading -> [Heading] data Priority A :: Priority B :: Priority C :: Priority newtype Plannings Plns :: (HashMap PlanningKeyword Timestamp) -> Plannings newtype StateKeyword StateKeyword :: Text -> StateKeyword unStateKeyword :: StateKeyword -> Text type Duration = (Hour, Minute) data PlanningKeyword SCHEDULED :: PlanningKeyword DEADLINE :: PlanningKeyword CLOSED :: PlanningKeyword type Properties = HashMap Text Text data Timestamp Timestamp :: DateTime -> Bool -> Maybe DateTime -> Timestamp tsTime :: Timestamp -> DateTime tsActive :: Timestamp -> Bool tsEndTime :: Timestamp -> Maybe DateTime data DateTime DateTime :: YearMonthDay' -> Maybe Text -> Maybe (Hour, Minute) -> Maybe Repeater -> Maybe Delay -> DateTime yearMonthDay :: DateTime -> YearMonthDay' dayName :: DateTime -> Maybe Text hourMinute :: DateTime -> Maybe (Hour, Minute) repeater :: DateTime -> Maybe Repeater delay :: DateTime -> Maybe Delay data Stats StatsPct :: Int -> Stats StatsOf :: Int -> Int -> Stats type Tag = Text data TimeUnit UnitYear :: TimeUnit UnitWeek :: TimeUnit UnitMonth :: TimeUnit UnitDay :: TimeUnit UnitHour :: TimeUnit data RepeaterType RepeatCumulate :: RepeaterType RepeatCatchUp :: RepeaterType RepeatRestart :: RepeaterType data Repeater Repeater :: RepeaterType -> Int -> TimeUnit -> Repeater repeaterType :: Repeater -> RepeaterType repeaterValue :: Repeater -> Int repeaterUnit :: Repeater -> TimeUnit data DelayType DelayAll :: DelayType DelayFirst :: DelayType data Delay Delay :: DelayType -> Int -> TimeUnit -> Delay delayType :: Delay -> DelayType delayValue :: Delay -> Int delayUnit :: Delay -> TimeUnit data YearMonthDay :: * YearMonthDay :: UnpkYear -> UnpkMonth -> UnpkDayOfMonth -> YearMonthDay ymdYear :: YearMonthDay -> UnpkYear ymdMonth :: YearMonthDay -> UnpkMonth ymdDay :: YearMonthDay -> UnpkDayOfMonth newtype YearMonthDay' YMD' :: YearMonthDay -> YearMonthDay' instance Show YearMonthDay' instance Eq YearMonthDay' instance Generic YearMonthDay' instance Show RepeaterType instance Eq RepeaterType instance Generic RepeaterType instance Show DelayType instance Eq DelayType instance Generic DelayType instance Show TimeUnit instance Eq TimeUnit instance Generic TimeUnit instance Show Delay instance Eq Delay instance Generic Delay instance Show Repeater instance Eq Repeater instance Generic Repeater instance Show DateTime instance Eq DateTime instance Generic DateTime instance Show Timestamp instance Eq Timestamp instance Generic Timestamp instance Show StateKeyword instance Eq StateKeyword instance Generic StateKeyword instance Show PlanningKeyword instance Eq PlanningKeyword instance Enum PlanningKeyword instance Ord PlanningKeyword instance Generic PlanningKeyword instance Show Plannings instance Eq Plannings instance Generic Plannings instance Show Priority instance Read Priority instance Eq Priority instance Ord Priority instance Generic Priority instance Show Stats instance Eq Stats instance Generic Stats instance Show Section instance Eq Section instance Generic Section instance Show Heading instance Eq Heading instance Generic Heading instance Show Document instance Eq Document instance Generic Document instance Datatype D1YearMonthDay' instance Constructor C1_0YearMonthDay' instance Datatype D1RepeaterType instance Constructor C1_0RepeaterType instance Constructor C1_1RepeaterType instance Constructor C1_2RepeaterType instance Datatype D1DelayType instance Constructor C1_0DelayType instance Constructor C1_1DelayType instance Datatype D1TimeUnit instance Constructor C1_0TimeUnit instance Constructor C1_1TimeUnit instance Constructor C1_2TimeUnit instance Constructor C1_3TimeUnit instance Constructor C1_4TimeUnit instance Datatype D1Delay instance Constructor C1_0Delay instance Selector S1_0_0Delay instance Selector S1_0_1Delay instance Selector S1_0_2Delay instance Datatype D1Repeater instance Constructor C1_0Repeater instance Selector S1_0_0Repeater instance Selector S1_0_1Repeater instance Selector S1_0_2Repeater instance Datatype D1DateTime instance Constructor C1_0DateTime instance Selector S1_0_0DateTime instance Selector S1_0_1DateTime instance Selector S1_0_2DateTime instance Selector S1_0_3DateTime instance Selector S1_0_4DateTime instance Datatype D1Timestamp instance Constructor C1_0Timestamp instance Selector S1_0_0Timestamp instance Selector S1_0_1Timestamp instance Selector S1_0_2Timestamp instance Datatype D1StateKeyword instance Constructor C1_0StateKeyword instance Selector S1_0_0StateKeyword instance Datatype D1PlanningKeyword instance Constructor C1_0PlanningKeyword instance Constructor C1_1PlanningKeyword instance Constructor C1_2PlanningKeyword instance Datatype D1Plannings instance Constructor C1_0Plannings instance Datatype D1Priority instance Constructor C1_0Priority instance Constructor C1_1Priority instance Constructor C1_2Priority instance Datatype D1Stats instance Constructor C1_0Stats instance Constructor C1_1Stats instance Datatype D1Section instance Constructor C1_0Section instance Selector S1_0_0Section instance Selector S1_0_1Section instance Selector S1_0_2Section instance Selector S1_0_3Section instance Datatype D1Heading instance Constructor C1_0Heading instance Selector S1_0_0Heading instance Selector S1_0_1Heading instance Selector S1_0_2Heading instance Selector S1_0_3Heading instance Selector S1_0_4Heading instance Selector S1_0_5Heading instance Selector S1_0_6Heading instance Selector S1_0_7Heading instance Datatype D1Document instance Constructor C1_0Document instance Selector S1_0_0Document instance Selector S1_0_1Document instance Hashable PlanningKeyword instance FromJSON Stats instance ToJSON Stats instance FromJSON Priority instance ToJSON Priority instance FromJSON Heading instance ToJSON Heading instance FromJSON Section instance ToJSON Section instance FromJSON Plannings instance ToJSON Plannings instance FromJSON PlanningKeyword instance ToJSON PlanningKeyword instance FromJSON StateKeyword instance ToJSON StateKeyword instance FromJSON TimeUnit instance ToJSON TimeUnit instance FromJSON Delay instance ToJSON Delay instance FromJSON DelayType instance ToJSON DelayType instance FromJSON Repeater instance ToJSON Repeater instance FromJSON RepeaterType instance ToJSON RepeaterType instance FromJSON DateTime instance ToJSON DateTime instance FromJSON YearMonthDay' instance ToJSON YearMonthDay' instance FromJSON Timestamp instance ToJSON Timestamp instance FromJSON Document instance ToJSON Document -- | Parsing combinators for org-mode entry property drawers. module Data.OrgMode.Parse.Attoparsec.PropertyDrawer -- | Parse a property drawer. -- --
--   :PROPERTIES:
--   :DATE: [2014-12-14 11:00]
--   :NOTE: Something really crazy happened today!
--   :END:
--   
parseDrawer :: Parser Text Properties -- | Parse a property of a drawer. -- -- Properties *must* be a `:KEY: value` pair, the key can be of any case -- and contain any characters except for newlines and colons (since they -- delimit the start and end of the key). property :: Parser Text (Text, Text) -- | Parsing combinators for org-mode active and inactive timestamps. module Data.OrgMode.Parse.Attoparsec.Time -- | Parse a planning line -- -- Plannings live in a heading section and are formatted as a keyword and -- a timestamp. There can be more than one, but they are all on the same -- line e.g. DEADLINE: 17:00 CLOSED: 12:00 parsePlannings :: Parser Text (HashMap PlanningKeyword Timestamp) -- | Parse a clock line -- -- A heading's section contains one line per clock entry Clocks may have -- a timestamp, a duration, both, or neither e.g.: CLOCK: [2014-12-10 Fri -- 2:30]--[2014-12-10 FRI 10:30] => 08:00 parseClock :: Parser Text (Maybe Timestamp, Maybe Duration) -- | Parse a timestamp -- -- Timestamps may be timepoints or timeranges, and they indicate whether -- they are active or closed by using angle or square brackets -- respectively -- -- Time ranges are formatted by appending two timepoints with '--' in -- between, or by appending two hh:mm stamps together in a single -- timepoint with a single - -- -- Each timepoint includes an optional repeater flag and an optional -- delay flag parseTimestamp :: Parser Text Timestamp -- | Parse a single time part -- -- e.g. [2015-03-27 Fri 10:20 +4h] returning: * The basic timestamp * -- Whether there was a time interval in place of a single time (this will -- be handled upstream by parseTimestamp) * Whether the time is active or -- inactive parseBracketedDateTime :: Parser Text (DateTime, Maybe (Hours, Minutes), Bool) -- | Parse a 3-character day name parseDay :: Parser Text Text -- | Parse the time-of-day part of a time part, as a single point or a time -- range parseTime' :: Parser Text (Either (Hours, Minutes) ((Hours, Minutes), (Hours, Minutes))) -- | Parse the YYYY-MM-DD part of a time part parseDate :: Parser Text YearMonthDay -- | Parse a single HH:MM point parseHM :: Parser Text (Hours, Minutes) parseTimeUnit :: Parser Text TimeUnit -- | Parse a repeater flag, e.g. ".+4w", or "++1y" parseRepeater :: Parser Text Repeater -- | Parse a delay flag, e.g. "--1d" or "-2w" parseDelay :: Parser Text Delay module Data.OrgMode.Parse.Attoparsec.Section -- | Parse a heading section -- -- Heading sections contain optionally a property drawer, a list of clock -- entries, code blocks (not yet implemented), plain lists (not yet -- implemented), and unstructured text. parseSection :: Parser Text Section -- | Parsing combinators for org-list headings. module Data.OrgMode.Parse.Attoparsec.Headings -- | Parse an org-mode heading and its contained entities (see -- orgmode.orgworgdev/org-syntax.html Header guidance) Headers -- include a hierarchy level indicated by *s, optional Todo-like -- state, priority level, %-done stats, and tags e.g.: ** TODO [#B] -- Polish Poetry Essay [25%] :HOMEWORK:POLISH:WRITING: -- -- Headings contain directly: * A section with Planning and Clock -- entries * A number of other not-yet-implemented entities (code blocks, -- lists) * Unstructured text * Other heading deeper in the hierarchy -- -- headingBelowLevel takes a list of terms to consider StateKeyword's, -- and a minumum hierarchy depth. Use 0 to parse any heading headingBelowLevel :: [Text] -> Int -> Parser Text Heading -- | Parse the asterisk indicated heading level until a space is reached. -- Constrain to levelReq level or its children headingLevel :: Int -> Parser Text Int -- | Parse the priority indicator. -- -- If anything but these priority indicators are used the parser will -- fail: `[B]`, `[#C]`. headingPriority :: Parser Text Priority -- | Parse a Stats block. -- -- Accepts either form: "[m/n]" or "[n%]" There is no restriction on m or -- n other than that they are integers parseStats :: Parser Text Stats -- | Parse a colon-separated list of Tags -- -- e.g. :HOMEWORK:POETRY:WRITING: parseTags :: Parser Text [Tag] module Data.OrgMode.Parse.Attoparsec.Document parseDocument :: [Text] -> Parser Text Document -- | Attoparsec combinators for orgmode documents. module Data.OrgMode.Parse