Build.PL100664001750001750 45514151700212 13040 0ustar00vojvoj000000000000Pandoc-0.9.1# ========================================================================= # THIS FILE IS AUTOMATICALLY GENERATED BY MINILLA. # DO NOT EDIT DIRECTLY. # ========================================================================= use 5.008_001; use strict; use Module::Build::Tiny 0.035; Build_PL(); Changes100664001750001750 571414151700212 13062 0ustar00vojvoj000000000000Pandoc-0.9.1Revision history for Pandoc Perl module 0.9.1 2021-12-01T14:02:41Z - Fix failing test for Pandoc >= 2.8 - pica-version: support installing selected version 0.9.0 2019-02-07 17:21:55 CET - Add command line script pandoc-version 0.8.8 2018-08-24 10:42:00 CEST - Update dependencies, require Perl 5.14 0.8.7 2018-08-22 09:46:00 CEST - Optionally authentificate GitHub API request with token 0.8.6 2018-07-04 09:39:52 CEST - Change license to EUPL 1.2 0.8.5 2018-06-20 23:11:29 CEST - Add method to symlink executable 0.8.4 2018-05-22 13:28:30 CEST - Introduce Pandoc::Error - Export Pandoc::Release methods as functions - Add Pandoc::Release::latest - Simplify download of new releases 0.8.3 2018-05-12 09:19:48 CEST - Fix pandoc_data_dir for Windows 0.8.2 2018-05-06 15:37:34 CEST - Add function pandoc_data_dir and extend method data_dir 0.8.0 2018-04-06 12:28:03 CEST - Search executable in ~/.pandoc/bin - Download executables with 'pandoc-' prefix - Automatically detect Debian architecture for download releases - Add method Pandoc::Relases->get - Add method Pandoc->extensions 0.7.2 2018-04-03 12:09:40 CEST - Fix test failure since Perl 5.26 0.7.1 2018-04-03 11:09:14 CEST - Add App::Prove::Plugin::andoc - Make sure tests pass on all pandoc versions (#25) 0.7.0 2018-03-26 22:31:51 CEST - Add Pandoc::Release - fix bug when calling with uneven number of arguments (#22) 0.6.1 2017-10-17 20:43:51 CEST - make sure to override existing options and output destination (#16) 0.6.0 2017-01-27 10:51:10 CET - support more expressive version requirements 0.5.0 2016-11-24 14:14:34 CET - add method Pandoc::Version::match 0.4.3 2016-11-09 21:11:53 CET - fix bug with executable not named 'pandoc' 0.4.2 2016-11-09 19:39:45 CET - fix test for pandoc 1.9 0.4.1 2016-11-03 21:14:26 CET - add method highlight_languages - support calling run( $filename, ... ) - strip '*' from input/output format names 0.4.0 2016-11-01 20:44:15 CET - add Pandoc::Version module for version numbers - allow setting executable via PANDOC_PATH environment variable - add method file to parse from file - add method libs to access libraries used by pandoc - prepare to adjust Pandoc::Elements for pandoc 1.18 0.3.1 2016-10-26 20:37:24 CEST - add parse method - fix version number comparison - extend documentation 0.3.0 2016-10-21 20:10:30 CEST - support setting default arguments on import - make bin and arguments setters - use File::Which to find executable 0.2.2 2016-10-20 11:20:36 CEST - support default arguments 0.2.1 2016-10-20 10:34:31 CEST - add method input_format and output_format - let version return a version object 0.2.0 2016-10-18 21:58:19 CEST - add alternative calling conventions for pandoc/run - add utility method convert 0.1.0 2016-10-10 10:37:02 CEST - create initial release LICENSE100664001750001750 3315614151700212 12615 0ustar00vojvoj000000000000Pandoc-0.9.1This software is Copyright (c) 2019 by Jakob Voß. This is free software, licensed under: The European Union Public License (EUPL) v1.2 EUROPEAN UNION PUBLIC LICENCE v. 1.2 EUPL © the European Union 2007, 2016 This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such use is covered by a right of the copyright holder of the Work). The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following notice immediately following the copyright notice for the Work: Licensed under the EUPL or has expressed by any other means his willingness to license under the EUPL. 1.Definitions In this Licence, the following terms have the following meaning: — ‘The Licence’:this Licence. — ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available as Source Code and also as Executable Code as the case may be. — ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in the country mentioned in Article 15. — ‘The Work’:the Original Work or its Derivative Works. — ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and modify. — ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by a computer as a program. — ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence. — ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to the creation of a Derivative Work. — ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the Licence. — ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating, transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential functionalities at the disposal of any other natural or legal person. 2.Scope of the rights granted by the Licence The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for the duration of copyright vested in the Original Work: — use the Work in any circumstance and for all usage, — reproduce the Work, — modify the Work, and make Derivative Works based upon the Work, — communicate to the public, including the right to make available or display the Work or copies thereof to the public and perform publicly, as the case may be, the Work, — distribute the Work or copies thereof, — lend and rent the Work or copies thereof, — sublicense rights in the Work or copies thereof. Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the applicable law permits so. In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed by law in order to make effective the licence of the economic rights here above listed. The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the extent necessary to make use of the rights granted on the Work under this Licence. 3.Communication of the Source Code The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to distribute or communicate the Work. 4.Limitations on copyright Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations thereto. 5.Obligations of the Licensee The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those obligations are the following: Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work to carry prominent notices stating that the Work has been modified and the date of modification. Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless the Original Work is expressly distributed only under this version of the Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the Work or Derivative Work that alter or restrict the terms of the Licence. Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail. Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available for as long as the Licensee continues to distribute or communicate the Work. Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the copyright notice. 6.Chain of Authorship The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence. Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence. Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions to the Work, under the terms of this Licence. 7.Disclaimer of Warranty The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work and may therefore contain defects or ‘bugs’ inherent to this type of development. For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this Licence. This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work. 8.Disclaimer of Liability Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, the Licensor will be liable under statutory product liability laws as far such laws apply to the Work. 9.Additional agreements While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by the fact You have accepted any warranty or additional liability. 10.Acceptance of the Licence The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms and conditions. Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution or Communication by You of the Work or copies thereof. 11.Information to the public In case of any Distribution or Communication of the Work by means of electronic communication by You (for example, by offering to download the Work from a remote location) the distribution channel or media (for example, a website) must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence and the way it may be accessible, concluded, stored and reproduced by the Licensee. 12.Termination of the Licence The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms of the Licence. Such a termination will not terminate the licences of any person who has received the Work from the Licensee under the Licence, provided such persons remain in full compliance with the Licence. 13.Miscellaneous Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the Work. If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid and enforceable. The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. New versions of the Licence will be published with a unique version number. All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take advantage of the linguistic version of their choice. 14.Jurisdiction Without prejudice to specific agreement between parties, — any litigation resulting from the interpretation of this License, arising between the European Union institutions, bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union, — any litigation arising between other parties and resulting from the interpretation of this License, will be subject to the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business. 15.Applicable Law Without prejudice to specific agreement between parties, — this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat, resides or has his registered office, — this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside a European Union Member State. Appendix ‘Compatible Licences’ according to Article 5 EUPL are: — GNU General Public License (GPL) v. 2, v. 3 — GNU Affero General Public License (AGPL) v. 3 — Open Software License (OSL) v. 2.1, v. 3.0 — Eclipse Public License (EPL) v. 1.0 — CeCILL v. 2.0, v. 2.1 — Mozilla Public Licence (MPL) v. 2 — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software — European Union Public Licence (EUPL) v. 1.1, v. 1.2 — Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+). The European Commission may update this Appendix to later versions of the above licences without producing a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the covered Source Code from exclusive appropriation. All other changes or additions to this Appendix require the production of a new EUPL version. META.json100664001750001750 511214151700212 13200 0ustar00vojvoj000000000000Pandoc-0.9.1{ "abstract" : "wrapper for the mighty Pandoc document converter", "author" : [ "Jakob Voß" ], "dynamic_config" : 0, "generated_by" : "Minilla/v3.1.11", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Pandoc", "no_index" : { "directory" : [ "t", "xt", "inc", "share", "eg", "examples", "author", "builder" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build::Tiny" : "0.035" } }, "develop" : { "requires" : { "Test::CPAN::Meta" : "0", "Test::MinimumVersion::Fast" : "0.04", "Test::PAUSE::Permissions" : "0.07", "Test::Pod" : "1.41", "Test::Spellunker" : "v0.2.7" } }, "runtime" : { "requires" : { "File::Which" : "1.11", "HTTP::Tiny" : "0", "IPC::Run3" : "0", "JSON::PP" : "0", "perl" : "5.014" } }, "test" : { "requires" : { "Test::Exception" : "0", "Test::More" : "0.96" } } }, "provides" : { "App::Prove::Plugin::andoc" : { "file" : "lib/App/Prove/Plugin/andoc.pm", "version" : "v0.9.1" }, "Pandoc" : { "file" : "lib/Pandoc.pm", "version" : "v0.9.1" }, "Pandoc::Error" : { "file" : "lib/Pandoc/Error.pm", "version" : "v0.9.1" }, "Pandoc::Release" : { "file" : "lib/Pandoc/Release.pm", "version" : "v0.9.1" }, "Pandoc::Version" : { "file" : "lib/Pandoc/Version.pm", "version" : "v0.9.1" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/nichtich/Pandoc-Wrapper/issues" }, "homepage" : "https://github.com/nichtich/Pandoc-Wrapper", "repository" : { "url" : "git://github.com/nichtich/Pandoc-Wrapper.git", "web" : "https://github.com/nichtich/Pandoc-Wrapper" } }, "version" : "0.9.1", "x_contributors" : [ "Benct Philip Jonsson ", "Edward Betts ", "Jakob Voß ", "Mohammad S Anwar ", "Theo van Hoesel " ], "x_serialization_backend" : "JSON::PP version 4.04", "x_static_install" : 1 } README.md100664001750001750 3115714151700212 13066 0ustar00vojvoj000000000000Pandoc-0.9.1# NAME Pandoc - wrapper for the mighty Pandoc document converter # STATUS [![Linux Build Status](https://travis-ci.org/nichtich/Pandoc-Wrapper.svg)](https://travis-ci.org/nichtich/Pandoc-Wrapper) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/8p68qdqv72to633d?svg=true)](https://ci.appveyor.com/project/nichtich/pandoc-wrapper) [![Coverage Status](https://coveralls.io/repos/nichtich/Pandoc-Wrapper/badge.svg)](https://coveralls.io/r/nichtich/Pandoc-Wrapper) [![Kwalitee Score](http://cpants.cpanauthors.org/dist/Pandoc.png)](http://cpants.cpanauthors.org/dist/Pandoc) # SYNOPSIS use Pandoc; # check at first use use Pandoc 1.12; # check at compile time Pandoc->require(1.12); # check at run time # execute pandoc pandoc 'input.md', -o => 'output.html'; pandoc -f => 'html', -t => 'markdown', { in => \$html, out => \$md }; # alternative syntaxes pandoc->run('input.md', -o => 'output.html'); pandoc [ -f => 'html', -t => 'markdown' ], in => \$html, out => \$md; pandoc [ -f => 'html', -t => 'markdown' ], { in => \$html, out => \$md }; # check executable pandoc or die "pandoc executable not found"; # check minimum version pandoc->version > 1.12 or die "pandoc >= 1.12 required"; # access properties say pandoc->bin." ".pandoc->version; say "Default user data directory: ".pandoc->data_dir; say "Compiled with: ".join(", ", keys %{ pandoc->libs }); say pandoc->libs->{'highlighting-kate'}; # create a new instance with default arguments my $md2latex = Pandoc->new(qw(-f markdown -t latex --number-sections)); $md2latex->run({ in => \$markdown, out => \$latex }); # create a new instance with selected executable my $pandoc = Pandoc->new('bin/pandoc'); my $pandoc = Pandoc->new('2.1'); # use ~/.pandoc/bin/pandoc-2.1 if available # set default arguments on compile time use Pandoc qw(-t latex); use Pandoc qw(/usr/bin/pandoc --number-sections); use Pandoc qw(1.16 --number-sections); # utility method to convert from string $latex = pandoc->convert( 'markdown' => 'latex', '*hello*' ); # utility methods to parse abstract syntax tree (requires Pandoc::Elements) $doc = pandoc->parse( markdown => '*hello* **world!**' ); $doc = pandoc->file( 'example.md' ); $doc = pandoc->file; # read Markdown from STDIN # DESCRIPTION This module provides a Perl wrapper for John MacFarlane's [Pandoc](http://pandoc.org) document converter. # INSTALLATION This module requires the Perl programming language (>= version 5.14) as included in most Unix operating systems by default. The recommended method to install Perl modules is `cpanm` (see its [install instructions](https://metacpan.org/pod/App::cpanminus#INSTALLATION) if needed): cpanm Pandoc Installing instruction for Pandoc itself are given [at Pandoc homepage](http://pandoc.org/installing.html). On Debian-based systems this module and script [pandoc-version](https://metacpan.org/pod/pandoc-version) can be used to install and update the pandoc executable with [Pandoc::Release](https://metacpan.org/pod/Pandoc%3A%3ARelease): pandoc-version install Then add `~/.pandoc/bin` to your `PATH` or copy `~/.pandoc/bin/pandoc` to a location where it can be executed. # USAGE The utility function [pandoc](#pandoc) is exported, unless the module is imported with an empty list (`use Pandoc ();`). Importing this module with a version number or a more complex version requirenment (e.g. `use Pandoc 1.13;` or `use Pandoc '>= 1.6, !=1.7`) will check version number of pandoc executable instead of version number of this module (see `$Pandoc::VERSION` for the latter). Additional import arguments can be passed to set the executable location and default arguments of the global Pandoc instance used by function pandoc. # FUNCTIONS ## pandoc If called without parameters, this function returns a global instance of class Pandoc to execute [methods](#methods), or `undef` if no pandoc executable was found. The location and/or name of pandoc executable can be set with environment variable `PANDOC_PATH` (set to the string `pandoc` by default). ## pandoc( ... ) If called with parameters, this functions runs the pandoc executable configured at the global instance of class Pandoc (`pandoc->bin`). Arguments (given as array or array reference) are passed as pandoc command line arguments. Additional options (given as hash or has reference) can control input, output, and error stream: pandoc @arguments, \%options; # ok pandoc \@arguments, %options; # ok pandoc \@arguments, \%options; # ok pandoc @arguments; # ok, if first of @arguments starts with '-' pandoc %options; # ok, if %options is not empty pandoc @arguments, %options; # not ok! Returns `0` on success. On error returns the exit code of pandoc executable or `-1` if execution failed. If option `throw` is set, a [Pandoc::Error](https://metacpan.org/pod/Pandoc%3A%3AError) is thrown instead. The following options are recognized: - in / out / err These options correspond to arguments `$stdin`, `$stdout`, and `$stderr` of [IPC::Run3](https://metacpan.org/pod/IPC%3A%3ARun3), see there for details. - binmode\_stdin / binmode\_stdout / binmode\_stderr These options correspond to the like-named options to [IPC::Run3](https://metacpan.org/pod/IPC%3A%3ARun3), see there for details. - binmode If defined any binmode\_stdin/binmode\_stdout/binmode\_stderr option which is undefined will be set to this value. - throw Throw a [Pandoc::Error](https://metacpan.org/pod/Pandoc%3A%3AError) instead returning the exit code on error. Disabled by default. - return\_if\_system\_error Set to negation of option `throw` by default. For convenience the `pandoc` function (_after_ checking the `binmode` option) checks the contents of any scalar references passed to the in/out/err options with [utf8::is\_utf8()](https://metacpan.org/pod/utf8#flag-utf8::is_utf8-string) and sets the binmode\_stdin/binmode\_stdout/binmode\_stderr options to `:encoding(UTF-8)` if the corresponding scalar is marked as UTF-8 and the respective option is undefined. Since all pandoc executable input/output must be UTF-8 encoded this is convenient if you run with [use utf8](https://metacpan.org/pod/utf8), as you then don't need to set the binmode options at all ([encode nor decode](https://metacpan.org/pod/Encode)) when passing input/output scalar references. ## pandoc\_data\_dir( \[ @subdirs \] \[ $file \] ) Returns the default pandoc data directory which is directory `.pandoc` in the home directory for Unix or `pandoc` directory in `%APPDATA%` for Windows. Optional arguments can be given to refer to a specific subdirectory or file. # METHODS ## new( \[ $executable | $version \] \[, @arguments \] ) Create a new instance of class Pandoc or throw an exception if no pandoc executable was found. The first argument, if given and not starting with `-`, can be used to set the pandoc executable (`pandoc` by default). If a version is specified the executable is also searched in `~/.pandoc/bin`, e.g. `~/.pandoc/bin/pandoc-2.0` for version `2.0`. Additional arguments are passed to the executable on each run. Repeated use of this constructor with same arguments is not recommended because `pandoc --version` is called for every new instance. ## run( ... ) Execute the pandoc executable with default arguments and optional additional arguments and options. See [function pandoc](#pandoc) for usage. ## convert( $from => $to, $input \[, @arguments \] ) Convert a string in format `$from` to format `$to`. Additional pandoc options such as `-N` and `--standalone` can be passed. The result is returned in same utf8 mode (`utf8::is_unicode`) as the input. To convert from file to string use method `pandoc`/`run` like this and set input/output format via standard pandoc arguments `-f` and `-t`: pandoc->run( $filename, @arguments, { out => \$string } ); ## parse( $from => $input \[, @arguments \] ) Parse a string in format `$from` to a [Pandoc::Document](https://metacpan.org/pod/Pandoc%3A%3ADocument) object. Additional pandoc options such as `-N` and `--normalize` can be passed. This method requires at least pandoc version 1.12.1 and the Perl module [Pandoc::Elements](https://metacpan.org/pod/Pandoc%3A%3AElements). The reverse action is possible with method `to_pandoc` of [Pandoc::Document](https://metacpan.org/pod/Pandoc%3A%3ADocument). Additional shortcut methods such as `to_html` are available: $html = pandoc->parse( 'markdown' => '# A *section*' )->to_html; Method `convert` should be preferred for simple conversions unless you want to modify or inspect the parsed document in between. ## file( \[ $filename \[, @arguments \] \] ) Parse from a file (or STDIN) to a [Pandoc::Document](https://metacpan.org/pod/Pandoc%3A%3ADocument) object. Additional pandoc options can be passed, for instance use HTML input format (`@arguments = qw(-f html)`) instead of default markdown. This method requires at least pandoc version 1.12.1 and the Perl module [Pandoc::Elements](https://metacpan.org/pod/Pandoc%3A%3AElements). ## require( $version\_requirement ) Return the Pandoc instance if its version number fulfills a given version requirement. Throw an error otherwise. Can also be called as constructor: `Pandoc->require(...)` is equivalent to `pandoc->require` but throws a more meaningful error message if no pandoc executable was found. ## version( \[ $version\_requirement \] ) Return the pandoc version as [Pandoc::Version](https://metacpan.org/pod/Pandoc%3A%3AVersion) object. If a version requirement is given, the method returns undef if the pandoc version does not fulfill this requirement. To check whether pandoc is available with a given minimal version use one of: Pandoc->require( $minimum_version) # true or die pandoc and pandoc->version( $minimum_version ) # true or false ## bin( \[ $executable \] ) Return or set the pandoc executable. Setting an new executable also updates version and data\_dir by calling `pandoc --version`. ## symlink( \[ $name \] \[ verbose => 0|1 \] ) Create a symlink with given name to the executable and change executable to the symlink location afterwards. An existing symlink is replaced. If `$name` is an existing directory, the symlink will be named `pandoc` in there. This makes most sense if the directory is listed in environment variable `$PATH`. If the name is omitted or an empty string, symlink is created in subdirectory `bin` of pandoc data directory. ## arguments( \[ @arguments | \\@arguments ) Return or set a list of default arguments. ## data\_dir( \[ @subdirs \] \[ $file \] ) Return the stated default data directory, introduced with Pandoc 1.11. Use function `pandoc_data_dir` alternatively to get the expected directory without calling Pandoc executable. ## input\_formats Return a list of supported input formats. ## output\_formats Return a list of supported output formats. ## highlight\_languages Return a list of programming languages which syntax highlighting is supported for (via Haskell library highlighting-kate). ## extensions( \[ $format \] ) Return a hash of extensions mapped to whether they are enabled by default. This method is only available since Pandoc 1.18 and the optional format argument since Pandoc 2.0.6. ## libs Return a hash mapping the names of Haskell libraries compiled into the pandoc executable to [Pandoc::Version](https://metacpan.org/pod/Pandoc%3A%3AVersion) objects. # SEE ALSO This package includes [Pandoc::Version](https://metacpan.org/pod/Pandoc%3A%3AVersion) to compare Pandoc version numbers, [Pandoc::Release](https://metacpan.org/pod/Pandoc%3A%3ARelease) to get Pandoc releases from GitHub, and [App::Prove::Plugin::andoc](https://metacpan.org/pod/App%3A%3AProve%3A%3APlugin%3A%3Aandoc) to run tests with selected Pandoc executables. See [Pandoc::Elements](https://metacpan.org/pod/Pandoc%3A%3AElements) for a Perl interface to the abstract syntax tree of Pandoc documents for more elaborate document processing. See [Pod::Pandoc](https://metacpan.org/pod/Pod%3A%3APandoc) to parse Plain Old Documentation format ([perlpod](https://metacpan.org/pod/perlpod)) for processing with Pandoc. See [Pandoc wrappers and interfaces](https://github.com/jgm/pandoc/wiki/Pandoc-wrappers-and-interfaces) in the Pandoc GitHub Wiki for a list of wrappers in other programming languages. Other Pandoc related but outdated modules at CPAN include [Orze::Sources::Pandoc](https://metacpan.org/pod/Orze%3A%3ASources%3A%3APandoc) and [App::PDoc](https://metacpan.org/pod/App%3A%3APDoc). # AUTHOR Jakob Voß # CONTRIBUTORS Benct Philip Jonsson # LICENSE European Union Public Licence v. 1.2 (EUPL-1.2) cpanfile100664001750001750 41614151700212 13245 0ustar00vojvoj000000000000Pandoc-0.9.1requires 'perl', '5.014'; # core modules since Perl5.14 requires 'HTTP::Tiny'; requires 'JSON::PP'; # additional requirements requires 'IPC::Run3'; requires 'File::Which', '1.11'; on test => sub { requires 'Test::More', '0.96'; requires 'Test::Exception'; }; dist.ini100664001750001750 3314151700212 13160 0ustar00vojvoj000000000000Pandoc-0.9.1author=Jakob Voß [@Milla] andoc.pm100664001750001750 236614151700212 17030 0ustar00vojvoj000000000000Pandoc-0.9.1/lib/App/Prove/Pluginpackage App::Prove::Plugin::andoc; use 5.014; use warnings; our $VERSION = '0.9.1'; use Pandoc; use File::Temp qw(tempdir); use Cwd qw(realpath); sub load { my ( $class, $p ) = @_; my ($bin) = @{ $p->{args} }; die "Usage: prove -Pandoc=EXECUTABLE ...\n" unless defined $bin; die "Pandoc executable not found: $bin\n" unless -x $bin; # dies if executable is not pandoc my $pandoc = Pandoc->new($bin); my $tmp = tempdir( CLEANUP => 1 ); symlink( realpath( $pandoc->bin ), "$tmp/pandoc" ) or die "symlinking pandoc failed!\n"; $ENV{PATH} = "$tmp:" . $ENV{PATH}; if ( $p->{app_prove}->{verbose} ) { print "# pandoc executable set to $bin\n"; } } 1; __END__ =head1 NAME App::Prove::Plugin::andoc - Select pandoc executable for tests =head1 SYNOPSIS # specify executable prove -Pandoc=bin/pandoc-2.1.2 ... # specify executable in ~/.pandoc/bin by version prove -Pandoc=2.1.2 ... =head1 DESCRIPTION This plugin to L modifies PATH to use a selected pandoc executable before running tests. See L to download pandoc executables. =head1 SEE ALSO Pandoc executable with package L can be specified by constructor or with environment variable C. =cut Pandoc.pm100664001750001750 5062614151700212 14121 0ustar00vojvoj000000000000Pandoc-0.9.1/libpackage Pandoc; use 5.014; use warnings; use utf8; =head1 NAME Pandoc - wrapper for the mighty Pandoc document converter =cut our $VERSION = '0.9.1'; use Pandoc::Version; use Pandoc::Error; use File::Which; use File::Spec::Functions 'catdir'; use IPC::Run3; use parent 'Exporter'; our @EXPORT = qw(pandoc pandoc_data_dir); our $PANDOC; our $PANDOC_PATH ||= $ENV{PANDOC_PATH} || 'pandoc'; sub import { shift; if ( @_ and $_[0] =~ /^[v0-9.<>=!, ]+$/ ) { $PANDOC //= Pandoc->new; $PANDOC->require(shift); } $PANDOC //= Pandoc->new(@_) if @_; Pandoc->export_to_level( 1, 'pandoc' ); } sub VERSION { shift; $PANDOC //= Pandoc->new; $PANDOC->require(shift) if @_; $PANDOC->version; } sub new { my $pandoc = bless {}, shift; my $bin = ( @_ and $_[0] !~ /^-./ ) ? shift : $PANDOC_PATH; my $bin_from_version = pandoc_data_dir( "bin", "pandoc-$bin" ); if ( !-x $bin && $bin =~ /^\d+(\.\d+)*$/ && -x $bin_from_version ) { $pandoc->{bin} = $bin_from_version; } else { $pandoc->{bin} = which($bin); } $pandoc->{arguments} = []; $pandoc->arguments(@_) if @_; my ( $in, $out, $err ); if ( $pandoc->{bin} ) { run3 [ $pandoc->{bin}, '-v' ], \$in, \$out, \$err, { return_if_system_error => 1 }; } unless ( $out and $out =~ /^[^ ]+ (\d+(\.\d+)+)/ ) { Pandoc::Error->throw( message => "pandoc executable not found", out => $out, err => $err, ); } $pandoc->{version} = Pandoc::Version->new($1); $pandoc->{data_dir} = $1 if $out =~ /^Default user data directory: (.+)$/m; # before pandoc supported --list-highlight-languages if ( $out =~ /^Syntax highlighting is supported/m ) { $pandoc->{highlight_languages} = [ map { split /\s*,\s*/, $_ } ( $out =~ /^ (.+)$/mg ) ]; } my %libs; my $LIBRARY_VERSION = qr/\s+(\pL\w*(?:-\pL\w*)*)\s+(\d+(?:\.\d+)*),?/; if ( $out =~ /^Compiled with($LIBRARY_VERSION+)/m ) { %libs = $1 =~ /$LIBRARY_VERSION/g; for my $name ( keys %libs ) { $libs{$name} = Pandoc::Version->new( $libs{$name} ); } } $pandoc->{libs} = \%libs; return $pandoc; } sub pandoc(@) { ## no critic $PANDOC //= eval { Pandoc->new } // 0; if (@_) { return $PANDOC ? $PANDOC->run(@_) : -1; } else { return $PANDOC; } } sub run { my $pandoc = shift; my $args = 'ARRAY' eq ref $_[0] ? \@{ shift @_ } : undef; # \@args [ ... ] my $opts = 'HASH' eq ref $_[-1] ? \%{ pop @_ } : undef; # [ ... ] \%opts if (@_) { if ( !$args ) { # @args if ( $_[0] =~ /^-/ or $opts or @_ % 2 ) { $args = \@_; } else { # %opts $opts = {@_}; } } elsif ( $args and !$opts and ( @_ % 2 == 0 ) ) { # \@args [, %opts ] $opts = {@_}; } else { # passed both the args and opts by ref, # so other arguments don't make sense; # or passed args by ref and an odd-length list Pandoc::Error->throw('Too many or ambiguous arguments'); } } $args //= []; $opts //= {}; for my $io (qw(in out err)) { $opts->{"binmode_std$io"} //= $opts->{binmode} if $opts->{binmode}; if ( 'SCALAR' eq ref $opts->{$io} ) { next unless utf8::is_utf8( ${ $opts->{$io} } ); $opts->{"binmode_std$io"} //= ':encoding(UTF-8)'; } } my $throw = $opts->{throw} || !( $opts->{return_if_system_error} // 1 ); $opts->{out} //= \( my $out ); $opts->{err} //= \( my $err ); $opts->{return_if_system_error} = 1; run3 [ $pandoc->{bin}, @{ $pandoc->{arguments} }, @$args ], $opts->{in}, $opts->{out}, $opts->{err}, $opts; my $status = $? == -1 ? -1 : $? >> 8; if ( $status && $throw ) { Pandoc::Error->throw( system => $!, out => ${ $opts->{out} }, err => ${ $opts->{err} }, status => $status, message => ${ $opts->{err} } || 'pandoc execution failed' ); } else { $status; } } sub convert { my $pandoc = shift; my $from = shift; my $to = shift; my $in = shift; my $out = ""; my $utf8 = utf8::is_utf8($in); $pandoc->run( [ @_, '-f' => $from, '-t' => $to, '-o' => '-' ], { in => \$in, out => \$out, throw => 1 } ); utf8::decode($out) if $utf8; chomp $out; return $out; } sub parse { my $pandoc = shift; my $format = shift; my $json = ""; if ( $format eq 'json' ) { $json = shift; } else { $pandoc->require('1.12.1'); $json = $pandoc->convert( $format => 'json', @_ ); } require Pandoc::Elements; Pandoc::Elements::pandoc_json($json); } sub file { my $pandoc = shift; $pandoc->require('1.12.1'); my @args = ( @_, '-t' => 'json', '-o' => '-' ); $pandoc->run( \@args, out => \( my $json ), throw => 1 ); require Pandoc::Elements; Pandoc::Elements::pandoc_json($json); } sub require { my $pandoc = shift; $pandoc = do { $PANDOC //= Pandoc->new } if $pandoc eq 'Pandoc'; unless ( $pandoc->version(@_) ) { Pandoc::Error->throw( message => "pandoc $_[0] required, only found " . $pandoc->{version}, version => $pandoc->{version}, require => $_[0], ); } return $pandoc; } sub version { my $pandoc = shift or return; my $version = $pandoc->{version} or return; # compare against given version return if @_ and not $version->fulfills(@_); return $version; } sub data_dir { catdir( shift->{data_dir}, @_ ); } sub pandoc_data_dir { if ( $^O eq 'MSWin32' ) { catdir( $ENV{APPDATA}, 'pandoc', @_ ); } else { catdir( $ENV{HOME}, '.pandoc', @_ ); } } sub bin { my $pandoc = shift; if (@_) { my $new = Pandoc->new(shift); $pandoc->{$_} = $new->{$_} for (qw(version bin data_dir)); } $pandoc->{bin}; } sub arguments { my $pandoc = shift; if (@_) { my $args = 'ARRAY' eq ref $_[0] ? shift : \@_; Pandoc::Error->throw("first default argument must be an -option") if @$args and $args->[0] !~ /^-./; $pandoc->{arguments} = $args; } @{ $pandoc->{arguments} }; } sub _list { my ( $pandoc, $which ) = @_; if ( !$pandoc->{$which} ) { if ( $pandoc->version('1.18') ) { my $list = ""; my $command = $which; $command =~ s/_/-/g; $pandoc->run( "--list-$command", { out => \$list } ); $pandoc->{$which} = [ split /\n/, $list ]; } elsif ( !defined $pandoc->{help} ) { my $help; $pandoc->run( '--help', { out => \$help } ); for my $inout (qw(Input Output)) { $help =~ /^$inout formats:\s+([a-z_0-9,\+\s*]+)/m or next; $pandoc->{ lc($inout) . '_formats' } = [ split /\*?,\s+|\*?\s+/, $1 ]; } $pandoc->{help} = $help; } } @{ $pandoc->{$which} // [] }; } sub input_formats { $_[0]->_list('input_formats'); } sub output_formats { $_[0]->_list('output_formats'); } sub highlight_languages { $_[0]->_list('highlight_languages'); } sub extensions { my $pandoc = shift; my $format = shift // ''; my $out = ""; my %ext; if ( $pandoc->version < 1.18 ) { warn "pandoc >= 1.18 required for --list-extensions\n"; } else { if ($format) { if ( $format =~ /^[a-z0-9_]$/ and $pandoc->version >= '2.0.6' ) { $format = "=$format"; } else { warn "ignoring format argument to Pandoc->extensions\n"; $format = ''; } } $pandoc->run( "--list-extensions$format", { out => \$out } ); %ext = map { $_ =~ /^([+-]?)\s*([^-+ ]+)\s*([+-]?)$/; ( $2 => ( $1 || $3 ) eq '+' ? 1 : 0 ); } split /\n/, $out; } %ext; } sub libs { $_[0]->{libs}; } sub symlink { my $self = shift; my ( $name, %opts ) = @_ % 2 ? @_ : ( '', @_ ); if ( '' eq $name // '' ) { $name = pandoc_data_dir( 'bin', 'pandoc' ); } elsif ( -d $name ) { $name = "$name/pandoc"; } my $bin = $self->bin; unlink $name if -l $name; if ( symlink $bin, $name ) { say "symlinked $name -> $bin" if $opts{verbose}; $self->bin($name); } else { die "failed to create symlink $name -> $bin\n"; } $self; } 1; __END__ =encoding utf-8 =begin markdown # STATUS [![Linux Build Status](https://travis-ci.org/nichtich/Pandoc-Wrapper.svg)](https://travis-ci.org/nichtich/Pandoc-Wrapper) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/8p68qdqv72to633d?svg=true)](https://ci.appveyor.com/project/nichtich/pandoc-wrapper) [![Coverage Status](https://coveralls.io/repos/nichtich/Pandoc-Wrapper/badge.svg)](https://coveralls.io/r/nichtich/Pandoc-Wrapper) [![Kwalitee Score](http://cpants.cpanauthors.org/dist/Pandoc.png)](http://cpants.cpanauthors.org/dist/Pandoc) =end markdown =head1 SYNOPSIS use Pandoc; # check at first use use Pandoc 1.12; # check at compile time Pandoc->require(1.12); # check at run time # execute pandoc pandoc 'input.md', -o => 'output.html'; pandoc -f => 'html', -t => 'markdown', { in => \$html, out => \$md }; # alternative syntaxes pandoc->run('input.md', -o => 'output.html'); pandoc [ -f => 'html', -t => 'markdown' ], in => \$html, out => \$md; pandoc [ -f => 'html', -t => 'markdown' ], { in => \$html, out => \$md }; # check executable pandoc or die "pandoc executable not found"; # check minimum version pandoc->version > 1.12 or die "pandoc >= 1.12 required"; # access properties say pandoc->bin." ".pandoc->version; say "Default user data directory: ".pandoc->data_dir; say "Compiled with: ".join(", ", keys %{ pandoc->libs }); say pandoc->libs->{'highlighting-kate'}; # create a new instance with default arguments my $md2latex = Pandoc->new(qw(-f markdown -t latex --number-sections)); $md2latex->run({ in => \$markdown, out => \$latex }); # create a new instance with selected executable my $pandoc = Pandoc->new('bin/pandoc'); my $pandoc = Pandoc->new('2.1'); # use ~/.pandoc/bin/pandoc-2.1 if available # set default arguments on compile time use Pandoc qw(-t latex); use Pandoc qw(/usr/bin/pandoc --number-sections); use Pandoc qw(1.16 --number-sections); # utility method to convert from string $latex = pandoc->convert( 'markdown' => 'latex', '*hello*' ); # utility methods to parse abstract syntax tree (requires Pandoc::Elements) $doc = pandoc->parse( markdown => '*hello* **world!**' ); $doc = pandoc->file( 'example.md' ); $doc = pandoc->file; # read Markdown from STDIN =head1 DESCRIPTION This module provides a Perl wrapper for John MacFarlane's L document converter. =head1 INSTALLATION This module requires the Perl programming language (>= version 5.14) as included in most Unix operating systems by default. The recommended method to install Perl modules is C (see its L if needed): cpanm Pandoc Installing instruction for Pandoc itself are given L. On Debian-based systems this module and script L can be used to install and update the pandoc executable with L: pandoc-version install Then add C<~/.pandoc/bin> to your C or copy C<~/.pandoc/bin/pandoc> to a location where it can be executed. =head1 USAGE The utility function L is exported, unless the module is imported with an empty list (C). Importing this module with a version number or a more complex version requirenment (e.g. C or C<< use Pandoc '>= 1.6, !=1.7 >>) will check version number of pandoc executable instead of version number of this module (see C<$Pandoc::VERSION> for the latter). Additional import arguments can be passed to set the executable location and default arguments of the global Pandoc instance used by function pandoc. =head1 FUNCTIONS =head2 pandoc If called without parameters, this function returns a global instance of class Pandoc to execute L, or C if no pandoc executable was found. The location and/or name of pandoc executable can be set with environment variable C (set to the string C by default). =head2 pandoc( ... ) If called with parameters, this functions runs the pandoc executable configured at the global instance of class Pandoc (C<< pandoc->bin >>). Arguments (given as array or array reference) are passed as pandoc command line arguments. Additional options (given as hash or has reference) can control input, output, and error stream: pandoc @arguments, \%options; # ok pandoc \@arguments, %options; # ok pandoc \@arguments, \%options; # ok pandoc @arguments; # ok, if first of @arguments starts with '-' pandoc %options; # ok, if %options is not empty pandoc @arguments, %options; # not ok! Returns C<0> on success. On error returns the exit code of pandoc executable or C<-1> if execution failed. If option C is set, a L is thrown instead. The following options are recognized: =over =item in / out / err These options correspond to arguments C<$stdin>, C<$stdout>, and C<$stderr> of L, see there for details. =item binmode_stdin / binmode_stdout / binmode_stderr These options correspond to the like-named options to L, see there for details. =item binmode If defined any binmode_stdin/binmode_stdout/binmode_stderr option which is undefined will be set to this value. =item throw Throw a L instead returning the exit code on error. Disabled by default. =item return_if_system_error Set to negation of option C by default. =back For convenience the C function (I checking the C option) checks the contents of any scalar references passed to the in/out/err options with L<< utf8::is_utf8()|utf8/"* C<$flag = utf8::is_utf8($string)>" >> and sets the binmode_stdin/binmode_stdout/binmode_stderr options to C<:encoding(UTF-8)> if the corresponding scalar is marked as UTF-8 and the respective option is undefined. Since all pandoc executable input/output must be UTF-8 encoded this is convenient if you run with L, as you then don't need to set the binmode options at all (L) when passing input/output scalar references. =head2 pandoc_data_dir( [ @subdirs ] [ $file ] ) Returns the default pandoc data directory which is directory C<.pandoc> in the home directory for Unix or C directory in C<%APPDATA%> for Windows. Optional arguments can be given to refer to a specific subdirectory or file. =head1 METHODS =head2 new( [ $executable | $version ] [, @arguments ] ) Create a new instance of class Pandoc or throw an exception if no pandoc executable was found. The first argument, if given and not starting with C<->, can be used to set the pandoc executable (C by default). If a version is specified the executable is also searched in C<~/.pandoc/bin>, e.g. C<~/.pandoc/bin/pandoc-2.0> for version C<2.0>. Additional arguments are passed to the executable on each run. Repeated use of this constructor with same arguments is not recommended because C is called for every new instance. =head2 run( ... ) Execute the pandoc executable with default arguments and optional additional arguments and options. See L for usage. =head2 convert( $from => $to, $input [, @arguments ] ) Convert a string in format C<$from> to format C<$to>. Additional pandoc options such as C<-N> and C<--standalone> can be passed. The result is returned in same utf8 mode (C) as the input. To convert from file to string use method C/C like this and set input/output format via standard pandoc arguments C<-f> and C<-t>: pandoc->run( $filename, @arguments, { out => \$string } ); =head2 parse( $from => $input [, @arguments ] ) Parse a string in format C<$from> to a L object. Additional pandoc options such as C<-N> and C<--normalize> can be passed. This method requires at least pandoc version 1.12.1 and the Perl module L. The reverse action is possible with method C of L. Additional shortcut methods such as C are available: $html = pandoc->parse( 'markdown' => '# A *section*' )->to_html; Method C should be preferred for simple conversions unless you want to modify or inspect the parsed document in between. =head2 file( [ $filename [, @arguments ] ] ) Parse from a file (or STDIN) to a L object. Additional pandoc options can be passed, for instance use HTML input format (C<@arguments = qw(-f html)>) instead of default markdown. This method requires at least pandoc version 1.12.1 and the Perl module L. =head2 require( $version_requirement ) Return the Pandoc instance if its version number fulfills a given version requirement. Throw an error otherwise. Can also be called as constructor: C<< Pandoc->require(...) >> is equivalent to C<< pandoc->require >> but throws a more meaningful error message if no pandoc executable was found. =head2 version( [ $version_requirement ] ) Return the pandoc version as L object. If a version requirement is given, the method returns undef if the pandoc version does not fulfill this requirement. To check whether pandoc is available with a given minimal version use one of: Pandoc->require( $minimum_version) # true or die pandoc and pandoc->version( $minimum_version ) # true or false =head2 bin( [ $executable ] ) Return or set the pandoc executable. Setting an new executable also updates version and data_dir by calling C. =head2 symlink( [ $name ] [ verbose => 0|1 ] ) Create a symlink with given name to the executable and change executable to the symlink location afterwards. An existing symlink is replaced. If C<$name> is an existing directory, the symlink will be named C in there. This makes most sense if the directory is listed in environment variable C<$PATH>. If the name is omitted or an empty string, symlink is created in subdirectory C of pandoc data directory. =head2 arguments( [ @arguments | \@arguments ) Return or set a list of default arguments. =head2 data_dir( [ @subdirs ] [ $file ] ) Return the stated default data directory, introduced with Pandoc 1.11. Use function C alternatively to get the expected directory without calling Pandoc executable. =head2 input_formats Return a list of supported input formats. =head2 output_formats Return a list of supported output formats. =head2 highlight_languages Return a list of programming languages which syntax highlighting is supported for (via Haskell library highlighting-kate). =head2 extensions( [ $format ] ) Return a hash of extensions mapped to whether they are enabled by default. This method is only available since Pandoc 1.18 and the optional format argument since Pandoc 2.0.6. =head2 libs Return a hash mapping the names of Haskell libraries compiled into the pandoc executable to L objects. =head1 SEE ALSO This package includes L to compare Pandoc version numbers, L to get Pandoc releases from GitHub, and L to run tests with selected Pandoc executables. See L for a Perl interface to the abstract syntax tree of Pandoc documents for more elaborate document processing. See L to parse Plain Old Documentation format (L) for processing with Pandoc. See L in the Pandoc GitHub Wiki for a list of wrappers in other programming languages. Other Pandoc related but outdated modules at CPAN include L and L. =head1 AUTHOR Jakob Voß =head1 CONTRIBUTORS Benct Philip Jonsson =head1 LICENSE European Union Public Licence v. 1.2 (EUPL-1.2) =cut Error.pm100664001750001750 226414151700212 15165 0ustar00vojvoj000000000000Pandoc-0.9.1/lib/Pandocpackage Pandoc::Error; use 5.014; use warnings; our $VERSION = '0.9.1'; use overload '""' => 'message', fallback => 1; use Carp; $Carp::CarpInternal{ (__PACKAGE__) }++; # don't include package in stack trace sub new { my ( $class, %fields ) = @_ % 2 ? @_ : ( shift, message => @_ ); $fields{message} = Carp::shortmess( $fields{message} // $class ); bless \%fields, $class; } sub throw { die ref $_[0] ? $_[0] : shift->new(@_); } sub message { $_[0]->{message}; } 1; =head1 NAME Pandoc::Error - Pandoc document processing error =head1 SYNOPSIS use Try::Tiny; try { ... } catch { if ( blessed $_ && $_->isa('Pandoc::Error') ) { ... } }; =head1 METHODS =head2 throw( [ %fields ] ) Throw an existing error or create and throw a new error. Setting field C is recommended. The message is enriched with error location. A stack trace can be added with L<$Carp::Verbose|Carp/$Carp::Verbose> or L. =head2 message The error message. Also returned on stringification. =head1 SEE ALSO This class does not inherit from L, L or L but may do so in a future version. =cut Release.pm100664001750001750 1620314151700212 15472 0ustar00vojvoj000000000000Pandoc-0.9.1/lib/Pandocpackage Pandoc::Release; use 5.014; use warnings; our $VERSION = '0.9.1'; use HTTP::Tiny; use JSON::PP; use Cwd; use File::Path qw(make_path remove_tree); use File::Copy 'move'; use File::Temp 'tempdir'; use Pandoc; use Pandoc::Version; use parent 'Exporter'; our @EXPORT = qw(get list latest); =head1 NAME Pandoc::Release - get pandoc releases from GitHub =cut our $CLIENT = HTTP::Tiny->new; sub _api_request { my ( $url, %opts ) = @_; say $url if $opts{verbose}; my %headers = $opts{token} ? ( Authorization => "token $opts{token}" ) : (); my $res = $CLIENT->get( $url, { headers => \%headers } ); $res->{success} or die "failed to fetch $url"; $res->{content} = JSON::PP::decode_json( $res->{content} ); $res; } sub get { shift if __PACKAGE__ eq ( $_[0] // '' ); # can also be used as method my ( $version, %opts ) = @_; warn "Pandoc release 1.17 had a bug, please don't use!\n" if "$version" eq "1.17"; my $url = "https://api.github.com/repos/jgm/pandoc/releases/tags/$version"; bless _api_request( $url, %opts )->{content}, __PACKAGE__; } sub list { shift if __PACKAGE__ eq ( $_[0] // '' ); # can also be used as method my %opts = @_; my $range = $opts{range}; my $limit = $opts{limit} // -1; my $since = Pandoc::Version->new( $opts{since} // 0 ); my $url = "https://api.github.com/repos/jgm/pandoc/releases"; my @releases; LOOP: while ($url) { my $res = _api_request( $url, %opts ); foreach ( @{ $res->{content} } ) { my $version = Pandoc::Version->new( $_->{tag_name} ); last LOOP unless $since < $version; # abort if possible next if $version == '1.17'; # version had a bug if ( !$range || $version->fulfills($range) ) { push @releases, bless $_, __PACKAGE__; last LOOP if --$limit == 0; } } my $link = $res->{headers}{link} // ''; $link =~ /<([^>]+)>; rel="next"/ or last; $url = $1; } @releases; } sub latest { shift if __PACKAGE__ eq ( $_[0] // '' ); # can also be used as method ( list( @_, limit => 1 ) )[0]; } sub download { my ( $self, %opts ) = @_; my $version = Pandoc::Version->new( $self->{tag_name} ); my $bin = $opts{bin} // pandoc_data_dir('bin'); if ($bin) { make_path($bin); -d $bin or die "missing directory $bin"; $bin = "$bin/pandoc-$version"; if ( -f $bin ) { say "skipping existing $bin" if $opts{verbose}; my $pandoc = Pandoc->new($bin); $pandoc = $pandoc->symlink( $opts{symlink}, %opts ) if exists $opts{symlink}; return $pandoc; } } my $arch = $opts{arch} // `dpkg --print-architecture`; chomp $arch; my $dir = $opts{dir} // tempdir( CLEANUP => 1 ); my ($asset) = grep { $_->{name} =~ /-$arch\.deb$/ } @{ $self->{assets} }; my $url = ( $asset // {} )->{browser_download_url} or do { say "release $self->{tag_name} contains no $arch Debian package" if $opts{verbose}; return; }; make_path($dir); -d $dir or die "missing directory $dir"; my $deb = "$dir/" . $asset->{name}; say $deb if $CLIENT->mirror( $url, $deb )->{success} and $opts{verbose}; if ($bin) { my $cmd = "dpkg --fsys-tarfile '$deb'" . "| tar -x ./usr/bin/pandoc -O > '$bin'" . "&& chmod +x '$bin'"; system($cmd) and die "failed to extract pandoc from $deb:\n $cmd"; say $bin if $opts{verbose}; my $pandoc = Pandoc->new($bin); $pandoc = $pandoc->symlink( $opts{symlink}, %opts ) if exists $opts{symlink}; return $pandoc; } else { return $version; } } 1; __END__ =head1 SYNOPSIS From command line: # print latest release name perl -MPandoc::Release -E 'say latest->{name}' # download latest release unless already in ~/.pandoc/bin perl -MPandoc::Release -E 'latest->download' # download specific release and create symlink ~/.pandoc/bin/pandoc perl -MPandoc::Release -E 'get("2.7.3")->download->symlink' In Perl code: use Pandoc::Release; my $release = get('2.1.3'); # get a specific release my $latest = latest; # get a latest release # get multiple releases my @releases = list( since => '2.0', verbose => 1 ); foreach my $release (@releases) { # print version number say $release->{tag_name}; # download Debian package and executable $release->download( dir => './deb', bin => './bin' ); } # download executable and use as temporary Pandoc object: my $pandoc = get('2.1.3)->download( bin => './bin' ); =head1 DESCRIPTION This utility module fetches information about pandoc releases via GitHub API. On Debian-bases systems, this module can update and switch locally installed pandoc versions if you add directory C<~/.pandoc/bin> to your C<$PATH>. See L for a command line script that makes use of this module. =head1 FUNCTIONS All functions are exported by default. =head2 get( $version, %options ) Get a specific release by its version or die if the given version does not exist. Returns data as returned by GitHub releases API: L. =head2 list( %options ) Get a list of all pandoc releases, optionally C some version or within a version C such as C or C<==2.1.2>. See L for possible values. Option C will print URLs before each request. Option C limits the maximum number of releases to be returned. =head2 latest( %options ) Get the latest release, optionally C some version or within a version C. Equivalent to method C with option C<< limit => 1 >>. =head1 METHODS =head2 download( %options ) Download the Debian release file for some architecture (e.g. C) Pandoc executables is then extracted to directory C named by pandoc version number (e.g. C). Skips downloading if an executable of this name is already found there. Returns a L instance if C is not false or L otherwise. Additional options: =over =item dir Where to download release files to. A temporary directory is used by default. =item arch System architecture, detected with C by default. =item bin Where to extract pandoc binary to. By default set to C<~/.pandoc/bin> on Unix (see L function C). Extraction of executables can be disabled by setting C to a false value. =item symlink Create a symlink to the executable. This is just a shortcut for calling function C of L: $release->download( verbose => $v )->symlink( $l, verbose => $v ) $release->download( verbose => $v, symlink => $l ) # equivalent =back =head1 COMMON OPTIONS =over =item verbose Print what's going on (disabled by default). =item token L to avoid rate limiting. =back =head1 SEE ALSO L L =cut Version.pm100664001750001750 1103714151700212 15537 0ustar00vojvoj000000000000Pandoc-0.9.1/lib/Pandocpackage Pandoc::Version; use 5.014; use warnings; our $VERSION = '0.9.1'; use overload '""' => 'string', '0+' => 'number', cmp => 'cmp', '<=>' => 'cmp', fallback => 1; use Scalar::Util qw(reftype blessed); use Pandoc::Error; our @CARP_NOT = ('Pandoc'); sub new { my $class = shift; # We accept array or string input # (or mixed but let's not document that!) my @nums = map { my $num = $_; $num =~ /^\d+$/ or Pandoc::Error->throw( message => 'invalid version number', version => $num ); $num =~ s/^0+(?=\d)//; # ensure decimal interpretation $num = 0 + $num; $num } map { s/^v//i; split /\./ } ## no critic map { 'ARRAY' CORE::eq ( reftype $_ // "" ) ? @$_ : $_ } map { $_ // '' } @_; Pandoc::Error->throw('invalid version number') unless @nums; return bless \@nums => $class; } sub string { join '.', @{ $_[0] } } sub number { my ( $major, @minors ) = @{ $_[0] }; no warnings qw(uninitialized numeric); if (@minors) { my $minor = join '', map { sprintf '%03d', $_ } @minors; return 0 + "$major.$minor"; # return a true number } return 0 + $major; } sub cmp { my ( $a, $b ) = map { ( blessed $_ and $_->isa('Pandoc::Version') ) ? $_ : Pandoc::Version->new( $_ // () ) } ( $_[0], $_[1] ); return $a->number <=> $b->number; } sub match { my ( $a, $b ) = map { Pandoc::Version->new($_) } @_; pop @$a while @$a > @$b; pop @$b while @$b > @$a; return $a->number == $b->number; } my %cmp_truth_table = ( '==' => [ 0, 1, 0 ], '!=' => [ 1, 0, 1 ], '>=' => [ 0, 1, 1 ], '<=' => [ 1, 1, 0 ], '<' => [ 1, 0, 0 ], '>' => [ 0, 0, 1 ] ); sub fulfills { my ( $self, $req ) = @_; return 1 unless $req; my @parts = split qr{\s*,\s*}, $req; for my $part (@parts) { my ( $op, $ver ) = $part =~ m{^\s*(==|>=|>|<=|<|!=)?\s*v?(\d+(\.\d+)*)$}; if ( !defined $ver ) { Pandoc::Error->throw( message => "invalid version requirement: $req", require => $req, ); } my $cmp = $self->cmp($ver) + 1; # will be 0 for <, 1 for ==, 2 for > return unless $cmp_truth_table{ $op || '>=' }->[$cmp]; } 1; } sub TO_JSON { my ($self) = @_; return [ map { 0 + $_ } @$self ]; } 1; __END__ =head1 NAME Pandoc::Version - version number of pandoc and its libraries =head1 SYNOPSIS $version = Pandoc::Version->new("1.17.2"); # create version $version = bless [1,17,2], 'Pandoc::Version'; # equivalent "$version"; # stringify to "1.17.2" $version > 1.9; # compare $version->[0]; # major $version->[1]; # minor $version->match('1.17'); # true for 1.17, 1.17.x, 1.17.x.y... =head1 DESCRIPTION This module is used to store and compare version numbers of pandoc executable and Haskell libraries compiled into pandoc. A Pandoc::Version object is an array reference of one or more non-negative integer values. In most cases there is no need to create Pandoc::Version objects by hand. Just use the instances returned by methods C and C of module L and trust in overloading. =head1 METHODS =head2 string Return a string representation of a version, for instance C<"1.17.0.4">. This method is automatically called by overloading in string context. =head2 number Return a number representation of a version, for instance C<1.017000004>. This method is automatically called by overloading in number context. =head2 cmp( $version ) Compare two version numbers. This is method is used automatically by overloading to compare version objects with strings or numbers (operators C, C, C, C, C<==>, C<< < >>, C<< > >>, C<< <= >>, and C<< >= >>). =head2 match( $version ) Return whether a version number matches another version number if cut to the same number of parts. For instance C<1.2.3> matches C<1>, C<1.2>, and C<1.2.3>. =head2 fulfills( $version_requirement ) Return whether a version number fullfills a version requirement, such as C. See L for possible values. =head2 TO_JSON Return an array reference of the version number to serialize in JSON format. =head1 SEE ALSO L is a similar module for Perl version numbers. L extends versions to Semantic Versioning as described at L. L to get information about and download pandoc releases. =cut minil.toml100664001750001750 2014151700212 13515 0ustar00vojvoj000000000000Pandoc-0.9.1name = "Pandoc" pandoc-version100775001750001750 414614151700212 15746 0ustar00vojvoj000000000000Pandoc-0.9.1/script#!/usr/bin/env perl use v5.14; use Pod::Usage; use Pandoc; use Pandoc::Version; use Pandoc::Release; my $verbose = grep /^(-v|--verbose)$/, @ARGV; my @args = grep {!/^(-v|--verbose)$/} @ARGV; pod2usage(-exitval => 0) if grep /^-{0,2}h(elp)?$/, @args; my $version = eval { Pandoc::Version->new($args[0]) }; my $command = $version ? 'use' : $args[0] // 'version'; if ($command =~ /^v(ersion)?$/) { # TODO: catch if no pandoc installed say pandoc->version; } elsif ($command =~ /^l(ist)?$/) { # print installed versions my $dir = pandoc_data_dir( 'bin' ); opendir(DIR, $dir); my @files = grep { -e "$dir/$_" } grep(/^pandoc-/,readdir(DIR)); my @versions = map { /^pandoc-(\d+(\.\d+)*)$/ ? $1 : () } @files; say $_ for reverse sort @versions; closedir(DIR); } elsif ($command =~ /^i(nstall)?$/) { my $pandoc; $version = Pandoc::Version->new($args[1]) if $args[1]; if ($version) { say "Installing release $version of Pandoc..."; $pandoc = Pandoc::Release->get($version); } else { say "Installing latest release of Pandoc..."; $pandoc = Pandoc::Release->latest; } $pandoc->download->symlink( verbose => 1 ); } elsif ($command =~ /^u(se)?$/) { $version //= eval { Pandoc::Version->new($args[1]) } // die "missing or malformed version number!\n"; if (my $pandoc = eval { Pandoc->new($version) }) { $pandoc->symlink( verbose => $verbose ); } else { say STDERR "Pandoc version $version is not installed!"; exit 1; } } exit; __END__ =head1 NAME pandoc-version - switch pandoc executable =head1 SYNOPSIS pandoc-version [-v|--verbose] [command] [version] Commands: v|version show current version l|list list installed versions u|use switch version i|nstall install latest or specified release h|help show help =head1 DESCRIPTION This command line can be used to show the current executable version of Pandoc, and to switch installed versions. Full usage is limited to Debian based operating systems. =head1 SEE ALSO L =cut binmode.t100664001750001750 135414151700212 13630 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Pandoc; use utf8; # essential! sub capture_stderr(&;@); plan skip_all => 'pandoc executable required' unless pandoc; plan skip_all => 'Capture::Tiny required' unless eval 'use Capture::Tiny qw(capture_stderr); 1;'; my $input = <<'DUMMY_TEXT'; ## Ëïüs Üt Qüï äüt völüptätë mïnïmä. DUMMY_TEXT my( $output, $stderr ); $stderr = capture_stderr { pandoc->run( +{ in => \$input, out => \$output } ) }; unlike $stderr, qr{Wide character in print}, 'no wide character warning'; $stderr = capture_stderr { pandoc->run( +{ in => \$input, out => \$output, binmode => ':encoding(UTF-8)' } ) }; unlike $stderr, qr{Wide character in print}, 'one binmode for all handles'; done_testing; convert.t100664001750001750 164014151700212 13671 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Test::Exception; use Pandoc; plan skip_all => 'pandoc executable required' unless pandoc; my $latex = pandoc->convert('html' => 'latex', 'hällo'); is $latex, '\emph{hällo}', 'html => latex'; my @options = (pandoc->version < 2.0) ? ('markdown' => 'html', '...', '--smart') : ('markdown+smart' => 'html', '...'); my $html = pandoc->convert(@options); is $html, '

