From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- Bugzilla/Markdown/GFM/Parser.pm | 129 +++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 67 deletions(-) (limited to 'Bugzilla/Markdown/GFM/Parser.pm') diff --git a/Bugzilla/Markdown/GFM/Parser.pm b/Bugzilla/Markdown/GFM/Parser.pm index 5307b49c1..7e16b2b31 100644 --- a/Bugzilla/Markdown/GFM/Parser.pm +++ b/Bugzilla/Markdown/GFM/Parser.pm @@ -7,79 +7,74 @@ use warnings; use FFI::Platypus::Buffer qw( scalar_to_buffer buffer_to_scalar ); sub new { - my ($class, $options) = @_; - my $extensions = delete $options->{extensions} // []; - my $parser = $class->_new($options); - $parser->{_options} = $options; - - eval { - foreach my $name (@$extensions) { - my $extension = Bugzilla::Markdown::GFM::SyntaxExtension->find($name) - or die "unknown extension: $name"; - $parser->attach_syntax_extension($extension); - } - }; - - return $parser; + my ($class, $options) = @_; + my $extensions = delete $options->{extensions} // []; + my $parser = $class->_new($options); + $parser->{_options} = $options; + + eval { + foreach my $name (@$extensions) { + my $extension = Bugzilla::Markdown::GFM::SyntaxExtension->find($name) + or die "unknown extension: $name"; + $parser->attach_syntax_extension($extension); + } + }; + + return $parser; } sub render_html { - my ($self, $markdown) = @_; - $self->feed($markdown); - my $node = $self->finish; - return $node->render_html($self->{_options}, $self->get_syntax_extensions); + my ($self, $markdown) = @_; + $self->feed($markdown); + my $node = $self->finish; + return $node->render_html($self->{_options}, $self->get_syntax_extensions); } sub SETUP { - my ($class, $FFI) = @_; - - $FFI->custom_type( - markdown_parser_t => { - native_type => 'opaque', - native_to_perl => sub { - bless { _pointer => $_[0] }, $class; - }, - perl_to_native => sub { $_[0]->{_pointer} }, - } - ); - - $FFI->attach( - [ cmark_parser_new => '_new' ], - [ 'markdown_options_t' ] => 'markdown_parser_t', - sub { - my $c_func = shift; - return $c_func->($_[1]); - } - ); - - $FFI->attach( - [ cmark_parser_free => 'DESTROY' ], - [ 'markdown_parser_t' ] => 'void' - ); - - $FFI->attach( - [ cmark_parser_feed => 'feed'], - ['markdown_parser_t', 'opaque', 'int'] => 'void', - sub { - my $c_func = shift; - $c_func->($_[0], scalar_to_buffer $_[1]); - } - ); - - $FFI->attach( - [ cmark_parser_finish => 'finish' ], - [ 'markdown_parser_t' ] => 'markdown_node_t', - ); - - $FFI->attach( - [ cmark_parser_attach_syntax_extension => 'attach_syntax_extension' ], - [ 'markdown_parser_t', 'markdown_syntax_extension_t' ] => 'void', - ); - - $FFI->attach( - [ cmark_parser_get_syntax_extensions => 'get_syntax_extensions' ], - [ 'markdown_parser_t' ] => 'markdown_syntax_extension_list_t', - ); + my ($class, $FFI) = @_; + + $FFI->custom_type( + markdown_parser_t => { + native_type => 'opaque', + native_to_perl => sub { + bless {_pointer => $_[0]}, $class; + }, + perl_to_native => sub { $_[0]->{_pointer} }, + } + ); + + $FFI->attach( + [cmark_parser_new => '_new'], + ['markdown_options_t'] => 'markdown_parser_t', + sub { + my $c_func = shift; + return $c_func->($_[1]); + } + ); + + $FFI->attach([cmark_parser_free => 'DESTROY'], ['markdown_parser_t'] => 'void'); + + $FFI->attach( + [cmark_parser_feed => 'feed'], + ['markdown_parser_t', 'opaque', 'int'] => 'void', + sub { + my $c_func = shift; + $c_func->($_[0], scalar_to_buffer $_[1]); + } + ); + + $FFI->attach([cmark_parser_finish => 'finish'], + ['markdown_parser_t'] => 'markdown_node_t',); + + $FFI->attach( + [cmark_parser_attach_syntax_extension => 'attach_syntax_extension'], + ['markdown_parser_t', 'markdown_syntax_extension_t'] => 'void', + ); + + $FFI->attach( + [cmark_parser_get_syntax_extensions => 'get_syntax_extensions'], + ['markdown_parser_t'] => 'markdown_syntax_extension_list_t', + ); } 1; -- cgit v1.2.3-24-g4f1b