-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A collection of Attoparsec combinators for parsing org-mode flavored documents. -- -- -- `orgmode-parse` is a parsing library for the org-mode flavor of -- document markup. -- -- The provided Attoparsec combinators parse the human-readable and -- textual representation into a simple AST for storage or output to -- another format (HTML? Markdown?). @package orgmode-parse @version 0.1.0.2 -- | 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 newtype Level Level :: Int -> Level data Heading Heading :: Level -> Maybe StateKeyword -> Maybe Priority -> Text -> Maybe Stats -> [Tag] -> Section -> [Heading] -> Heading -- | Org headline nesting level (1 is at the top) level :: Heading -> Level -- | 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 newtype LevelDepth LevelDepth :: Int -> LevelDepth data TitleMeta TitleMeta :: Text -> (Maybe Stats) -> (Maybe [Tag]) -> TitleMeta data YearMonthDay :: * YearMonthDay :: UnpkYear -> UnpkMonth -> UnpkDayOfMonth -> YearMonthDay ymdYear :: YearMonthDay -> UnpkYear ymdMonth :: YearMonthDay -> UnpkMonth ymdDay :: YearMonthDay -> UnpkDayOfMonth newtype YearMonthDay' YMD' :: YearMonthDay -> YearMonthDay' instance Eq LevelDepth instance Show LevelDepth instance Num LevelDepth instance Eq Level instance Show Level instance Num Level instance Generic Level 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 Eq TitleMeta instance Show TitleMeta 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 D1Level instance Constructor C1_0Level 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 Level instance ToJSON Level 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 (PropertyKey, PropertyVal) -- | 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 infixing two timepoints with a double -- hyphen, --; or, by appending two hh:mm timestamps -- together in a single timepoint with one hyphen -. -- -- Each timepoint includes an optional repeater flag and an optional -- delay flag. parseTimestamp :: Parser Text Timestamp type Weekday = Text data BracketedDateTime BracketedDateTime :: YearMonthDay -> Maybe Weekday -> Maybe TimePart -> Maybe Repeater -> Maybe Delay -> Bool -> BracketedDateTime datePart :: BracketedDateTime -> YearMonthDay dayNamePart :: BracketedDateTime -> Maybe Weekday timePart :: BracketedDateTime -> Maybe TimePart repeat :: BracketedDateTime -> Maybe Repeater delayPart :: BracketedDateTime -> Maybe Delay isActive :: BracketedDateTime -> Bool -- | Parse a single time part -- --
-- [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 (DateTime, -- Maybe (Hours, Minutes), Bool) parseBracketedDateTime :: Parser Text BracketedDateTime transformBracketedDateTime :: BracketedDateTime -> (DateTime, Maybe (Hours, Minutes), Bool) -- | Parse a 3-character day name parseDay :: Parser Text Text type AbsoluteTime = (Hours, Minutes) type TimestampRange = (AbsoluteTime, AbsoluteTime) newtype TimePart TimePart :: (Either AbsoluteTime TimestampRange) -> TimePart -- | Parse the time-of-day part of a time part, as a single point or a time -- range parseTime' :: Parser Text TimePart -- | 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) -- | Parse the Timeunit part of a delay or repeater flag. 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 instance Eq TimePart instance Ord TimePart instance Show TimePart instance Show BracketedDateTime instance Eq BracketedDateTime -- | Parsing combinators for org-mode sections. 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: * 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] -> LevelDepth -> Parser Text Heading -- | Parse the asterisk indicated heading level until a space is reached. -- -- Constrain to LevelDepth or its children headingLevel :: LevelDepth -> Parser Text Level -- | 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