2 Org::Parser - Parse Org documents
10 my $orgp = Org::Parser->new();
13 my $doc = $orgp->parse_file("$ENV{HOME}/todo.org");
16 $doc = $orgp->parse(<<EOF);
17 #+TODO: TODO | DONE CANCELLED
21 SCHEDULED: <2011-03-31 Thu>
25 this will become a link: radio target
26 * TODO heading1b *bold*
38 # walk the document tree
41 return unless $el->isa('Org::Element::Headline');
42 say "heading level ", $el->level, ": ", $el->title->as_string;
45 will print something like:
47 heading level 1: heading1a
48 heading level 2: heading2a
49 heading level 2: heading2b *bold*
50 heading level 1: heading1b
51 heading level 1: heading1c
53 A command-line utility (in a separate distribution: App::OrgUtils) is
54 available for debugging:
56 % dump-org-structure ~/todo.org
58 Setting: "#+TODO: TODO | DONE CANCELLED\n"
59 RadioTarget: "<<<radio target>>>"
65 Headline: l=2 todo=TODO
73 This module parses Org documents. See http://orgmode.org/ for more
74 details on Org documents.
76 This module uses Log::Any logging framework.
78 This module uses Moo object system.
80 See "todo.org" in the distribution for the list of already- and not yet
86 Create a new parser instance.
88 $orgp->parse($str | $arrayref | $coderef | $filehandle, $opts) => $doc
89 Parse document (which can be contained in a scalar $str, an array of
90 lines $arrayref, a subroutine which will be called for chunks until it
91 returns undef, or a filehandle).
93 Returns Org::Document object.
95 If 'handler' attribute is specified, will call handler repeatedly during
96 parsing. See the 'handler' attribute for more details.
98 Will die if there are syntax errors in documents.
100 $opts is a hashref and can contain these keys: "time_zone" (will be
101 passed to Org::Document's constructor).
103 $orgp->parse_file($filename, $opts) => $doc
104 Just like parse(), but will load document from file instead.
107 Why? Just as only perl can parse Perl, only org-mode can parse Org anyway!
108 True. I'm only targetting good enough. As long as I can parse/process
109 all my Org notes and todo files, I have no complaints.
112 Parser is completely regex-based at the moment (I plan to use Marpa
113 someday). Performance is quite lousy but I'm not annoyed enough at the
114 moment to overhaul it.
120 Steven Haryanto <stevenharyanto@gmail.com>
122 COPYRIGHT AND LICENSE
123 This software is copyright (c) 2012 by Steven Haryanto.
125 This is free software; you can redistribute it and/or modify it under
126 the same terms as the Perl 5 programming language system itself.