', 'markdown => html'; is $html, "

\xE2\x80\xA6

", 'convert returns bytes'; utf8::decode($html); my $format = pandoc->version < 2.0 ? 'markdown' : 'markdown-smart'; my $markdown = pandoc->convert('html' => $format, $html); like $markdown, qr{^\x{2026}}, 'convert returns Unicode to Unicode'; throws_ok { pandoc->convert('latex' => 'html', '', '--template' => '') } qr/template/, 'croak on error'; like pandoc->convert('latex' => 'html', '$\rightarrow$'), qr/→/, 'unicode'; done_testing; data-dir.t100664001750001750 23614151700212 13656 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use File::Spec::Functions 'catdir'; use Pandoc; ok length pandoc_data_dir > length '/.pandoc', 'pandoc_data_dir'; done_testing; example.md100664001750001750 714151700212 13715 0ustar00vojvoj000000000000Pandoc-0.9.1/t*--ä* executables.t100664001750001750 111114151700212 14506 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use File::Temp; use Pandoc; plan skip_all => 'pandoc executable required' unless pandoc; plan skip_all => 'these tests are for release candidate testing' unless $ENV{RELEASE_TESTING}; my $dir = File::Temp->newdir; isa_ok pandoc->symlink("$dir/foo"), 'Pandoc', 'symlink'; new_ok 'Pandoc', [ "$dir/foo" ], 'executable not named "pandoc"'; symlink "xxx", "$dir/pandoc"; # test overriding existing symlink is pandoc->symlink("$dir")->bin, pandoc->bin, 'return Pandoc instance'; new_ok 'Pandoc', [ "$dir/pandoc" ], 'symlink in directory'; done_testing; file-objects.t100664001750001750 113014151700212 14551 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Test::Exception; use Pandoc; use subs qw(path tempdir); plan skip_all => 'pandoc executable required' unless pandoc; plan skip_all => 'Path::Tiny required' unless eval 'use Path::Tiny qw(path tempdir); 1;'; my $dir = tempdir( CLEANUP => 1 ); (my $input = $dir->child('input.md'))->spew_utf8(<<'DUMMY_TEXT'); ## Eius Ut Qui aut voluptate minima. DUMMY_TEXT note $input->slurp_utf8; my $output = $dir->child('output.html'); lives_ok { pandoc->run(-o => $output, $input) } 'call pandoc with file objects as arguments'; note $output->slurp_utf8; done_testing; import.t100664001750001750 125214151700212 13522 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Test::Exception; BEGIN { require Pandoc; if ($ENV{RELEASE_TESTING}) { Pandoc->import(qw(-t latex)); } else { plan skip_all => 'these tests are for release candidate testing'; } } is_deeply [ pandoc->arguments ], [qw(-t latex)], 'import with arguments'; throws_ok { Pandoc->VERSION(99) } qr/^pandoc 99 required/, '!use Pandoc 99'; throws_ok { Pandoc->import(99) } qr/^pandoc 99 required/, '!use Pandoc qw(99 ...)'; lives_ok { Pandoc->VERSION(pandoc->version) } "use Pandoc ".pandoc->version; lives_ok { Pandoc->VERSION('1.9') } "use Pandoc 1.9"; lives_ok { Pandoc->VERSION('v1') } "use Pandoc 'v1'"; done_testing; lists.t100664001750001750 72014151700212 13325 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Test::Exception; use Pandoc; plan skip_all => 'pandoc executable required' unless pandoc; my @in = pandoc->input_formats; ok scalar @in > 5, 'input_formats'; my @out = pandoc->output_formats; ok scalar @out > 5, 'output_formats'; if (pandoc->version >= 1.18) { my %ext = pandoc->extensions; is $ext{raw_html}, 1, 'extensions: raw_html'; is $ext{hard_line_breaks}, 0, 'extensions: hard_line_breaks'; } done_testing; methods.t100664001750001750 1011314151700212 13667 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Test::Exception; use File::Which; use File::Spec::Functions 'catdir'; use Pandoc; use Scalar::Util 'reftype'; plan skip_all => 'pandoc executable required' unless pandoc; # import { throws_ok { Pandoc->import('999.9.9') } qr/^pandoc 999\.9\.9 required, only found \d+(\.\d)+/, 'import'; } # require { my $pandoc; lives_ok { $pandoc = Pandoc->require('0.1.0.1') } 'Pandoc->require'; is_deeply $pandoc, pandoc, 'require returns singleton'; lives_ok { pandoc->require('0.1.0.1') } 'pandoc->require'; throws_ok { pandoc->require('x') } qr{ at t/methods.t}m, 'require throws)'; throws_ok { pandoc->require('12345.67') } qr/^pandoc 12345\.67 required, only found \d+(\.\d)+/, 'require throws'; } # new { my $pandoc = Pandoc->new; is_deeply $pandoc, pandoc(), 'Pandoc->new'; ok $pandoc != pandoc, 'Pandoc->new creates new instance'; eval { Pandoc->new('/dev/null/notexist') }; isa_ok $@, 'Pandoc::Error'; like $@, qr{pandoc executable not found at t/methods\.t}, 'stringify Pandoc::Error'; } # bin { is pandoc->bin, which( $ENV{PANDOC_PATH} || 'pandoc' ), 'default executable'; # not an full test but part of it lives_ok { pandoc->bin( pandoc->bin ) } 'set executable'; throws_ok { pandoc->bin('/dev/null/notexist') } qr{pandoc executable not found}; } # version { my $version = pandoc->version; like( $version, qr/^\d+(.\d+)+$/, 'pandoc->version' ); isa_ok $version, 'Pandoc::Version', 'pandoc->version is a version object'; ok pandoc->version >= $version, 'compare same versions'; is pandoc->version($version), $version, 'expect same version'; ok pandoc->version > '0.1.2', 'compare lower versions'; is pandoc->version('0.1.2'), $version, 'expect lower version'; $version =~ s/(\d+)$/$1+1/e; ok pandoc->version < $version, 'compare higher versions'; ok !pandoc->version($version), 'expect higher version'; throws_ok { pandoc->version('abc') } qr{at t/methods\.t}m, 'invalid version'; } # arguments { my @args = qw(--number-sections -t html); my $pandoc = Pandoc->new(@args); is_deeply [ $pandoc->arguments ], \@args, 'arguments'; $pandoc = Pandoc->new( 'pandoc', @args ); is $pandoc->bin, which('pandoc'), 'executable and arguments'; is_deeply [ $pandoc->arguments ], \@args, 'arguments'; my ( $in, $out ) = ('# x'); is $pandoc->run( [], in => \$in, out => \$out ), 0, 'run'; like $out, qr{

