orgmode-0.1.0.1: Org Mode library for haskell

Copyright(c) Lally Singh, 2015
LicenseBSD3
Maintaineryell@lal.ly
Stabilityexperimental
PortabilityBangPatterns, GADTs, DeriveDataTypeable, StandaloneDeriving
Safe HaskellNone
LanguageHaskell2010

Data.OrgMode

Description

A package to parse and interpret Emacs Org-Mode documents. It also supports arbitrary types that map back and forth with Node. Create an instance of NodeUpdate a and use OrgDocView a to read/write values of a in an org-mode file. Property drawers are great for this mapping.

Synopsis

Documentation

data Prefix Source

A keyword at the front of a node heading, like TODO or DONE.

Constructors

Prefix String 

Instances

data Drawer Source

Constructors

Drawer 

Fields

drName :: String

:PROPERTIES: or another name.

drProperties :: [(String, String)]

Key-value pairs.

drLines :: [TextLine]

Literal text of the entire drawer.

Instances

data Babel Source

Currently underimplemented: stores the lines of the babel environment.

Constructors

Babel [TextLine] 

Instances

data Table Source

Currently underimplemented: stores the lines of the table.

Constructors

Table [TextLine] 

Instances

data NodeChild Source

Children of top-level Org Nodes.

Constructors

ChildText TextLine

Regular text.

ChildDrawer Drawer 
ChildNode Node

outline nodes of higher depth.

ChildBabel Babel 
ChildTable Table 

data Node Source

An outline node in org-mode. For a node ** TODO Foo a bar :FOOBAR:

  • nDepth is 2
  • nPrefix is Just TODO
  • nTags is [FOOBAR]
  • nTopic is "Foo a bar", note the stripped whitespace on the front and back.
  • nChildren aren't determined by this line, but by the lines after.

Constructors

Node 

Fields

nDepth :: Int

Number of stars on the left.

nPrefix :: Maybe Prefix

E.g., TODO or DONE.

nTags :: [String]

:TAGS:AT:END:

nChildren :: [NodeChild]

Everything hierarchially under the node.

nTopic :: String

Text of he header line, minus prefix and tags.

nLine :: TextLine

Literal text of the node header.

data OrgFileProperty Source

Properties within the org file. Examples include #+TITLE:

Constructors

OrgFileProperty 

Fields

fpName :: String
 
fpValue :: String
 

data OrgDocView a Source

Constructors

OrgDocView 

Fields

ovElements :: [(a, Node)]
 
ovDocument :: OrgDoc
 

Instances

class Eq a => NodeUpdate a where Source

Generic visitor for updating a Node's values. Intentionally, we don't allow node deletion, just update. Preferably, if you want to delete a Node, you should control the parent. We also have findItemInNode which will construct an a from the Node, which we may then update against a list.

data OrgDoc Source

Full contents of an org file.

Constructors

OrgDoc 

data TextLine Source

Raw data about each line of text. Lines with 'tlLineNum == None' are generated and don't exist within the Org file (yet).

Constructors

TextLine 

Fields

tlIndent :: Int

how long of a whitespace (or asterisk, for Node) prefix is in tlText?

tlText :: String
 
tlLineNum :: LineNumber
 

type LineNumber = Maybe Int Source

Line numbers, where we can have an unattached root.

class TextLineSource s where Source

Implements an API for getting text lines. Useful for Org file generation or mutation.

Methods

getTextLines :: s -> [TextLine] Source

orgFile :: String -> OrgDoc Source

Parsing the file efficiently. Let's keep it non-quadratic.

  • Split it up into lines
  • Identify each line, as part of one of the big structure types:

    • Node headers
    • Drawers
    • File-level properties
    • Babel headers
    • Lines who's type depend on context (e.g., babel entries or node text)
  • Then fold the lines over a builder function and a zipper of the tree.

addOrgLine :: OrgDocZipper -> OrgLine -> OrgDocZipper Source

Adds a pre-classified OrgLine to an OrgDocZipper, possibly adding it to some existing part of the OrgDocZipper.

emptyZip :: OrgDocZipper Source

categorizeLines :: String -> [OrgLine] Source