Element/Headline.pm

filter: Statementstmt 98.3% 182 / 185 Branchbran 71.0% 71 / 100 Conditioncond 78.4% 40 / 51 MC/DCmcdc 60.7% 17 / 28 Subroutinesub 95.2% 20 / 21 Podpod 85.7% 12 / 14 totaltotal 85.7% 342 / 399 SCAR 46.2
CC
86
Cov
87%
update_statistics_cookie
18.6
promote_node
12.0
header_as_string
11.3
CRAP 101.5
« Document.pm ↑ Summary Element/Timestamp.pm »
1 package Org::Element::Headline;
2  
3 17 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 extends 'Org::Element';
9 17 with 'Org::ElementRole';
10 17 with 'Org::ElementRole::Block';
11  
12 17 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
13 17 our $DATE = '2023-08-05'; # DATE
14 17 our $DIST = 'Org-Parser'; # DIST
15 17 our $VERSION = '0.560'; # VERSION
16  
17 17 has level => (is => 'rw');
18 17 has title => (is => 'rw');
19 17 has priority => (is => 'rw');
20 17 has tags => (is => 'rw');
21 17 has is_todo => (is => 'rw');
22 17 has is_done => (is => 'rw');
23 17 has todo_state => (is => 'rw');
24 17 has statistics_cookie => (is => 'rw');
25  
26 # old name, deprecated since 2014-07-17, will be removed in the future
27 0 ▶sub todo_priority { shift->priority(@_) }
Subroutine todo_priority: not called CC=1 SCAR=6.9
Pod undocumented
28  
29 sub extra_walkables {
30 161 ▶ my $self = shift;
Subroutine extra_walkables: called CC=1 SCAR=0.0
Pod documented
31 161 grep {defined} ($self->title);
32 }
33  
34 sub header_as_string {
35 24 ▶ my ($self) = @_;
Subroutine header_as_string: called CC=7 SCAR=24.2
Pod undocumented
36 24 ▶ return $self->_str if defined $self->_str;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->_str 23 1 24
37 join("",
38 "*" x $self->level,
39 " ",
40 $self->is_todo ? $self->todo_state." " : "",
41 $self->priority ? "[#".$self->priority."] " : "",
42 $self->statistics_cookie ? "[".$self->statistics_cookie."] " : "",
43 $self->title->as_string,
44 0 $self->tags && @{$self->tags} ?
45 1 ▶ " :".join(":", @{$self->tags}).":" : "",
Branch: 4 branches
BranchTrueFalseTotal
$self->is_todo ? : 0 1 1
$self->priority ? : 0 1 1
$self->statistics_cookie ? : 0 1 1
$self->tags && @{$self->tags;} ? : 0 1 1
Condition33%1/3
$self->tags and @{$self->tags;}
!ll&&!rl&&r
100
MC/DC0%0/2
$self->tags and @{$self->tags;}
$self->tags @{$self->tags;}
Truth table33%1/3
A and B
A= $self->tagsB= @{$self->tags;}
ABresult
0X0
100
111
46 "\n");
47 }
48  
49 sub as_string {
50 24 ▶ my ($self) = @_;
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
51 24 $self->header_as_string . $self->children_as_string;
52 }
53  
54 sub get_tags {
55 6 ▶ my ($self, $name) = @_;
Subroutine get_tags: called CC=4 SCAR=13.9
Pod documented
56 6 ▶ my @res = @{ $self->tags // [] };
Condition100%2/2
$self->tags // []
l!l
51
MC/DC100%1/1
$self->tags // []
$self->tags
Truth table100%2/2
A
A= $self->tags
Aresult
11
00
57 $self->walk_parents(
58 sub {
59 7 ▶ my ($el, $parent) = @_;
Subroutine __ANON__: called CC=5 SCAR=16.2
60 7 ▶ return 1 unless $parent->isa('Org::Element::Headline');
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->isa("Org::Element::Headline") 6 1 7
61 1 ▶ if ($parent->tags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->tags) 1 0 1
62 1 for my $tag (@{ $parent->tags }) {
63 1 ▶ push @res, $tag unless grep { $_ eq $tag } @res;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $tag;} @res 1 0 1
64 }
65 }
66 1 1;
67 6 });
68 6 for my $tag (@{ $self->document->tags }) {
69 6 ▶ push @res, $tag unless grep { $_ eq $tag } @res;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $tag;} @res 6 0 6
70 }
71 6 @res;
72 }
73  
74 sub get_active_timestamp {
75 5 ▶ my ($self) = @_;
Subroutine get_active_timestamp: called CC=3 SCAR=11.0
Pod documented
76  
77 5 for my $s ($self->title, $self) {
78 8 my $ats;
79 $s->walk(
80 sub {
81 24 ▶ my ($el) = @_;
Subroutine __ANON__: called CC=4 SCAR=13.9
82 24 ▶ return if $ats;
Branch: 1 branch
BranchTrueFalseTotal
if $ats 5 19 24
83 19 ▶ $ats = $el if $el->isa('Org::Element::Timestamp') &&
Branch: 1 branch
BranchTrueFalseTotal
if $el->isa("Org::Element::Timestamp") and $el->is_active 3 16 19
Condition100%3/3
$el->isa("Org::Element::Timestamp") and $el->is_active
!ll&&!rl&&r
1423
MC/DC100%2/2
$el->isa("Org::Element::Timestamp") and $el->is_active
$el->isa("Org::Element::Timestamp") $el->is_active
Truth table100%3/3
A and B
A= $el->isa("Org::Element::Timestamp")B= $el->is_active
ABresult
0X0
100
111
84 $el->is_active;
85 }
86 8 );
87 8 ▶ return $ats if $ats;
Branch: 1 branch
BranchTrueFalseTotal
if $ats 3 5 8
88 }
89 2 return;
90 }
91  
92 sub is_leaf {
93 4 ▶ my ($self) = @_;
Subroutine is_leaf: called CC=4 SCAR=14.0
Pod documented
94  
95 4 ▶ return 1 unless $self->children;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->children 2 2 4
96  
97 2 my $res;
98 2 for my $child (@{ $self->children }) {
99 $child->walk(
100 sub {
101 2 ▶ return if defined($res);
Subroutine __ANON__: called CC=3 SCAR=11.3
Branch: 1 branch
BranchTrueFalseTotal
if defined $res 0 2 2
102 2 my ($el) = @_;
103 2 ▶ if ($el->isa('Org::Element::Headline')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($el->isa("Org::Element::Headline")) 2 0 2
104 2 $res = 0;
105 2 goto EXIT_WALK;
106 }
107 }
108 2 );
109 }
110 EXIT_WALK:
111 2 ▶ $res //= 1;
Condition50%1/2
$res //= 1
l!l
20
MC/DC0%0/1
$res //= 1
$res
Truth table50%1/2
A
A= $res
Aresult
11
00
112 2 $res;
113 }
114  
115 sub promote_node {
116 8 ▶ my ($self, $num_levels) = @_;
Subroutine promote_node: called CC=12 SCAR=24.9
Pod documented
117 8 ▶ $num_levels //= 1;
Condition100%2/2
$num_levels //= 1
l!l
17
MC/DC100%1/1
$num_levels //= 1
$num_levels
Truth table100%2/2
A
A= $num_levels
Aresult
11
00
118 8 ▶ return if $num_levels == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels == 0 0 8 8
119 8 ▶ $self->die("Please specify a positive number of levels") if $num_levels < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels < 0 0 8 8
120  
121 8 for my $i (1..$num_levels) {
122  
123 9 my $l = $self->level;
124 9 ▶ last if $l <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $l <= 1 1 8 9
125 8 $l--;
126 8 $self->level($l);
127  
128 8 $self->_str(undef);
129  
130 8 my $parent = $self->parent;
131 8 my $siblings = $parent->children;
132 8 my $pos = $self->seniority;
133  
134 # our children stay as children
135  
136 # our right sibling headline(s) become children
137 8 while (1) {
138 11 my $s = $siblings->[$pos+1];
139 11 ▶ last unless $s && $s->isa('Org::Element::Headline')
Branch: 1 branch
BranchTrueFalseTotal
unless $s and $s->isa("Org::Element::Headline") and $s->level > $l 2 3 5
Condition83%5/6
$s and $s->isa("Org::Element::Headline") and $s->level > $l
!ll&&!rl&&r
623
$s and $s->isa("Org::Element::Headline")
!ll&&!rl&&r
605
MC/DC66%2/3
$s and $s->isa("Org::Element::Headline") and $s->level > $l
$s $s->isa("Org::Element::Headline") $s->level > $l
Truth table75%3/4
A and B and C
A= $sB= $s->isa("Org::Element::Headline")C= $s->level > $l
ABCresult
0XX0
10X0
1100
1111
140 && $s->level > $l;
141 3 ▶ $self->children([]) unless defined $self->children;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->children 1 2 3
142 3 push @{$self->children}, $s;
143 3 splice @$siblings, $pos+1, 1;
144 3 $s->parent($self);
145 }
146  
147 # our parent headline can become sibling if level is the same
148 8 ▶ if ($parent->isa('Org::Element::Headline') && $parent->level == $l) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa("Org::Element::Headline") and $parent->level == $l) 2 6 8
Condition100%3/3
$parent->isa("Org::Element::Headline") and $parent->level == $l
!ll&&!rl&&r
422
MC/DC100%2/2
$parent->isa("Org::Element::Headline") and $parent->level == $l
$parent->isa("Org::Element::Headline") $parent->level == $l
Truth table100%3/3
A and B
A= $parent->isa("Org::Element::Headline")B= $parent->level == $l
ABresult
0X0
100
111
149 2 splice @$siblings, $pos, 1;
150 2 my $gparent = $parent->parent;
151 2 splice @{$gparent->children}, $parent->seniority+1, 0, $self;
152 2 $self->parent($gparent);
153 }
154  
155 }
156 }
157  
158 sub demote_node {
159 6 ▶ my ($self, $num_levels) = @_;
Subroutine demote_node: called CC=9 SCAR=22.1
Pod documented
160 6 ▶ $num_levels //= 1;
Condition100%2/2
$num_levels //= 1
l!l
15
MC/DC100%1/1
$num_levels //= 1
$num_levels
Truth table100%2/2
A
A= $num_levels
Aresult
11
00
161 6 ▶ return if $num_levels == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels == 0 0 6 6
162 6 ▶ $self->die("Please specify a positive number of levels") if $num_levels < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels < 0 0 6 6
163  
164 6 for my $i (1..$num_levels) {
165  
166 8 my $l = $self->level;
167 8 $l++;
168 8 $self->level($l);
169  
170 8 $self->_str(undef);
171  
172 # prev sibling can become parent
173 8 my $ps = $self->prev_sibling;
174 8 ▶ if ($ps && $ps->isa('Org::Element::Headline') && $ps->level < $l) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ps and $ps->isa("Org::Element::Headline") and $ps->level < $l) 1 7 8
Condition83%5/6
$ps and $ps->isa("Org::Element::Headline") and $ps->level < $l
!ll&&!rl&&r
611
$ps and $ps->isa("Org::Element::Headline")
!ll&&!rl&&r
602
MC/DC66%2/3
$ps and $ps->isa("Org::Element::Headline") and $ps->level < $l
$ps $ps->isa("Org::Element::Headline") $ps->level < $l
Truth table75%3/4
A and B and C
A= $psB= $ps->isa("Org::Element::Headline")C= $ps->level < $l
ABCresult
0XX0
10X0
1100
1111
175 1 splice @{$self->parent->children}, $self->seniority, 1;
176 1 ▶ $ps->children([]) if !defined($ps->children);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ps->children 1 0 1
177 1 push @{$ps->children}, $self;
178 1 $self->parent($ps);
179 }
180  
181 }
182 }
183  
184 sub promote_branch {
185 1 ▶ my ($self, $num_levels) = @_;
Subroutine promote_branch: called CC=7 SCAR=20.7
Pod documented
186 1 ▶ $num_levels //= 1;
Condition50%1/2
$num_levels //= 1
l!l
01
MC/DC0%0/1
$num_levels //= 1
$num_levels
Truth table50%1/2
A
A= $num_levels
Aresult
11
00
187 1 ▶ return if $num_levels == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels == 0 0 1 1
188 1 ▶ $self->die("Please specify a positive number of levels") if $num_levels < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels < 0 0 1 1
189  
190 1 for my $i (1..$num_levels) {
191 1 ▶ last if $self->level <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->level <= 1 0 1 1
192 1 $_->promote_node() for $self->find('Headline');
193 }
194 }
195  
196 sub demote_branch {
197 1 ▶ my ($self, $num_levels) = @_;
Subroutine demote_branch: called CC=6 SCAR=18.8
Pod documented
198 1 ▶ $num_levels //= 1;
Condition50%1/2
$num_levels //= 1
l!l
01
MC/DC0%0/1
$num_levels //= 1
$num_levels
Truth table50%1/2
A
A= $num_levels
Aresult
11
00
199 1 ▶ return if $num_levels == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels == 0 0 1 1
200 1 ▶ $self->die("Please specify a positive number of levels") if $num_levels < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $num_levels < 0 0 1 1
201  
202 1 for my $i (1..$num_levels) {
203 1 $_->demote_node() for $self->find('Headline');
204 }
205 }
206  
207 sub get_drawer {
208 13 ▶ my $self = shift;
Subroutine get_drawer: called CC=7 SCAR=19.7
Pod documented
209 13 ▶ my $wanted_drawer_name = shift || "PROPERTIES";
Condition50%1/2
shift() || 'PROPERTIES'
l!l
130
MC/DC0%0/1
shift() || 'PROPERTIES'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
210  
211 13 ▶ for my $d (@{$self->children||[]}) {
Branch: 1 branch
BranchTrueFalseTotal
$self->children or [] 0 13 13
212 28 log_trace("seeking $wanted_drawer_name drawer in child: %s (%s)", $d->as_string, ref($d));
213 28 ▶ next unless ($d->isa('Org::Element::Drawer')
Branch: 1 branch
BranchTrueFalseTotal
unless $d->isa("Org::Element::Drawer") and $d->name eq $wanted_drawer_name and $d->properties 1 13 14
Condition83%5/6
$d->isa("Org::Element::Drawer") and $d->name eq $wanted_drawer_name and $d->properties
!ll&&!rl&&r
15013
$d->isa("Org::Element::Drawer") and $d->name eq $wanted_drawer_name
!ll&&!rl&&r
14113
MC/DC66%2/3
$d->isa("Org::Element::Drawer") and $d->name eq $wanted_drawer_name and $d->properties
$d->isa("Org::Element::Drawer") $d->name eq $wanted_drawer_name $d->properties
Truth table75%3/4
A and B and C
A= $d->isa("Org::Element::Drawer")B= $d->name eq $wanted_drawer_nameC= $d->properties
ABCresult
0XX0
10X0
1100
1111
214 && $d->name eq $wanted_drawer_name
215 && $d->properties);
216 13 return $d;
217 }
218 }
219  
220 sub get_property {
221 12 ▶ my ($self, $name, $search_parent, $search_docprop) = @_;
Subroutine get_property: called CC=10 SCAR=23.2
Pod documented
222 #$log->tracef("-> get_property(%s, search_par=%s)", $name, $search_parent);
223 12 my $parent = $self->parent;
224  
225 12 my $propd = $self->get_drawer("PROPERTIES");
226 return $propd->properties->{$name} if
227 12 ▶ $propd && defined $propd->properties->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $propd and defined $propd->properties->{$name} 5 7 12
Condition66%2/3
$propd and defined $propd->properties->{$name}
!ll&&!rl&&r
075
MC/DC50%1/2
$propd and defined $propd->properties->{$name}
$propd defined $propd->properties->{$name}
Truth table66%2/3
A and B
A= $propdB= defined $propd->properties->{$name}
ABresult
0X0
100
111
228  
229 7 ▶ if ($parent && $search_parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent and $search_parent) 2 5 7
Condition66%2/3
$parent and $search_parent
!ll&&!rl&&r
052
MC/DC50%1/2
$parent and $search_parent
$parent $search_parent
Truth table66%2/3
A and B
A= $parentB= $search_parent
ABresult
0X0
100
111
230 2 ▶ while ($parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent) 3 0 3
231 3 ▶ if ($parent->isa('Org::Element::Headline')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa("Org::Element::Headline")) 3 0 3
232 3 my $res = $parent->get_property($name, 0, 0);
233 3 ▶ return $res if defined $res;
Branch: 1 branch
BranchTrueFalseTotal
if defined $res 2 1 3
234 }
235 1 $parent = $parent->parent;
236 }
237 }
238  
239 5 ▶ if ($search_docprop // 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search_docprop // 1) 4 1 5
Condition100%2/2
$search_docprop // 1
l!l
14
MC/DC100%1/1
$search_docprop // 1
$search_docprop
Truth table100%2/2
A
A= $search_docprop
Aresult
11
00
240 4 log_trace("Getting property from document's .properties");
241 4 return $self->document->properties->{$name};
242 }
243 1 undef;
244 }
245  
246 sub update_statistics_cookie {
247 8 ▶ my $self = shift;
Subroutine update_statistics_cookie: called CC=18 SCAR=29.2
Pod documented
248  
249 8 my $statc = $self->statistics_cookie;
250 8 ▶ return unless $statc;
Branch: 1 branch
BranchTrueFalseTotal
unless $statc 4 4 8
251  
252 4 my $num_done = 0;
253 4 my $num_total = 0;
254  
255 # count using checks on first-level list's children, or from first-level
256 # subheadlines
257 4 ▶ for my $chld (@{ $self->children // [] }) {
Condition100%2/2
$self->children // []
l!l
22
MC/DC100%1/1
$self->children // []
$self->children
Truth table100%2/2
A
A= $self->children
Aresult
11
00
258 2 ▶ if ($chld->isa("Org::Element::Headline")) {
Branch: 2 branches
BranchTrueFalseTotal
if ($chld->isa('Org::Element::Headline')) { } 1 1 2
elsif ($chld->isa('Org::Element::List')) { } 1 0 1
259 1 for my $el (@{ $self->children }) {
260 3 ▶ next unless $el->isa("Org::Element::Headline");
Branch: 1 branch
BranchTrueFalseTotal
unless $el->isa("Org::Element::Headline") 0 3 3
261 3 ▶ if ($el->is_todo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($el->is_todo) 3 0 3
262 3 $num_total++;
263 3 ▶ $num_done++ if $el->is_done;
Branch: 1 branch
BranchTrueFalseTotal
if $el->is_done 1 2 3
264 }
265 }
266 1 last;
267 } elsif ($chld->isa("Org::Element::List")) {
268 1 for my $el (@{ $self->children }) {
269 1 ▶ next unless $el->isa("Org::Element::List");
Branch: 1 branch
BranchTrueFalseTotal
unless $el->isa("Org::Element::List") 0 1 1
270 1 for my $el2 (@{ $el->children }) {
271 3 ▶ next unless $el2->isa("Org::Element::ListItem");
Branch: 1 branch
BranchTrueFalseTotal
unless $el2->isa("Org::Element::ListItem") 0 3 3
272 3 my $state = $el2->check_state;
273 3 ▶ if (defined $state) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $state) 3 0 3
274 3 $num_total++;
275 3 ▶ $num_done++ if $state eq 'X';
Branch: 1 branch
BranchTrueFalseTotal
if $state eq "X" 2 1 3
276 }
277 }
278 }
279 1 last;
280 }
281 }
282  
283 4 undef $self->{_str}; # we modify content
284 4 ▶ if ($statc =~ /%/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($statc =~ /%/l) { } 1 3 4
285 1 ▶ $self->statistics_cookie(
Branch: 1 branch
BranchTrueFalseTotal
$num_total == 0 ? : 1 0 1
286 sprintf("%d%%", $num_total == 0 ? 0 : $num_done/$num_total * 100));
287 } else {
288 3 $self->statistics_cookie(sprintf("%d/%d", $num_done, $num_total));
289 }
290 }
291  
292 17 1;
293 # ABSTRACT: Represent Org headline
294  
295 __END__
296  
297 =pod
298  
299 =encoding UTF-8
300  
301 =head1 NAME
302  
303 Org::Element::Headline - Represent Org headline
304  
305 =head1 VERSION
306  
307 This document describes version 0.560 of Org::Element::Headline (from Perl distribution Org-Parser), released on 2023-08-05.
308  
309 =head1 DESCRIPTION
310  
311 Derived from L<Org::Element>.
312  
313 =for Pod::Coverage ^(header_as_string|as_string|todo_priority)$
314  
315 =head1 ATTRIBUTES
316  
317 =head2 level => INT
318  
319 Level of headline (e.g. 1, 2, 3). Corresponds to the number of bullet stars.
320  
321 =head2 title => OBJ
322  
323 L<Org::Element::Text> representing the headline title
324  
325 =head2 priority => STR
326  
327 String (optional) representing priority.
328  
329 =head2 tags => ARRAY
330  
331 Arrayref (optional) containing list of defined tags.
332  
333 =head2 is_todo => BOOL
334  
335 Whether this headline is a TODO item.
336  
337 =head2 is_done => BOOL
338  
339 Whether this TODO item is in a done state (state which requires no more action,
340 e.g. DONE). Only meaningful if headline is a TODO item.
341  
342 =head2 todo_state => STR
343  
344 TODO state.
345  
346 =head2 statistics_cookie => STR
347  
348 Statistics cookie, e.g. '5/10' or '50%'. TODO: there might be more than one
349 statistics cookie.
350  
351 =head1 METHODS
352  
353 =head2 $el->get_tags() => ARRAY
354  
355 Get tags for this headline. A headline can define tags or inherit tags from its
356 parent headline (or from document).
357  
358 =head2 $el->get_active_timestamp() => ELEMENT
359  
360 Get the first active timestamp element for this headline, either in the title or
361 in the child elements.
362  
363 =head2 $el->is_leaf() => BOOL
364  
365 Returns true if element doesn't contain subtrees.
366  
367 =head2 $el->promote_node([$num_levels])
368  
369 Promote (decrease the level) of this headline node. $level specifies number of
370 levels, defaults to 1. Won't further promote if already at level 1.
371 Illustration:
372  
373 * h1
374 ** h2 <-- promote 1 level
375 *** h3
376 *** h3b
377 ** h4
378 * h5
379  
380 becomes:
381  
382 * h1
383 * h2
384 *** h3
385 *** h3b
386 ** h4
387 * h5
388  
389 =head2 $el->demote_node([$num_levels])
390  
391 Does the opposite of promote_node().
392  
393 =head2 $el->promote_branch([$num_levels])
394  
395 Like promote_node(), but all children headlines will also be promoted.
396 Illustration:
397  
398 * h1
399 ** h2 <-- promote 1 level
400 *** h3
401 **** grandkid
402 *** h3b
403  
404 ** h4
405 * h5
406  
407 becomes:
408  
409 * h1
410 * h2
411 ** h3
412 *** grandkid
413 ** h3b
414  
415 ** h4
416 * h5
417  
418 =head2 $el->demote_branch([$num_levels])
419  
420 Does the opposite of promote_branch().
421  
422 =head2 $el->get_property($name, $search_parent) => VALUE
423  
424 Search for property named $name in the PROPERTIES drawer. If $search_parent is
425 set to true (default is false), will also search in upper-level properties
426 (useful for searching for inherited property, like foo_ALL). Return undef if
427 property cannot be found.
428  
429 Regardless of $search_parent setting, file-wide properties will be consulted if
430 property is not found in the headline's properties drawer.
431  
432 =head2 $el->get_drawer([$drawer_name]) => VALUE
433  
434 Return an entire drawer as an Org::Element::Drawer object. By default, return the
435 PROPERTIES drawer. If you want LOGBOOK or some other drawer, ask for it by name.
436  
437 =head2 $el->update_statistics_cookie
438  
439 Update the statistics cookies by recalculating the number of TODO and
440 checkboxes.
441  
442 Will do nothing if the headline does not have any statistics cookie.
443  
444 =head1 HOMEPAGE
445  
446 Please visit the project's homepage at L<https://metacpan.org/release/Org-Parser>.
447  
448 =head1 SOURCE
449  
450 Source repository is at L<https://github.com/perlancar/perl-Org-Parser>.
451  
452 =head1 AUTHOR
453  
454 perlancar <perlancar@cpan.org>
455  
456 =head1 CONTRIBUTING
457  
458  
459 To contribute, you can send patches by email/via RT, or send pull requests on
460 GitHub.
461  
462 Most of the time, you don't need to build the distribution yourself. You can
463 simply modify the code, then test via:
464  
465 % prove -l
466  
467 If you want to build the distribution (e.g. to try to install it locally on your
468 system), you can install L<Dist::Zilla>,
469 L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
470 L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
471 Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
472 that are considered a bug and can be reported to me.
473  
474 =head1 COPYRIGHT AND LICENSE
475  
476 This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar <perlancar@cpan.org>.
477  
478 This is free software; you can redistribute it and/or modify it under
479 the same terms as the Perl 5 programming language system itself.
480  
481 =head1 BUGS
482  
483 Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Org-Parser>
484  
485 When submitting a bug or request, please include a test-file or a
486 patch to an existing test-file that illustrates the bug or desired
487 feature.
488  
489 =cut
« Document.pm ↑ Summary Element/Timestamp.pm »