1 x

}, 'use default arguments'; is $pandoc->run( '-t' => 'latex', { in => \$in, out => \$out } ), 0, 'run'; like $out, qr{\\section\{x\}\\label\{x\}}, 'override default arguments'; throws_ok { $pandoc->arguments(1) } qr/^first default argument must be an -option/; pandoc->arguments('--number-sections'); is_deeply [ pandoc->arguments ], ['--number-sections'], 'set arguments'; pandoc->arguments( [] ); is_deeply [ pandoc->arguments ], [], 'set arguments with array ref'; } # data_dir { if ( -d $ENV{HOME} . '/.pandoc' and pandoc->version('1.11') ) { my $dir = pandoc->data_dir; ok $dir, 'pandoc->data_dir'; is catdir( $dir, 'filters' ), pandoc->data_dir('filters'), 'pandoc->data_dir(...)'; } } # libs { is reftype( pandoc->libs ), 'HASH', 'pandoc->libs'; #if ($ENV{RELEASE_TESTING}) { # don't assume any libraries # isa_ok pandoc->libs->{'highlighting-kate'}, 'Pandoc::Version'; #} } # input_formats / output_formats { my $want = qr/^(markdown|latex|html|json)$/; is scalar( grep { $_ =~ $want } pandoc->input_formats ), 4, 'input_formats'; is scalar( grep { $_ =~ $want } pandoc->output_formats ), 4, 'output_formats'; } # highlight_languages { # we cannot assume that highlighting is enabled but it should not die if ( pandoc->libs->{'highlighting-kate'} ) { ok scalar( pandoc->highlight_languages ) > 10, 'highlight_languages'; } } # file { throws_ok { pandoc->file('?'); } 'Pandoc::Error'; } done_testing; parse.t100664001750001750 232714151700212 13326 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Test::Exception; use Pandoc; plan skip_all => 'pandoc executable >= 1.12.1 required' unless pandoc and pandoc->version('1.12.1'); plan skip_all => 'Pandoc::Elements required' unless eval { require Pandoc::Elements; 1 }; my $expect = '{"c":[{"c":[{"c":"ä","t":"Str"}],"t":"Emph"}],"t":"Para"}'; my $doc = pandoc->parse( markdown => "*ä*" ); isa_ok $doc, 'Pandoc::Document', 'parse markdown'; is $doc->content->[0]->to_json, $expect, 'parse markdown'; $doc = pandoc->parse( html => '

