orgmode-parse-0.2.3: A collection of Attoparsec combinators for parsing org-mode flavored documents.

Copyright© 2014 Parnell Springmeyer
LicenseAll Rights Reserved
MaintainerParnell Springmeyer <parnell@digitalmentat.com>
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

Data.OrgMode.Parse.Attoparsec.Headline

Description

Parsing combinators for org-mode headlines.

Synopsis

Documentation

headlineBelowDepth :: [Text] -> Depth -> Parser Text Headline Source #

Parse an org-mode headline, its metadata, its section-body, and any sub-headlines; please see org-syntax.

Headline metadata includes a hierarchy level indicated by asterisks, optional todo state keywords, an optional priority level, %-done statistics, and tags; e.g:

** TODO [#B] Polish Poetry Essay [25%] :HOMEWORK:POLISH:WRITING:

Headlines may contain:

  • A section with Planning and Clock entries
  • A number of other not-yet-implemented entities (code blocks, lists)
  • Unstructured text
  • Sub-headlines

headlineBelowDepth takes a list of terms to consider, state keywords, and a minumum hierarchy depth.

Use a Depth of 0 to parse any headline.

headlineDepth :: Depth -> Parser Text Depth Source #

Parse the asterisk-indicated headline depth until a space is encountered.

Constrain it to Depth.

headingPriority :: Parser Text Priority Source #

Parse the priority indicator.

If anything but these priority indicators are used the parser will fail:

  • [#A]
  • [#B]
  • [#C]

parseStats :: Parser Text Stats Source #

Parse a statisticss block, e.g: [33%].

Accepts either form: "[m/n]" or "[n%]" and there is no restriction on m or n other than that they are integers.

parseTags :: Parser Text [Tag] Source #

Parse a colon-separated list of tags.

:HOMEWORK:POETRY:WRITING:

mkTitleMeta Source #

Arguments

:: Text

Start of title till the end of line

-> Maybe Stats

Stats, e.g: [33%]

-> Maybe [Tag]

Tags, e.g: :HOMEWORK:CODE:SLEEP:

-> Text

Leftovers (may be empty) of the title

-> TitleMeta 

Produce a triple consisting of a stripped start-of-title if there are no leftovers after parsing (otherwise, recombine the two) and the optional stats and tags.

data TitleMeta Source #

Intermediate type for parsing titles in a headline after the state keyword and priority have been parsed.