| 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-11-06'; # DATE | |||||||||||||||||||||||||||||||||||||||||
| 14 | 17 | our $DIST = 'Org-Parser'; # DIST | |||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | our $VERSION = '0.561'; # 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$self->tags and @{$self->tags;}
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;}
| |||||||||||||||||||||||||||||||||||||||||||
| 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 // []
MC/DC100%1/1
$self->tags // []
$self->tags
Truth table100%2/2
A
A= $self->tags
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | if ($parent->tags) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | for my $tag (@{ $parent->tags }) { | |||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | push @res, $tag unless grep { $_ eq $tag } @res; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 19 | ▶ | $ats = $el if $el->isa('Org::Element::Timestamp') && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$el->isa("Org::Element::Timestamp") and $el->is_active
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
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | $el->is_active; | ||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | return $ats if $ats; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | my ($el) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | if ($el->isa('Org::Element::Headline')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/1
$res //= 1
$res
Truth table50%1/2
A
A= $res
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC100%1/1
$num_levels //= 1
$num_levels
Truth table100%2/2
A
A= $num_levels
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 8 | ▶ | return if $num_levels == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 8 | ▶ | $self->die("Please specify a positive number of levels") if $num_levels < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition83%5/6
$s and $s->isa("Org::Element::Headline") and $s->level > $l
$s and $s->isa("Org::Element::Headline")
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
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | && $s->level > $l; | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | ▶ | $self->children([]) unless defined $self->children; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
$parent->isa("Org::Element::Headline") and $parent->level == $l
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC100%1/1
$num_levels //= 1
$num_levels
Truth table100%2/2
A
A= $num_levels
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 6 | ▶ | return if $num_levels == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 6 | ▶ | $self->die("Please specify a positive number of levels") if $num_levels < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition83%5/6
$ps and $ps->isa("Org::Element::Headline") and $ps->level < $l
$ps and $ps->isa("Org::Element::Headline")
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
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | splice @{$self->parent->children}, $self->seniority, 1; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | $ps->children([]) if !defined($ps->children); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/1
$num_levels //= 1
$num_levels
Truth table50%1/2
A
A= $num_levels
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | ▶ | return if $num_levels == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ▶ | $self->die("Please specify a positive number of levels") if $num_levels < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | for my $i (1..$num_levels) { | |||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | last if $self->level <= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/1
$num_levels //= 1
$num_levels
Truth table50%1/2
A
A= $num_levels
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | return if $num_levels == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | $self->die("Please specify a positive number of levels") if $num_levels < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
shift() || 'PROPERTIES'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 13 | ▶ | for my $d (@{$self->children||[]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition83%5/6
$d->isa("Org::Element::Drawer") and $d->name eq $wanted_drawer_name and $d->properties
$d->isa("Org::Element::Drawer") and $d->name eq $wanted_drawer_name
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$propd and defined $propd->properties->{$name}
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}
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 7 | ▶ | if ($parent && $search_parent) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$parent and $search_parent
MC/DC50%1/2
$parent and $search_parent
$parent
$search_parent
Truth table66%2/3
A and B
A= $parentB= $search_parent
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | ▶ | while ($parent) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | if ($parent->isa('Org::Element::Headline')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 3 | my $res = $parent->get_property($name, 0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 233 | 3 | ▶ | return $res if defined $res; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | $parent = $parent->parent; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 5 | ▶ | if ($search_docprop // 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$search_docprop // 1
MC/DC100%1/1
$search_docprop // 1
$search_docprop
Truth table100%2/2
A
A= $search_docprop
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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 // []
MC/DC100%1/1
$self->children // []
$self->children
Truth table100%2/2
A
A= $self->children
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | if ($chld->isa("Org::Element::Headline")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | for my $el (@{ $self->children }) { | |||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | ▶ | next unless $el->isa("Org::Element::Headline"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | ▶ | if ($el->is_todo) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | $num_total++; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | ▶ | $num_done++ if $el->is_done; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | for my $el2 (@{ $el->children }) { | |||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | ▶ | next unless $el2->isa("Org::Element::ListItem"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 3 | my $state = $el2->check_state; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 3 | ▶ | if (defined $state) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | $num_total++; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | ▶ | $num_done++ if $state eq 'X'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | undef $self->{_str}; # we modify content | |||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | ▶ | if ($statc =~ /%/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | ▶ | $self->statistics_cookie( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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.561 of Org::Element::Headline (from Perl distribution Org-Parser), released on 2023-11-06. | ||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||