File Coverage

blib/lib/Pandoc.pm
Criterion Covered Total %
statement 47 198 23.7
branch 9 100 9.0
condition 7 83 8.4
subroutine 13 30 43.3
pod 18 19 94.7
total 94 430 21.8


line stmt bran cond sub pod time code
1             package Pandoc;
2 10     10   1491211 use 5.014;
  10         40  
3 10     10   65 use warnings;
  10         17  
  10         706  
4              
5 10     10   5655 use utf8;
  10         3232  
  10         66  
6              
7             =head1 NAME
8              
9             Pandoc - wrapper for the mighty Pandoc document converter
10              
11             =cut
12              
13             our $VERSION = '0.9.2';
14              
15 10     10   5781 use Pandoc::Version;
  10         33  
  10         404  
16 10     10   68 use Pandoc::Error;
  10         18  
  10         2242  
17 10     10   5356 use File::Which;
  10         14553  
  10         845  
18 10     10   4163 use File::Spec::Functions 'catdir';
  10         8086  
  10         832  
19 10     10   6251 use IPC::Run3;
  10         438253  
  10         976  
20 10     10   115 use parent 'Exporter';
  10         118  
  10         93  
21             our @EXPORT = qw(pandoc pandoc_data_dir);
22              
23             our $PANDOC;
24             our $PANDOC_PATH ||= $ENV{PANDOC_PATH} || 'pandoc';
25              
26             sub import {
27 9     9   127 shift;
28              
29 9 50 33     58 if ( @_ and $_[0] =~ /^[v0-9.<>=!, ]+$/ ) {
30 0   0     0 $PANDOC //= Pandoc->new;
31 0         0 $PANDOC->require(shift);
32             }
33 9 50 0     34 $PANDOC //= Pandoc->new(@_) if @_;
34              
35 9         724384 Pandoc->export_to_level( 1, 'pandoc' );
36             }
37              
38             sub VERSION {
39 0     0 0 0 shift;
40 0   0     0 $PANDOC //= Pandoc->new;
41 0 0       0 $PANDOC->require(shift) if @_;
42 0         0 $PANDOC->version;
43             }
44              
45             sub new {
46 8     8 1 30 my $pandoc = bless {}, shift;
47              
48 8 50 33     67 my $bin = ( @_ and $_[0] !~ /^-./ ) ? shift : $PANDOC_PATH;
49              
50 8         72 my $bin_from_version = pandoc_data_dir( "bin", "pandoc-$bin" );
51 8 50 33     312 if ( !-x $bin && $bin =~ /^\d+(\.\d+)*$/ && -x $bin_from_version ) {
      33        
52 0         0 $pandoc->{bin} = $bin_from_version;
53             }
54             else {
55 8         63 $pandoc->{bin} = which($bin);
56             }
57              
58 8         2241 $pandoc->{arguments} = [];
59 8 50       45 $pandoc->arguments(@_) if @_;
60              
61 8         25 my ( $in, $out, $err );
62              
63 8 50       83 if ( $pandoc->{bin} ) {
64 0         0 run3 [ $pandoc->{bin}, '-v' ], \$in, \$out, \$err,
65             { return_if_system_error => 1 };
66             }
67 8 50 33     132 unless ( $out and $out =~ /^[^ ]+ (\d+(\.\d+)+)/ ) {
68 8         107 Pandoc::Error->throw(
69             message => "pandoc executable not found",
70             out => $out,
71             err => $err,
72             );
73             }
74              
75 0         0 $pandoc->{version} = Pandoc::Version->new($1);
76 0 0       0 $pandoc->{data_dir} = $1 if $out =~ /^Default user data directory: (.+)$/m;
77              
78             # before pandoc supported --list-highlight-languages
79 0 0       0 if ( $out =~ /^Syntax highlighting is supported/m ) {
80             $pandoc->{highlight_languages} =
81 0         0 [ map { split /\s*,\s*/, $_ } ( $out =~ /^ (.+)$/mg ) ];
  0         0  
82             }
83              
84 0         0 my %libs;
85 0         0 my $LIBRARY_VERSION = qr/\s+(\pL\w*(?:-\pL\w*)*)\s+(\d+(?:\.\d+)*),?/;
86 0 0       0 if ( $out =~ /^Compiled with($LIBRARY_VERSION+)/m ) {
87 0         0 %libs = $1 =~ /$LIBRARY_VERSION/g;
88 0         0 for my $name ( keys %libs ) {
89 0         0 $libs{$name} = Pandoc::Version->new( $libs{$name} );
90             }
91             }
92 0         0 $pandoc->{libs} = \%libs;
93              
94 0         0 return $pandoc;
95             }
96              
97             sub pandoc(@) { ## no critic
98 8   50 8 1 1343985 $PANDOC //= eval { Pandoc->new } // 0;
  8   33     80  
99              
100 8 50       33 if (@_) {
101 0 0       0 return $PANDOC ? $PANDOC->run(@_) : -1;
102             }
103             else {
104 8         27 return $PANDOC;
105             }
106             }
107              
108             sub run {
109 0     0 1 0 my $pandoc = shift;
110              
111 0 0       0 my $args = 'ARRAY' eq ref $_[0] ? \@{ shift @_ } : undef; # \@args [ ... ]
  0         0  
112 0 0       0 my $opts = 'HASH' eq ref $_[-1] ? \%{ pop @_ } : undef; # [ ... ] \%opts
  0         0  
113              
114 0 0       0 if (@_) {
115 0 0 0     0 if ( !$args ) { # @args
    0 0        
116 0 0 0     0 if ( $_[0] =~ /^-/ or $opts or @_ % 2 ) {
      0        
117 0         0 $args = \@_;
118             }
119             else { # %opts
120 0         0 $opts = {@_};
121             }
122             }
123             elsif ( $args and !$opts and ( @_ % 2 == 0 ) ) { # \@args [, %opts ]
124 0         0 $opts = {@_};
125             }
126             else {
127             # passed both the args and opts by ref,
128             # so other arguments don't make sense;
129             # or passed args by ref and an odd-length list
130 0         0 Pandoc::Error->throw('Too many or ambiguous arguments');
131             }
132             }
133              
134 0   0     0 $args //= [];
135 0   0     0 $opts //= {};
136              
137 0         0 for my $io (qw(in out err)) {
138 0 0 0     0 $opts->{"binmode_std$io"} //= $opts->{binmode} if $opts->{binmode};
139 0 0       0 if ( 'SCALAR' eq ref $opts->{$io} ) {
140 0 0       0 next unless utf8::is_utf8( ${ $opts->{$io} } );
  0         0  
141 0   0     0 $opts->{"binmode_std$io"} //= ':encoding(UTF-8)';
142             }
143             }
144              
145 0   0     0 my $throw = $opts->{throw} || !( $opts->{return_if_system_error} // 1 );
146 0   0     0 $opts->{out} //= \( my $out );
147 0   0     0 $opts->{err} //= \( my $err );
148              
149 0         0 $opts->{return_if_system_error} = 1;
150 0         0 run3 [ $pandoc->{bin}, @{ $pandoc->{arguments} }, @$args ],
151 0         0 $opts->{in}, $opts->{out}, $opts->{err}, $opts;
152              
153 0 0       0 my $status = $? == -1 ? -1 : $? >> 8;
154              
155 0 0 0     0 if ( $status && $throw ) {
156             Pandoc::Error->throw(
157             system => $!,
158 0         0 out => ${ $opts->{out} },
159 0         0 err => ${ $opts->{err} },
160             status => $status,
161 0   0     0 message => ${ $opts->{err} } || 'pandoc execution failed'
162             );
163             }
164             else {
165 0         0 $status;
166             }
167             }
168              
169             sub convert {
170 0     0 1 0 my $pandoc = shift;
171 0         0 my $from = shift;
172 0         0 my $to = shift;
173 0         0 my $in = shift;
174 0         0 my $out = "";
175              
176 0         0 my $utf8 = utf8::is_utf8($in);
177              
178 0         0 $pandoc->run(
179             [ @_, '-f' => $from, '-t' => $to, '-o' => '-' ],
180             { in => \$in, out => \$out, throw => 1 }
181             );
182              
183 0 0       0 utf8::decode($out) if $utf8;
184              
185 0         0 chomp $out;
186 0         0 return $out;
187             }
188              
189             sub parse {
190 0     0 1 0 my $pandoc = shift;
191 0         0 my $format = shift;
192 0         0 my $json = "";
193              
194 0 0       0 if ( $format eq 'json' ) {
195 0         0 $json = shift;
196             }
197             else {
198 0         0 $pandoc->require('1.12.1');
199 0         0 $json = $pandoc->convert( $format => 'json', @_ );
200             }
201              
202 0         0 require Pandoc::Elements;
203 0         0 Pandoc::Elements::pandoc_json($json);
204             }
205              
206             sub file {
207 0     0 1 0 my $pandoc = shift;
208 0         0 $pandoc->require('1.12.1');
209              
210 0         0 my @args = ( @_, '-t' => 'json', '-o' => '-' );
211 0         0 $pandoc->run( \@args, out => \( my $json ), throw => 1 );
212              
213 0         0 require Pandoc::Elements;
214 0         0 Pandoc::Elements::pandoc_json($json);
215             }
216              
217             sub require {
218 0     0 1 0 my $pandoc = shift;
219 0 0 0     0 $pandoc = do { $PANDOC //= Pandoc->new } if $pandoc eq 'Pandoc';
  0         0  
220 0 0       0 unless ( $pandoc->version(@_) ) {
221             Pandoc::Error->throw(
222             message => "pandoc $_[0] required, only found "
223             . $pandoc->{version},
224             version => $pandoc->{version},
225 0         0 require => $_[0],
226             );
227             }
228 0         0 return $pandoc;
229             }
230              
231             sub version {
232 0 0   0 1 0 my $pandoc = shift or return;
233 0 0       0 my $version = $pandoc->{version} or return;
234              
235             # compare against given version
236 0 0 0     0 return if @_ and not $version->fulfills(@_);
237              
238 0         0 return $version;
239             }
240              
241             sub data_dir {
242 0     0 1 0 catdir( shift->{data_dir}, @_ );
243             }
244              
245             sub pandoc_data_dir {
246 9 50   9 1 119266 if ( $^O eq 'MSWin32' ) {
247 0         0 catdir( $ENV{APPDATA}, 'pandoc', @_ );
248             }
249             else {
250 9         119 catdir( $ENV{HOME}, '.pandoc', @_ );
251             }
252             }
253              
254             sub bin {
255 0     0 1   my $pandoc = shift;
256 0 0         if (@_) {
257 0           my $new = Pandoc->new(shift);
258 0           $pandoc->{$_} = $new->{$_} for (qw(version bin data_dir));
259             }
260 0           $pandoc->{bin};
261             }
262              
263             sub arguments {
264 0     0 1   my $pandoc = shift;
265 0 0         if (@_) {
266 0 0         my $args = 'ARRAY' eq ref $_[0] ? shift : \@_;
267 0 0 0       Pandoc::Error->throw("first default argument must be an -option")
268             if @$args and $args->[0] !~ /^-./;
269 0           $pandoc->{arguments} = $args;
270             }
271 0           @{ $pandoc->{arguments} };
  0            
272             }
273              
274             sub _list {
275 0     0     my ( $pandoc, $which ) = @_;
276 0 0         if ( !$pandoc->{$which} ) {
277 0 0         if ( $pandoc->version('1.18') ) {
    0          
278 0           my $list = "";
279 0           my $command = $which;
280 0           $command =~ s/_/-/g;
281 0           $pandoc->run( "--list-$command", { out => \$list } );
282 0           $pandoc->{$which} = [ split /\n/, $list ];
283             }
284             elsif ( !defined $pandoc->{help} ) {
285 0           my $help;
286 0           $pandoc->run( '--help', { out => \$help } );
287 0           for my $inout (qw(Input Output)) {
288 0 0         $help =~ /^$inout formats:\s+([a-z_0-9,\+\s*]+)/m or next;
289 0           $pandoc->{ lc($inout) . '_formats' } =
290             [ split /\*?,\s+|\*?\s+/, $1 ];
291             }
292 0           $pandoc->{help} = $help;
293             }
294             }
295 0   0       @{ $pandoc->{$which} // [] };
  0            
296             }
297              
298             sub input_formats {
299 0     0 1   $_[0]->_list('input_formats');
300             }
301              
302             sub output_formats {
303 0     0 1   $_[0]->_list('output_formats');
304             }
305              
306             sub highlight_languages {
307 0     0 1   $_[0]->_list('highlight_languages');
308             }
309              
310             sub extensions {
311 0     0 1   my $pandoc = shift;
312 0   0       my $format = shift // '';
313 0           my $out = "";
314 0           my %ext;
315              
316 0 0         if ( $pandoc->version < 1.18 ) {
317 0           warn "pandoc >= 1.18 required for --list-extensions\n";
318             }
319             else {
320 0 0         if ($format) {
321 0 0 0       if ( $format =~ /^[a-z0-9_]$/ and $pandoc->version >= '2.0.6' ) {
322 0           $format = "=$format";
323             }
324             else {
325 0           warn "ignoring format argument to Pandoc->extensions\n";
326 0           $format = '';
327             }
328             }
329 0           $pandoc->run( "--list-extensions$format", { out => \$out } );
330             %ext = map {
331 0           $_ =~ /^([+-]?)\s*([^-+ ]+)\s*([+-]?)$/;
  0            
332 0 0 0       ( $2 => ( $1 || $3 ) eq '+' ? 1 : 0 );
333             } split /\n/, $out;
334             }
335              
336 0           %ext;
337             }
338              
339             sub libs {
340 0     0 1   $_[0]->{libs};
341             }
342              
343             sub symlink {
344 0     0 1   my $self = shift;
345 0 0         my ( $name, %opts ) = @_ % 2 ? @_ : ( '', @_ );
346              
347 0 0 0       if ( '' eq $name // '' ) {
    0          
348 0           $name = pandoc_data_dir( 'bin', 'pandoc' );
349             }
350             elsif ( -d $name ) {
351 0           $name = "$name/pandoc";
352             }
353              
354 0           my $bin = $self->bin;
355              
356 0 0         unlink $name if -l $name;
357 0 0         if ( symlink $bin, $name ) {
358 0 0         say "symlinked $name -> $bin" if $opts{verbose};
359 0           $self->bin($name);
360             }
361             else {
362 0           die "failed to create symlink $name -> $bin\n";
363             }
364              
365 0           $self;
366             }
367              
368             1;
369              
370             __END__
371              
372             =encoding utf-8
373              
374             =begin markdown
375              
376             # STATUS
377              
378             [![Linux Build Status](https://travis-ci.org/nichtich/Pandoc-Wrapper.svg)](https://travis-ci.org/nichtich/Pandoc-Wrapper)
379             [![Windows Build Status](https://ci.appveyor.com/api/projects/status/8p68qdqv72to633d?svg=true)](https://ci.appveyor.com/project/nichtich/pandoc-wrapper)
380             [![Coverage Status](https://coveralls.io/repos/nichtich/Pandoc-Wrapper/badge.svg)](https://coveralls.io/r/nichtich/Pandoc-Wrapper)
381             [![Kwalitee Score](http://cpants.cpanauthors.org/dist/Pandoc.png)](http://cpants.cpanauthors.org/dist/Pandoc)
382              
383             =end markdown
384              
385             =head1 SYNOPSIS
386              
387             use Pandoc; # check at first use
388             use Pandoc 1.12; # check at compile time
389             Pandoc->require(1.12); # check at run time
390              
391             # execute pandoc
392             pandoc 'input.md', -o => 'output.html';
393             pandoc -f => 'html', -t => 'markdown', { in => \$html, out => \$md };
394              
395             # alternative syntaxes
396             pandoc->run('input.md', -o => 'output.html');
397             pandoc [ -f => 'html', -t => 'markdown' ], in => \$html, out => \$md;
398             pandoc [ -f => 'html', -t => 'markdown' ], { in => \$html, out => \$md };
399              
400             # check executable
401             pandoc or die "pandoc executable not found";
402              
403             # check minimum version
404             pandoc->version > 1.12 or die "pandoc >= 1.12 required";
405              
406             # access properties
407             say pandoc->bin." ".pandoc->version;
408             say "Default user data directory: ".pandoc->data_dir;
409             say "Compiled with: ".join(", ", keys %{ pandoc->libs });
410             say pandoc->libs->{'highlighting-kate'};
411              
412             # create a new instance with default arguments
413             my $md2latex = Pandoc->new(qw(-f markdown -t latex --number-sections));
414             $md2latex->run({ in => \$markdown, out => \$latex });
415              
416             # create a new instance with selected executable
417             my $pandoc = Pandoc->new('bin/pandoc');
418             my $pandoc = Pandoc->new('2.1'); # use ~/.pandoc/bin/pandoc-2.1 if available
419              
420             # set default arguments on compile time
421             use Pandoc qw(-t latex);
422             use Pandoc qw(/usr/bin/pandoc --number-sections);
423             use Pandoc qw(1.16 --number-sections);
424              
425             # utility method to convert from string
426             $latex = pandoc->convert( 'markdown' => 'latex', '*hello*' );
427              
428             # utility methods to parse abstract syntax tree (requires Pandoc::Elements)
429             $doc = pandoc->parse( markdown => '*hello* **world!**' );
430             $doc = pandoc->file( 'example.md' );
431             $doc = pandoc->file; # read Markdown from STDIN
432              
433             =head1 DESCRIPTION
434              
435             This module provides a Perl wrapper for John MacFarlane's
436             L<Pandoc|http://pandoc.org> document converter.
437              
438             =head1 INSTALLATION
439              
440             This module requires the Perl programming language (>= version 5.14) as
441             included in most Unix operating systems by default. The recommended method to
442             install Perl modules is C<cpanm> (see its L<install
443             instructions|https://metacpan.org/pod/App::cpanminus#INSTALLATION> if needed):
444              
445             cpanm Pandoc
446              
447             Installing instruction for Pandoc itself are given L<at Pandoc
448             homepage|http://pandoc.org/installing.html>. On Debian-based systems this
449             module and script L<pandoc-version> can be used to install and update the
450             pandoc executable with L<Pandoc::Release>:
451              
452             pandoc-version install
453              
454             Then add C<~/.pandoc/bin> to your C<PATH> or copy C<~/.pandoc/bin/pandoc> to
455             a location where it can be executed.
456              
457             =head1 USAGE
458              
459             The utility function L<pandoc|/pandoc> is exported, unless the module is
460             imported with an empty list (C<use Pandoc ();>). Importing this module with a
461             version number or a more complex version requirenment (e.g. C<use Pandoc
462             1.13;> or C<< use Pandoc '>= 1.6, !=1.7 >>) will check version number of
463             pandoc executable instead of version number of this module (see
464             C<$Pandoc::VERSION> for the latter). Additional import arguments can be passed
465             to set the executable location and default arguments of the global Pandoc
466             instance used by function pandoc.
467              
468             =head1 FUNCTIONS
469              
470             =head2 pandoc
471              
472             If called without parameters, this function returns a global instance of class
473             Pandoc to execute L<methods|/METHODS>, or C<undef> if no pandoc executable was
474             found. The location and/or name of pandoc executable can be set with
475             environment variable C<PANDOC_PATH> (set to the string C<pandoc> by default).
476              
477             =head2 pandoc( ... )
478              
479             If called with parameters, this functions runs the pandoc executable configured
480             at the global instance of class Pandoc (C<< pandoc->bin >>). Arguments (given
481             as array or array reference) are passed as pandoc command line arguments.
482             Additional options (given as hash or has reference) can control input, output,
483             and error stream:
484              
485             pandoc @arguments, \%options; # ok
486             pandoc \@arguments, %options; # ok
487             pandoc \@arguments, \%options; # ok
488             pandoc @arguments; # ok, if first of @arguments starts with '-'
489             pandoc %options; # ok, if %options is not empty
490              
491             pandoc @arguments, %options; # not ok!
492              
493             Returns C<0> on success. On error returns the exit code of pandoc executable or
494             C<-1> if execution failed. If option C<throw> is set, a L<Pandoc::Error> is
495             thrown instead. The following options are recognized:
496              
497             =over
498              
499             =item in / out / err
500              
501             These options correspond to arguments C<$stdin>, C<$stdout>, and
502             C<$stderr> of L<IPC::Run3>, see there for details.
503              
504             =item binmode_stdin / binmode_stdout / binmode_stderr
505              
506             These options correspond to the like-named options to L<IPC::Run3>, see
507             there for details.
508              
509             =item binmode
510              
511             If defined any binmode_stdin/binmode_stdout/binmode_stderr option which
512             is undefined will be set to this value.
513              
514             =item throw
515              
516             Throw a L<Pandoc::Error> instead returning the exit code on error. Disabled by
517             default.
518              
519             =item return_if_system_error
520              
521             Set to negation of option C<throw> by default.
522              
523             =back
524              
525             For convenience the C<pandoc> function (I<after> checking the C<binmode>
526             option) checks the contents of any scalar references passed to the
527             in/out/err options with
528             L<< utf8::is_utf8()|utf8/"* C<$flag = utf8::is_utf8($string)>" >>
529             and sets the binmode_stdin/binmode_stdout/binmode_stderr options to
530             C<:encoding(UTF-8)> if the corresponding scalar is marked as UTF-8 and
531             the respective option is undefined. Since all pandoc executable
532             input/output must be UTF-8 encoded this is convenient if you run with
533             L<use utf8|utf8>, as you then don't need to set the binmode options at
534             all (L<encode nor decode|Encode>) when passing input/output scalar
535             references.
536              
537             =head2 pandoc_data_dir( [ @subdirs ] [ $file ] )
538              
539             Returns the default pandoc data directory which is directory C<.pandoc> in the
540             home directory for Unix or C<pandoc> directory in C<%APPDATA%> for Windows.
541             Optional arguments can be given to refer to a specific subdirectory or file.
542              
543             =head1 METHODS
544              
545             =head2 new( [ $executable | $version ] [, @arguments ] )
546              
547             Create a new instance of class Pandoc or throw an exception if no pandoc
548             executable was found. The first argument, if given and not starting with C<->,
549             can be used to set the pandoc executable (C<pandoc> by default). If a version
550             is specified the executable is also searched in C<~/.pandoc/bin>, e.g.
551             C<~/.pandoc/bin/pandoc-2.0> for version C<2.0>. Additional arguments are
552             passed to the executable on each run.
553              
554             Repeated use of this constructor with same arguments is not recommended because
555             C<pandoc --version> is called for every new instance.
556              
557             =head2 run( ... )
558              
559             Execute the pandoc executable with default arguments and optional additional
560             arguments and options. See L<function pandoc|/pandoc> for usage.
561              
562             =head2 convert( $from => $to, $input [, @arguments ] )
563              
564             Convert a string in format C<$from> to format C<$to>. Additional pandoc options
565             such as C<-N> and C<--standalone> can be passed. The result is returned
566             in same utf8 mode (C<utf8::is_unicode>) as the input. To convert from file to
567             string use method C<pandoc>/C<run> like this and set input/output format via
568             standard pandoc arguments C<-f> and C<-t>:
569              
570             pandoc->run( $filename, @arguments, { out => \$string } );
571              
572             =head2 parse( $from => $input [, @arguments ] )
573              
574             Parse a string in format C<$from> to a L<Pandoc::Document> object. Additional
575             pandoc options such as C<-N> and C<--normalize> can be passed. This method
576             requires at least pandoc version 1.12.1 and the Perl module L<Pandoc::Elements>.
577              
578             The reverse action is possible with method C<to_pandoc> of L<Pandoc::Document>.
579             Additional shortcut methods such as C<to_html> are available:
580              
581             $html = pandoc->parse( 'markdown' => '# A *section*' )->to_html;
582              
583             Method C<convert> should be preferred for simple conversions unless you want to
584             modify or inspect the parsed document in between.
585              
586             =head2 file( [ $filename [, @arguments ] ] )
587              
588             Parse from a file (or STDIN) to a L<Pandoc::Document> object. Additional pandoc
589             options can be passed, for instance use HTML input format (C<@arguments = qw(-f
590             html)>) instead of default markdown. This method requires at least pandoc
591             version 1.12.1 and the Perl module L<Pandoc::Elements>.
592              
593             =head2 require( $version_requirement )
594              
595             Return the Pandoc instance if its version number fulfills a given version
596             requirement. Throw an error otherwise. Can also be called as constructor:
597             C<< Pandoc->require(...) >> is equivalent to C<< pandoc->require >> but
598             throws a more meaningful error message if no pandoc executable was found.
599              
600             =head2 version( [ $version_requirement ] )
601              
602             Return the pandoc version as L<Pandoc::Version> object. If a version
603             requirement is given, the method returns undef if the pandoc version does not
604             fulfill this requirement. To check whether pandoc is available with a given
605             minimal version use one of:
606              
607             Pandoc->require( $minimum_version) # true or die
608             pandoc and pandoc->version( $minimum_version ) # true or false
609              
610             =head2 bin( [ $executable ] )
611              
612             Return or set the pandoc executable. Setting an new executable also updates
613             version and data_dir by calling C<pandoc --version>.
614              
615             =head2 symlink( [ $name ] [ verbose => 0|1 ] )
616              
617             Create a symlink with given name to the executable and change executable to the
618             symlink location afterwards. An existing symlink is replaced. If C<$name> is an
619             existing directory, the symlink will be named C<pandoc> in there. This makes
620             most sense if the directory is listed in environment variable C<$PATH>. If the
621             name is omitted or an empty string, symlink is created in subdirectory C<bin>
622             of pandoc data directory.
623              
624             =head2 arguments( [ @arguments | \@arguments )
625              
626             Return or set a list of default arguments.
627              
628             =head2 data_dir( [ @subdirs ] [ $file ] )
629              
630             Return the stated default data directory, introduced with Pandoc 1.11. Use
631             function C<pandoc_data_dir> alternatively to get the expected directory without
632             calling Pandoc executable.
633              
634             =head2 input_formats
635              
636             Return a list of supported input formats.
637              
638             =head2 output_formats
639              
640             Return a list of supported output formats.
641              
642             =head2 highlight_languages
643              
644             Return a list of programming languages which syntax highlighting is supported
645             for (via Haskell library highlighting-kate).
646              
647             =head2 extensions( [ $format ] )
648              
649             Return a hash of extensions mapped to whether they are enabled by default.
650             This method is only available since Pandoc 1.18 and the optional format
651             argument since Pandoc 2.0.6.
652              
653             =head2 libs
654              
655             Return a hash mapping the names of Haskell libraries compiled into the
656             pandoc executable to L<Pandoc::Version> objects.
657              
658             =head1 SEE ALSO
659              
660             This package includes L<Pandoc::Version> to compare Pandoc version numbers,
661             L<Pandoc::Release> to get Pandoc releases from GitHub, and
662             L<App::Prove::Plugin::andoc> to run tests with selected Pandoc executables.
663              
664             See L<Pandoc::Elements> for a Perl interface to the abstract syntax tree of
665             Pandoc documents for more elaborate document processing.
666              
667             See L<Pod::Pandoc> to parse Plain Old Documentation format (L<perlpod>) for
668             processing with Pandoc.
669              
670             See L<Pandoc wrappers and interfaces|https://github.com/jgm/pandoc/wiki/Pandoc-wrappers-and-interfaces>
671             in the Pandoc GitHub Wiki for a list of wrappers in other programming
672             languages.
673              
674             Other Pandoc related but outdated modules at CPAN include
675             L<Orze::Sources::Pandoc> and L<App::PDoc>.
676              
677             =head1 AUTHOR
678              
679             Jakob Voß
680              
681             =head1 CONTRIBUTORS
682              
683             Benct Philip Jonsson
684              
685             =head1 LICENSE
686              
687             European Union Public Licence v. 1.2 (EUPL-1.2)
688              
689             =cut