The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Org::Parser - Parse Org documents

VERSION

version 0.08

SYNOPSIS

 use 5.010;
 use Org::Parser;
 my $orgp = Org::Parser->new();

 # parse a file
 my $doc = $orgp->parse_file("$ENV{HOME}/todo.org");

 # parse a string
 $orgp->parse(<<EOF);
 * heading1a
 ** TODO heading2a
 ** DONE heading2b
 * TODO heading1b
 * heading1c
 EOF

 # walk the document tree
 $orgp->walk(sub {
     my ($el) = @_;
     next unless $el->isa('Org::Element::Headline');
     say "heading level ", $el->level, ": ", $el->title->as_string;
 });

will print something like:

 heading level 1: heading1a
 heading level 2: heading2a
 heading level 2: heading2b
 heading level 1: heading1b
 heading level 1: heading1c

DESCRIPTION

This module parses Org documents. See http://orgmode.org/ for more details on Org documents.

This module uses Log::Any logging framework.

This module uses Moo object system.

See todo.org in the distribution for the list of already- and not yet implemented stuffs,

ATTRIBUTES

METHODS

new()

Create a new parser instance.

$orgp->parse($str | $arrayref | $coderef | $filehandle) => $doc

Parse document (which can be contained in a scalar $str, an array of lines $arrayref, a subroutine which will be called for chunks until it returns undef, or a filehandle).

Returns Org::Document object.

If 'handler' attribute is specified, will call handler repeatedly during parsing. See the 'handler' attribute for more details.

Will die if there are syntax errors in documents.

$orgp->parse_file($filename) => $doc

Just like parse(), but will load document from file instead.

SEE ALSO

Org::Document

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.