1 package Org::Element::Block;
6 extends 'Org::Element';
8 our $VERSION = '0.23'; # VERSION
10 has name => (is => 'rw');
11 has args => (is => 'rw');
12 has raw_content => (is => 'rw');
13 has begin_indent => (is => 'rw');
14 has end_indent => (is => 'rw');
16 my @known_blocks = qw(
17 ASCII CENTER COMMENT EXAMPLE HTML
22 my ($self, $args) = @_;
23 $self->name(uc $self->name);
24 $self->name ~~ @known_blocks or die "Unknown block name: ".$self->name;
27 sub element_as_string {
29 return $self->_str if defined $self->_str;
31 $self->begin_indent // "",
32 "#+BEGIN_".uc($self->name),
33 $self->args && @{$self->args} ?
34 " ".Org::Document::__format_args($self->args) : "",
37 $self->end_indent // "",
38 "#+END_".uc($self->name)."\n");
42 # ABSTRACT: Represent Org block
49 Org::Element::Block - Represent Org block
57 Derived from L<Org::Element>.
63 Block name. For example, #+begin_src ... #+end_src is an 'SRC' block.
67 =head2 raw_content => STR
69 =head2 begin_indent => STR
71 Indentation on begin line (before C<#+BEGIN>), or empty string if none.
73 =head2 end_indent => STR
75 Indentation on end line (before C<#+END>), or empty string if none.
79 =for Pod::Coverage element_as_string BUILD
83 Steven Haryanto <stevenharyanto@gmail.com>
85 =head1 COPYRIGHT AND LICENSE
87 This software is copyright (c) 2012 by Steven Haryanto.
89 This is free software; you can redistribute it and/or modify it under
90 the same terms as the Perl 5 programming language system itself.