-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Org Mode library for haskell -- @package orgmode @version 0.1.0.0 module Data.OrgMode.Text -- | Line numbers, where we can have an unattached root. type LineNumber = Maybe Int toNumber :: Int -> LineNumber -> Int -- | Raw data about each line of text. Lines with 'tlLineNum == None' are -- generated and don't exist within the Org file (yet). data TextLine TextLine :: Int -> String -> LineNumber -> TextLine -- | how long of a whitespace (or asterisk, for Node) prefix is in -- tlText? tlIndent :: TextLine -> Int tlText :: TextLine -> String tlLineNum :: TextLine -> LineNumber isNumber :: LineNumber -> Bool -- | Implements an API for getting text lines. Useful for Org file -- generation or mutation. class TextLineSource s getTextLines :: TextLineSource s => s -> [TextLine] -- | Normalizes out newlines to UNIX format. CR -> LF, CRLF -> LF normalizeInputText :: String -> String lineAdd :: Num a => Maybe a -> Maybe a -> Maybe a linesStartingFrom :: LineNumber -> [LineNumber] hasNumber :: TextLine -> Bool makeDrawerLines :: LineNumber -> Int -> String -> [(String, String)] -> [TextLine] wrapLine :: Int -> TextLine -> [TextLine] prefixLine :: String -> TextLine -> TextLine tlPrint :: TextLineSource s => s -> IO () tlFormat :: TextLineSource s => s -> String wrapStringVarLines :: [Int] -> String -> String instance Typeable TextLine instance Eq TextLine instance Ord TextLine instance Show TextLine module Data.OrgMode.Doc -- | An outline node in org-mode. For a node ** TODO Foo a bar -- :FOOBAR: -- -- data Node Node :: Int -> Maybe Prefix -> [String] -> [NodeChild] -> String -> TextLine -> Node -- | Number of stars on the left. nDepth :: Node -> Int -- | E.g., TODO or DONE. nPrefix :: Node -> Maybe Prefix -- | :TAGS:AT:END: nTags :: Node -> [String] -- | Everything hierarchially under the node. nChildren :: Node -> [NodeChild] -- | Text of he header line, minus prefix and tags. nTopic :: Node -> String -- | Literal text of the node header. nLine :: Node -> TextLine -- | A keyword at the front of a node heading, like TODO or DONE. data Prefix Prefix :: String -> Prefix data Drawer Drawer :: String -> [(String, String)] -> [TextLine] -> Drawer -- | :PROPERTIES: or another name. drName :: Drawer -> String -- | Key-value pairs. drProperties :: Drawer -> [(String, String)] -- | Literal text of the entire drawer. drLines :: Drawer -> [TextLine] -- | Properties within the org file. Examples include #+TITLE: data OrgFileProperty OrgFileProperty :: String -> String -> OrgFileProperty fpName :: OrgFileProperty -> String fpValue :: OrgFileProperty -> String -- | Currently underimplemented: stores the lines of the babel environment. data Babel Babel :: [TextLine] -> Babel -- | Currently underimplemented: stores the lines of the table. data Table Table :: [TextLine] -> Table -- | Full contents of an org file. data OrgDoc OrgDoc :: [Node] -> [OrgFileProperty] -> [TextLine] -> OrgDoc odNodes :: OrgDoc -> [Node] odProperties :: OrgDoc -> [OrgFileProperty] odLines :: OrgDoc -> [TextLine] -- | Children of top-level Org Nodes. data NodeChild -- | Regular text. ChildText :: TextLine -> NodeChild ChildDrawer :: Drawer -> NodeChild -- | outline nodes of higher depth. ChildNode :: Node -> NodeChild ChildBabel :: Babel -> NodeChild ChildTable :: Table -> NodeChild updateNode :: (Node -> Maybe Node) -> Node -> Node trim :: [Char] -> [Char] makeNodeLine :: Node -> String instance Eq Prefix instance Show Prefix instance Eq Drawer instance Show Drawer instance Eq Babel instance Show Babel instance Eq Table instance Show Table instance Eq Node instance Show Node instance Eq NodeChild instance Show NodeChild instance Eq OrgFileProperty instance Show OrgFileProperty instance Eq OrgDoc instance Show OrgDoc instance TextLineSource OrgFileProperty instance TextLineSource Node instance TextLineSource NodeChild module Data.OrgMode.OrgDocView data OrgDocView a OrgDocView :: [(a, Node)] -> OrgDoc -> OrgDocView a ovElements :: OrgDocView a -> [(a, Node)] ovDocument :: OrgDocView a -> OrgDoc generateDocView :: NodeUpdate a => OrgDoc -> OrgDocView a getRawElements :: OrgDocView a -> [a] updateDoc :: (Ord a, NodeUpdate a) => Set a -> OrgDocView a -> OrgDocView a -- | 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. class Eq a => NodeUpdate a findItemInNode :: NodeUpdate a => Node -> Maybe a updateNodeLine :: NodeUpdate a => a -> Node -> Maybe Node instance TextLineSource (OrgDocView a) instance TextLineSource OrgDoc -- | 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. module Data.OrgMode -- | A keyword at the front of a node heading, like TODO or DONE. data Prefix Prefix :: String -> Prefix data Drawer Drawer :: String -> [(String, String)] -> [TextLine] -> Drawer -- | :PROPERTIES: or another name. drName :: Drawer -> String -- | Key-value pairs. drProperties :: Drawer -> [(String, String)] -- | Literal text of the entire drawer. drLines :: Drawer -> [TextLine] -- | Currently underimplemented: stores the lines of the babel environment. data Babel Babel :: [TextLine] -> Babel -- | Currently underimplemented: stores the lines of the table. data Table Table :: [TextLine] -> Table -- | Children of top-level Org Nodes. data NodeChild -- | Regular text. ChildText :: TextLine -> NodeChild ChildDrawer :: Drawer -> NodeChild -- | outline nodes of higher depth. ChildNode :: Node -> NodeChild ChildBabel :: Babel -> NodeChild ChildTable :: Table -> NodeChild -- | An outline node in org-mode. For a node ** TODO Foo a bar -- :FOOBAR: -- -- data Node Node :: Int -> Maybe Prefix -> [String] -> [NodeChild] -> String -> TextLine -> Node -- | Number of stars on the left. nDepth :: Node -> Int -- | E.g., TODO or DONE. nPrefix :: Node -> Maybe Prefix -- | :TAGS:AT:END: nTags :: Node -> [String] -- | Everything hierarchially under the node. nChildren :: Node -> [NodeChild] -- | Text of he header line, minus prefix and tags. nTopic :: Node -> String -- | Literal text of the node header. nLine :: Node -> TextLine -- | Properties within the org file. Examples include #+TITLE: data OrgFileProperty OrgFileProperty :: String -> String -> OrgFileProperty fpName :: OrgFileProperty -> String fpValue :: OrgFileProperty -> String data OrgFileElement OrgTopProperty :: OrgFileProperty -> OrgFileElement OrgTopLevel :: Node -> OrgFileElement tlNode :: OrgFileElement -> Node data OrgDocView a OrgDocView :: [(a, Node)] -> OrgDoc -> OrgDocView a ovElements :: OrgDocView a -> [(a, Node)] ovDocument :: OrgDocView a -> OrgDoc -- | 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. class Eq a => NodeUpdate a findItemInNode :: NodeUpdate a => Node -> Maybe a updateNodeLine :: NodeUpdate a => a -> Node -> Maybe Node -- | Full contents of an org file. data OrgDoc OrgDoc :: [Node] -> [OrgFileProperty] -> [TextLine] -> OrgDoc odNodes :: OrgDoc -> [Node] odProperties :: OrgDoc -> [OrgFileProperty] odLines :: OrgDoc -> [TextLine] -- | Raw data about each line of text. Lines with 'tlLineNum == None' are -- generated and don't exist within the Org file (yet). data TextLine TextLine :: Int -> String -> LineNumber -> TextLine -- | how long of a whitespace (or asterisk, for Node) prefix is in -- tlText? tlIndent :: TextLine -> Int tlText :: TextLine -> String tlLineNum :: TextLine -> LineNumber -- | Line numbers, where we can have an unattached root. type LineNumber = Maybe Int -- | Implements an API for getting text lines. Useful for Org file -- generation or mutation. class TextLineSource s getTextLines :: TextLineSource s => s -> [TextLine] -- | Parsing the file efficiently. Let's keep it non-quadratic. -- -- orgFile :: String -> OrgDoc generateDocView :: NodeUpdate a => OrgDoc -> OrgDocView a getRawElements :: OrgDocView a -> [a] updateNode :: (Node -> Maybe Node) -> Node -> Node -- | Adds a pre-classified OrgLine to an OrgDocZipper, possibly adding it -- to some existing part of the OrgDocZipper. addOrgLine :: OrgDocZipper -> OrgLine -> OrgDocZipper emptyZip :: OrgDocZipper categorizeLines :: String -> [OrgLine] instance Eq OrgDocZipper instance Show OrgDocZipper instance Eq OrgLine instance Show OrgLine instance Eq OrgFileElement instance Show OrgFileElement instance TextLineSource OrgLine