summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Markdown/GFM/SyntaxExtension.pm
diff options
context:
space:
mode:
authorIsrael Madueme <purelogiq@gmail.com>2018-06-15 23:42:19 +0200
committerDylan William Hardison <dylan@hardison.net>2018-06-15 23:42:19 +0200
commit170ec08234e29050c5d78d52e4100207625897d2 (patch)
tree14e8abc9e746dc30f42527b024d85b64f474e001 /Bugzilla/Markdown/GFM/SyntaxExtension.pm
parent404dc5496967203c5f99755340f43d712420446a (diff)
downloadbugzilla-170ec08234e29050c5d78d52e4100207625897d2.tar.gz
bugzilla-170ec08234e29050c5d78d52e4100207625897d2.tar.xz
Bug 1456877 - Add a wrapper around libcmark_gfm to Bugzilla
Diffstat (limited to 'Bugzilla/Markdown/GFM/SyntaxExtension.pm')
-rw-r--r--Bugzilla/Markdown/GFM/SyntaxExtension.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/Bugzilla/Markdown/GFM/SyntaxExtension.pm b/Bugzilla/Markdown/GFM/SyntaxExtension.pm
new file mode 100644
index 000000000..56efa177a
--- /dev/null
+++ b/Bugzilla/Markdown/GFM/SyntaxExtension.pm
@@ -0,0 +1,31 @@
+package Bugzilla::Markdown::GFM::SyntaxExtension;
+
+use 5.10.1;
+use strict;
+use warnings;
+
+sub SETUP {
+ 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]);
+ }
+ );
+}
+
+1;
+
+__END__