diff options
author | Perl Tidy <perltidy@bugzilla.org> | 2018-12-05 21:38:52 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2018-12-05 23:49:08 +0100 |
commit | 8ec8da0491ad89604700b3e29a227966f6d84ba1 (patch) | |
tree | 9d270f173330ca19700e0ba9f2ee931300646de1 /Bugzilla/Markdown | |
parent | a7bb5a65b71644d9efce5fed783ed545b9336548 (diff) | |
download | bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.gz bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.xz |
no bug - reformat all the code using the new perltidy rules
Diffstat (limited to 'Bugzilla/Markdown')
-rw-r--r-- | Bugzilla/Markdown/GFM.pm | 80 | ||||
-rw-r--r-- | Bugzilla/Markdown/GFM/Node.pm | 34 | ||||
-rw-r--r-- | Bugzilla/Markdown/GFM/Parser.pm | 129 | ||||
-rw-r--r-- | Bugzilla/Markdown/GFM/SyntaxExtension.pm | 36 | ||||
-rw-r--r-- | Bugzilla/Markdown/GFM/SyntaxExtensionList.pm | 20 |
5 files changed, 146 insertions, 153 deletions
diff --git a/Bugzilla/Markdown/GFM.pm b/Bugzilla/Markdown/GFM.pm index 367dc7a53..437122093 100644 --- a/Bugzilla/Markdown/GFM.pm +++ b/Bugzilla/Markdown/GFM.pm @@ -17,55 +17,55 @@ use Bugzilla::Markdown::GFM::Node; our @EXPORT_OK = qw(cmark_markdown_to_html); my %OPTIONS = ( - default => 0, - sourcepos => ( 1 << 1 ), - hardbreaks => ( 1 << 2 ), - safe => ( 1 << 3 ), - nobreaks => ( 1 << 4 ), - normalize => ( 1 << 8 ), - validate_utf8 => ( 1 << 9 ), - smart => ( 1 << 10 ), - github_pre_lang => ( 1 << 11 ), - liberal_html_tag => ( 1 << 12 ), - footnotes => ( 1 << 13 ), - strikethrough_double_tilde => ( 1 << 14 ), - table_prefer_style_attributes => ( 1 << 15 ), + default => 0, + sourcepos => (1 << 1), + hardbreaks => (1 << 2), + safe => (1 << 3), + nobreaks => (1 << 4), + normalize => (1 << 8), + validate_utf8 => (1 << 9), + smart => (1 << 10), + github_pre_lang => (1 << 11), + liberal_html_tag => (1 << 12), + footnotes => (1 << 13), + strikethrough_double_tilde => (1 << 14), + table_prefer_style_attributes => (1 << 15), ); my $FFI = FFI::Platypus->new( - lib => [grep { not -l $_ } Alien::libcmark_gfm->dynamic_libs], -); + lib => [grep { not -l $_ } Alien::libcmark_gfm->dynamic_libs],); $FFI->custom_type( - markdown_options_t => { - native_type => 'int', - native_to_perl => sub { - my ($options) = @_; - my $result = {}; - foreach my $key (keys %OPTIONS) { - $result->{$key} = ($options & $OPTIONS{$key}) != 0; - } - return $result; - }, - perl_to_native => sub { - my ($options) = @_; - my $result = 0; - foreach my $key (keys %OPTIONS) { - if ($options->{$key}) { - $result |= $OPTIONS{$key}; - } - } - return $result; + markdown_options_t => { + native_type => 'int', + native_to_perl => sub { + my ($options) = @_; + my $result = {}; + foreach my $key (keys %OPTIONS) { + $result->{$key} = ($options & $OPTIONS{$key}) != 0; + } + return $result; + }, + perl_to_native => sub { + my ($options) = @_; + my $result = 0; + foreach my $key (keys %OPTIONS) { + if ($options->{$key}) { + $result |= $OPTIONS{$key}; } + } + return $result; } + } ); -$FFI->attach(cmark_markdown_to_html => ['opaque', 'int', 'markdown_options_t'] => 'string', - sub { - my $c_func = shift; - my($markdown, $markdown_length) = scalar_to_buffer $_[0]; - return $c_func->($markdown, $markdown_length, $_[1]); - } +$FFI->attach( + cmark_markdown_to_html => ['opaque', 'int', 'markdown_options_t'] => 'string', + sub { + my $c_func = shift; + my ($markdown, $markdown_length) = scalar_to_buffer $_[0]; + return $c_func->($markdown, $markdown_length, $_[1]); + } ); # This has to happen after something from the main lib is loaded diff --git a/Bugzilla/Markdown/GFM/Node.pm b/Bugzilla/Markdown/GFM/Node.pm index da5af1a68..934cb4055 100644 --- a/Bugzilla/Markdown/GFM/Node.pm +++ b/Bugzilla/Markdown/GFM/Node.pm @@ -5,27 +5,25 @@ use strict; use warnings; sub SETUP { - my ($class, $FFI) = @_; + my ($class, $FFI) = @_; - $FFI->custom_type( - markdown_node_t => { - native_type => 'opaque', - native_to_perl => sub { - bless \$_[0], $class if $_[0]; - }, - perl_to_native => sub { ${ $_[0] } }, - } - ); + $FFI->custom_type( + markdown_node_t => { + native_type => 'opaque', + native_to_perl => sub { + bless \$_[0], $class if $_[0]; + }, + perl_to_native => sub { ${$_[0]} }, + } + ); - $FFI->attach( - [ cmark_node_free => 'DESTROY' ], - [ 'markdown_node_t' ] => 'void' - ); + $FFI->attach([cmark_node_free => 'DESTROY'], ['markdown_node_t'] => 'void'); - $FFI->attach( - [ cmark_render_html => 'render_html' ], - [ 'markdown_node_t', 'markdown_options_t', 'markdown_syntax_extension_list_t'] => 'string', - ); + $FFI->attach( + [cmark_render_html => 'render_html'], + ['markdown_node_t', 'markdown_options_t', + 'markdown_syntax_extension_list_t'] => 'string', + ); } 1; 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; diff --git a/Bugzilla/Markdown/GFM/SyntaxExtension.pm b/Bugzilla/Markdown/GFM/SyntaxExtension.pm index 56efa177a..213980485 100644 --- a/Bugzilla/Markdown/GFM/SyntaxExtension.pm +++ b/Bugzilla/Markdown/GFM/SyntaxExtension.pm @@ -5,25 +5,25 @@ use strict; use warnings; sub SETUP { - my ($class, $FFI) = @_; + my ($class, $FFI) = @_; - $FFI->custom_type( - markdown_syntax_extension_t => { - native_type => 'opaque', - native_to_perl => sub { - bless \$_[0], $class if $_[0]; - }, - perl_to_native => sub { $_[0] ? ${ $_[0] } : 0 }, - } - ); - $FFI->attach( - [ cmark_find_syntax_extension => 'find' ], - [ 'string' ] => 'markdown_syntax_extension_t', - sub { - my $c_func = shift; - return $c_func->($_[1]); - } - ); + $FFI->custom_type( + markdown_syntax_extension_t => { + native_type => 'opaque', + native_to_perl => sub { + bless \$_[0], $class if $_[0]; + }, + perl_to_native => sub { $_[0] ? ${$_[0]} : 0 }, + } + ); + $FFI->attach( + [cmark_find_syntax_extension => 'find'], + ['string'] => 'markdown_syntax_extension_t', + sub { + my $c_func = shift; + return $c_func->($_[1]); + } + ); } 1; diff --git a/Bugzilla/Markdown/GFM/SyntaxExtensionList.pm b/Bugzilla/Markdown/GFM/SyntaxExtensionList.pm index 06a9798c2..963dec26d 100644 --- a/Bugzilla/Markdown/GFM/SyntaxExtensionList.pm +++ b/Bugzilla/Markdown/GFM/SyntaxExtensionList.pm @@ -5,17 +5,17 @@ use strict; use warnings; sub SETUP { - my ($class, $FFI) = @_; + my ($class, $FFI) = @_; - $FFI->custom_type( - markdown_syntax_extension_list_t => { - native_type => 'opaque', - native_to_perl => sub { - bless \$_[0], $class if $_[0]; - }, - perl_to_native => sub { $_[0] ? ${ $_[0] } : 0 }, - } - ); + $FFI->custom_type( + markdown_syntax_extension_list_t => { + native_type => 'opaque', + native_to_perl => sub { + bless \$_[0], $class if $_[0]; + }, + perl_to_native => sub { $_[0] ? ${$_[0]} : 0 }, + } + ); } 1; |