ä

' ); is $doc->content->[0]->to_json, $expect, 'parse html'; SKIP: { skip 'pandoc executable < 1.18 required' # FIXME in Pandoc::Elements if pandoc->version('1.18'); $doc = pandoc->parse( markdown => "*--ä*", '--smart' ); is $doc->string, "\x{2013}\x{00E4}", 'parse with addition arguments'; is_deeply $doc, pandoc->parse( json => $doc->to_json ), 'parse json'; my $ex = pandoc->file('t/example.md', '--smart'); is_deeply $ex, $doc, 'parse_file'; } if ($Pandoc::Elements::VERSION >= 0.29) { my $html = pandoc->parse( 'markdown' => '# A *section*' )->to_html; ok $html =~ qr{]*>A section}, 'parse->to_html'; } done_testing; run.t100664001750001750 441014151700212 13013 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More 0.96; # for subtests use Test::Exception; use Pandoc; plan skip_all => 'pandoc executable required' unless pandoc; my $args = ['-t' => 'markdown']; subtest 'pandoc( ... )' => sub { my ($html, $md); is pandoc({ in => \'*.*', out => \$html }), 0, 'pandoc({in =>..., out=>...}'; is $html, "

.

\n", 'markdown => html'; ## no critic pandoc -f => 'html', -t => 'markdown', { in => \$html, out => \$md }; like $md, qr/^\*\.\*/, 'html => markdown'; }; subtest 'run(@args, \%opts)' => sub { my $in = 'foo'; my %opts = ( in => \$in, out => \my($out), err => \my($err) ); lives_ok { pandoc->run( @$args, \%opts ) }, 'run'; like $out, qr!^\s*foo\s*$!, 'stdout'; note $out; is $err //= "", "", 'stderr'; lives_ok { pandoc->run( 'README.md', \%opts ) }, 'run with filename'; }; subtest '->run(\@args, \%opts)' => sub { my $in = 'foo'; my %opts = ( in => \$in, out => \my($out), err => \my($err) ); lives_ok { pandoc->run( $args, \%opts ) }, 'run'; like $out, qr!^\s*foo\s*$!, 'stdout'; is $err //= "", "", 'stderr'; }; subtest '->run(\@args, %opts)' => sub { my $in = 'foo'; my %opts = ( in => \$in, out => \my($out), err => \my($err) ); lives_ok { pandoc->run( $args, %opts ) }, 'run'; like $out, qr!^\s*foo\s*$!, 'stdout'; is $err //= "", "", 'stderr'; }; subtest '->run([], %opts)' => sub { my $in = 'foo'; my %opts = ( in => \$in, out => \my($out), err => \my($err) ); lives_ok { pandoc->run( [], %opts ) }, 'run'; like $out, qr!

