Element/Text.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond 50.0% 6 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 76.4% 39 / 51 CC 7 SCAR 12.8
CC
7
Cov
84%
as_string
4.6
as_text
4.6
BEGIN
1.0
CRAP 3.6
« Element.pm ↑ Summary Element/TableHLine.pm »
1 package Org::Element::Text;
2  
3 25 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶use locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 25 extends 'Org::Element';
7 25 with 'Org::ElementRole';
8 25 with 'Org::ElementRole::Inline';
9  
10 25 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
11 25 our $DATE = '2023-11-06'; # DATE
12 25 our $DIST = 'Org-Parser'; # DIST
13 25 our $VERSION = '0.561'; # VERSION
14  
15 25 has text => (is => 'rw');
16 25 has style => (is => 'rw');
17  
18 25 our %mu2style = (''=>'', '*'=>'B', '_'=>'U', '/'=>'I',
19 '+'=>'S', '='=>'C', '~'=>'V');
20 25 our %style2mu = reverse(%mu2style);
21  
22 sub as_string {
23 194 ▶ my ($self) = @_;
Subroutine as_string: called CC=4 SCAR=15.2
Pod documented
24 194 ▶ my $muchar = $style2mu{$self->style // ''} // '';
Condition50%2/4
$Org::Element::Text::style2mu{$self->style // ""} // ""
l!l
1940
$self->style // ""
l!l
1940
MC/DC0%0/1
$Org::Element::Text::style2mu{$self->style // ""} // ""
$Org::Element::Text::style2mu{$self->style // ""}
MC/DC0%0/1
$self->style // ""
$self->style
Truth table50%1/2
A
A= $Org::Element::Text::style2mu{$self->style // ""}
Aresult
11
00
Truth table50%1/2
A
A= $self->style
Aresult
11
00
25  
26 194 ▶ join("",
Condition50%1/2
$self->text // ""
l!l
1940
MC/DC0%0/1
$self->text // ""
$self->text
Truth table50%1/2
A
A= $self->text
Aresult
11
00
27 $muchar,
28 $self->text // '', $self->children_as_string,
29 $muchar);
30 }
31  
32 sub as_text {
33 1 ▶ my $self = shift;
Subroutine as_text: called CC=4 SCAR=15.2
Pod documented
34 1 ▶ my $muchar = $style2mu{$self->style // ''} // '';
Condition50%2/4
$Org::Element::Text::style2mu{$self->style // ""} // ""
l!l
10
$self->style // ""
l!l
10
MC/DC0%0/1
$Org::Element::Text::style2mu{$self->style // ""} // ""
$Org::Element::Text::style2mu{$self->style // ""}
MC/DC0%0/1
$self->style // ""
$self->style
Truth table50%1/2
A
A= $Org::Element::Text::style2mu{$self->style // ""}
Aresult
11
00
Truth table50%1/2
A
A= $self->style
Aresult
11
00
35  
36 1 ▶ join("",
Condition50%1/2
$self->text // ""
l!l
10
MC/DC0%0/1
$self->text // ""
$self->text
Truth table50%1/2
A
A= $self->text
Aresult
11
00
37 $muchar,
38 $self->text // '', $self->children_as_text,
39 $muchar);
40 }
41  
42 25 1;
43 # ABSTRACT: Represent text
44  
45 __END__
46  
47 =pod
48  
49 =encoding UTF-8
50  
51 =head1 NAME
52  
53 Org::Element::Text - Represent text
54  
55 =head1 VERSION
56  
57 This document describes version 0.561 of Org::Element::Text (from Perl distribution Org-Parser), released on 2023-11-06.
58  
59 =head1 DESCRIPTION
60  
61 Derived from L<Org::Element>.
62  
63 Org::Element::Text is an object that represents a piece of text. It has C<text>
64 and C<style> attributes. Simple text like C<Jakarta> or C<*Jakarta!*> will be
65 represented, respectively, as C<(text=Jakarta, style='')> and C<text=Jakarta!,
66 style=B> (for bold).
67  
68 This object can also hold other inline (non-block) elements, e.g. links, radio
69 targets, timestamps, time ranges. They are all put in the C<children> attribute.
70  
71 =for Pod::Coverage as_string
72  
73 =head1 ATTRIBUTES
74  
75 =head2 text => str
76  
77 Plain text for this object I<only>. Note that if you want to get a plain text
78 representation for the whole text (including child elements), you'd want the
79 C<as_text> method.
80  
81 =head2 style => str
82  
83 ''=normal, I=italic, B=bold, U=underline, S=strikethrough, V=verbatim,
84 C=code
85  
86 =head1 METHODS
87  
88 =head2 as_text => str
89  
90 From L<Org::ElementRole::Inline>.
91  
92 =head2 as_string => str
93  
94 From L<Org::Element>.
95  
96 =head1 HOMEPAGE
97  
98 Please visit the project's homepage at L<https://metacpan.org/release/Org-Parser>.
99  
100 =head1 SOURCE
101  
102 Source repository is at L<https://github.com/perlancar/perl-Org-Parser>.
103  
104 =head1 AUTHOR
105  
106 perlancar <perlancar@cpan.org>
107  
108 =head1 CONTRIBUTING
109  
110  
111 To contribute, you can send patches by email/via RT, or send pull requests on
112 GitHub.
113  
114 Most of the time, you don't need to build the distribution yourself. You can
115 simply modify the code, then test via:
116  
117 % prove -l
118  
119 If you want to build the distribution (e.g. to try to install it locally on your
120 system), you can install L<Dist::Zilla>,
121 L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
122 L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
123 Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
124 that are considered a bug and can be reported to me.
125  
126 =head1 COPYRIGHT AND LICENSE
127  
128 This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar <perlancar@cpan.org>.
129  
130 This is free software; you can redistribute it and/or modify it under
131 the same terms as the Perl 5 programming language system itself.
132  
133 =head1 BUGS
134  
135 Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Org-Parser>
136  
137 When submitting a bug or request, please include a test-file or a
138 patch to an existing test-file that illustrates the bug or desired
139 feature.
140  
141 =cut
« Element.pm ↑ Summary Element/TableHLine.pm »