File Coverage

blib/lib/Org/Element/Text.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition 6 12 50.0
subroutine 5 5 100.0
pod 2 2 100.0
total 27 33 81.8


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