foo

!, 'stdout'; is $err //= "", "", 'stderr'; }; subtest 'run(%opts)' => sub { my $out; lives_ok { pandoc in => \"# hi", out => \$out }; is $out, "

hi

\n", 'run( %opts )'; }; subtest '->run(\@args, qw[odd length list])' => sub { my $in = 'foo'; my %opts = ( in => \$in, out => \my($out), err => \my($err) ); throws_ok { pandoc->run( $args, %opts, 'foo' ) } qr!^Too many or ambiguous arguments!, 'run'; }; subtest '->run(\@args, ..., \%opts)' => sub { my $in = 'foo'; my %opts = ( in => \$in, out => \my($out), err => \my($err) ); throws_ok { pandoc->run( $args, qw[foo, bar], \%opts ) } qr!^Too many or ambiguous arguments!, 'run'; }; done_testing; version.t100664001750001750 465414151700212 13706 0ustar00vojvoj000000000000Pandoc-0.9.1/tuse strict; use Test::More; use Test::Exception; use Pandoc::Version; { my %same = ( array => [ [ 1, 17, 0, 4 ] ], list => [ ( 1, 17, 0, 4 ) ], string => ['1.17.0.4'], vstring => ['v1.17.0.4'], ); foreach ( sort keys %same ) { my $version = new_ok 'Pandoc::Version', $same{$_}, "new from $_"; is_deeply $version->TO_JSON, [qw(1 17 0 4)], "from $_"; } my @invalid = ( [{}], ['1..2'], ['abc'], ['1.9a'], ['0.-1'], [], [''], [undef] ); foreach ( @invalid ) { throws_ok { Pandoc::Version->new(@{$_}) } qr{^invalid version number}, 'invalid version number'; } } { my $version = bless [ 1, 17, 0, 4 ], 'Pandoc::Version'; new_ok 'Pandoc::Version', [ $version ], 'copy constructor'; is "$version", '1.17.0.4', 'stringify'; is $version->number, 1.017000004, 'number'; my %tests = ( '1.9' => { eq => '1.9', gt => '1.10', }, '1' => { eq => '1.0', gt => '1.0.1', }, '1.17.0.4' => { eq => '1.17.0.4', gt => '1.18', } ); foreach ( sort keys %tests ) { my $version = Pandoc::Version->new($_); my $eq = $tests{$_}{eq}; my $gt = $tests{$_}{gt}; ok $version == $eq, "$version == ".$eq; ok $version >= $eq, "$version >= ".$eq; ok $version <= $eq, "$version <= ".$eq; ok $version eq $eq, "$version eq ".$eq; ok $version ge $eq, "$version ge ".$eq; ok $version le $eq, "$version le ".$eq; if ( defined $gt ) { ok $version < $gt, "$version < $gt"; ok $version lt $gt, "$version lt $gt"; } } } { my $version = Pandoc::Version->new('1.7.3'); ok($version->match($_), "1.7.3 match $_") for qw(1 1.7 1.7.3 1.7.3.1); ok(!$version->match($_), "1.7.3 no match $_") for qw(1.6 1.8 2); } { my $version = Pandoc::Version->new('1.7'); my @yes = qw(1.7 !=1.7.1 >1.6 >=1.7 <1.7.1 <=1.7.1 ==1.7); for (@yes, join ', ', @yes) { ok $version->fulfills($_), "fulfills $_"; } my @no = qw(1.7,!=1.7 1.7.1 >1.7 >=1.7.1 <1.7 <=1.6 ==1.7.1); for (@no, join(', ', @yes, @no)) { ok !$version->fulfills($_), "!fulfills $_"; } throws_ok { $version->fulfills('foo') } qr/^invalid version requirement: foo/, 'invalid version requirement'; } done_testing; download-pandoc100775001750001750 121314151700212 15207 0ustar00vojvoj000000000000Pandoc-0.9.1/xt#!/usr/bin/env perl use strict; use warnings; use Pandoc::Release; my $range = join ',', @ARGV; my $verbose = 1; my @releases = $range =~ /^(==v?)?(\d+(\.\d)*)$/ ? get($2, verbose => $verbose) : list(range => $range, verbose => $verbose); foreach (@releases) { $_->download( dir => 'xt/deb', bin => 'xt/bin', verbose => $verbose ); } =head1 DESCRIPTION This script can be used to download binary executables of Pandoc. For instance to download a specific release or list of releases: ./xt/download-pandoc 2.1.0 ./xt/download-pandoc '>=2.1.0' Debian packages are put into C and Pandoc executables into C. =cut prove100775001750001750 44414151700212 13256 0ustar00vojvoj000000000000Pandoc-0.9.1/xt#!/usr/bin/env perl use strict; foreach (glob('xt/bin/*')) { next if $_ !~ qr{^xt/bin/pandoc-(\d(\.\d+)*)$}; system('prove', "-Pandoc=$_", @ARGV); } =head1 DESCRIPTION This script runs L with each pandoc executable found in C via L. =cut release.t100664001750001750 116214151700212 14020 0ustar00vojvoj000000000000Pandoc-0.9.1/xtuse strict; use Test::More; use File::Temp; use Pandoc::Release; my $release = Pandoc::Release->get( '2.1.3' ); is $release->{name}, 'pandoc 2.1.3', 'get release'; my @releases = Pandoc::Release->list( since => '2.1' ); like $releases[0]->{name}, qr/^pandoc/i, 'list releases'; note $_ for map { $_->{tag_name} } @releases; @releases = list( since => '9.0' ); is_deeply \@releases , [], 'no > 9.0 releases'; my @releases = list( range => '<=2.0.1, >1.19.2' ); is_deeply [ map {$_->{tag_name}} @releases ], [qw(2.0.1 2.0.0.1 2.0 1.19.2.1)], 'range releases'; like latest->{name}, qr{^pandoc}, 'latest'; done_testing; versions.t100664001750001750 35514151700212 14233 0ustar00vojvoj000000000000Pandoc-0.9.1/xtuse strict; use Test::More; use Pandoc; foreach (glob('xt/bin/*')) { next if $_ !~ qr{^xt/bin/pandoc-(\d(\.\d+)*)$}; is(Pandoc->new($_)->version, $1, $1); } ok(1); # to avoid zero tests if no executables available done_testing; META.yml100664001750001750 275014151700212 13035 0ustar00vojvoj000000000000Pandoc-0.9.1--- abstract: 'wrapper for the mighty Pandoc document converter' author: - 'Jakob Voß' build_requires: Test::Exception: '0' Test::More: '0.96' configure_requires: Module::Build::Tiny: '0.035' dynamic_config: 0 generated_by: 'Minilla/v3.1.11, CPAN::Meta::Converter version 2.150010' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Pandoc no_index: directory: - t - xt - inc - share - eg - examples - author - builder provides: App::Prove::Plugin::andoc: file: lib/App/Prove/Plugin/andoc.pm version: v0.9.1 Pandoc: file: lib/Pandoc.pm version: v0.9.1 Pandoc::Error: file: lib/Pandoc/Error.pm version: v0.9.1 Pandoc::Release: file: lib/Pandoc/Release.pm version: v0.9.1 Pandoc::Version: file: lib/Pandoc/Version.pm version: v0.9.1 requires: File::Which: '1.11' HTTP::Tiny: '0' IPC::Run3: '0' JSON::PP: '0' perl: '5.014' resources: bugtracker: https://github.com/nichtich/Pandoc-Wrapper/issues homepage: https://github.com/nichtich/Pandoc-Wrapper repository: git://github.com/nichtich/Pandoc-Wrapper.git version: 0.9.1 x_contributors: - 'Benct Philip Jonsson ' - 'Edward Betts ' - 'Jakob Voß ' - 'Mohammad S Anwar ' - 'Theo van Hoesel ' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' x_static_install: 1 MANIFEST100664001750001750 64614151700212 12677 0ustar00vojvoj000000000000Pandoc-0.9.1Build.PL Changes LICENSE META.json README.md cpanfile dist.ini lib/App/Prove/Plugin/andoc.pm lib/Pandoc.pm lib/Pandoc/Error.pm lib/Pandoc/Release.pm lib/Pandoc/Version.pm minil.toml script/pandoc-version t/binmode.t t/convert.t t/data-dir.t t/example.md t/executables.t t/file-objects.t t/import.t t/lists.t t/methods.t t/parse.t t/run.t t/version.t xt/download-pandoc xt/prove xt/release.t xt/versions.t META.yml MANIFEST