Pandoc-Elements-0.33 000755 001750 001750 0 13050301451 13164 5 ustar 00voj voj 000000 000000 README 100644 001750 001750 44565 13050301451 14163 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 NAME
Pandoc::Elements - create and process Pandoc documents
SYNOPSIS
The output of this script hello.pl
use Pandoc::Elements;
use JSON;
print Document(
{
title => MetaInlines [ Str "Greeting" ]
},
[
Header( 1, attributes { id => 'top' }, [ Str 'Hello' ] ),
Para [ Str 'Hello, world!' ],
],
api_version => '1.17.0.4'
)->to_json;
can be converted for instance to HTML via
./hello.pl | pandoc -f json -t html5 --standalone
an equivalent Pandoc Markdown document would be
% Greeting
# Gruß {.de}
Hello, world!
DESCRIPTION
Pandoc::Elements provides utility functions to parse, serialize, and
modify abstract syntax trees (AST) of Pandoc
documents. Pandoc can convert this data structure to many other
document formats, such as HTML, LaTeX, ODT, and ePUB.
See also module Pandoc::Filter, command line script pod2pandoc, and the
internal modules Pandoc::Walker and Pod::Simple::Pandoc.
PANDOC VERSIONS
The Pandoc document model is defined in file Text.Pandoc.Definition
as part of Haskell package pandoc-types.
Pandoc::Elements is compatible with pandoc-types 1.12.3 (released with
pandoc 1.12.1) up to at least pandoc-types-1.17.0.4 (first releases
with pandoc 1.18). JSON output of all pandoc releases since 1.12.1 can
be parsed with function pandoc_json, the "Document" constructor or
method parse of module Pandoc. The AST is always upgraded to
pandoc-types 1.17 and downgraded to another api version on
serialization with to_json.
To determine the api version required by a version of pandoc executable
since version 1.18 execute pandoc with the --version option and check
which version of the pandoc-types library pandoc was compiled with.
Beginning with version 1.18 pandoc will not decode a JSON AST
representation unless the major and minor version numbers (Document
method api_version) match those built into that version of pandoc. The
following changes in pandoc document model have been implemented:
* pandoc-types 1.17, released for pandoc 1.18, introduced the
LineBlock element and modified representation of the root Document
element.
* pandoc-types 1.16, released with pandoc 1.16, introduced attributes
to Link and Image elements
* pandoc-types 1.12.3, released with pandoc 1.12.1, modified the
representation of elements to objects with field t and c. This is
also the internal representation of documents used in this module.
FUNCTIONS
The following functions and keywords are exported by default:
* Constructors for all Pandoc document element (block elements such
as Para and inline elements such as Emph, metadata elements and the
Document).
* Type keywords such as Decimal and LowerAlpha to be used as types in
other document elements.
* The following helper functions pandoc_json, pandoc_version,
attributes, metadata, citation, and element.
pandoc_json $json
Parse a JSON string, as emitted by pandoc in JSON format. This is the
reverse to method to_json but it can read both old (before Pandoc 1.16)
and new format.
attributes { key => $value, ... }
Maps a hash reference or instance of Hash::MultiValue into the internal
structure of Pandoc attributes. The special keys id (string), and class
(string or array reference with space-separated class names) are
recognized. See attribute methods for details.
citation { ... }
A citation as part of document element Cite must be a hash reference
with fields citationID (string), citationPrefix (list of inline
elements) citationSuffix (list of inline elements), citationMode (one
of NormalCitation, AuthorInText, SuppressAuthor), citationNoteNum
(integer), and citationHash (integer). The helper method citation can
be used to construct such hash by filling in default values and using
shorter field names (id, prefix, suffix, mode, note, and hash):
citation {
id => 'foo',
prefix => [ Str "see" ],
suffix => [ Str "p.", Space, Str "42" ]
}
# in Pandoc Markdown
[see @foo p. 42]
pandoc_version( [ $document ] )
Return a Pandoc::Version object with expected version number of pandoc
executable to be used for serializing documents with to_json.
If a Document element is given as argument, the minimal pandoc release
version compatible with its api version is returned.
Without argument, package variable $PANDOC_VERSION is checked for a
preferred pandoc release. By default this variable is set from an
environment variable of same name. If no preferred pandoc release has
been specified, the function returns version 1.18 because this is the
first pandoc release compatible with most recent api version supported
by this module.
See also method version of module Pandoc to get the current version of
pandoc executable on your system.
element( $name => $content )
Create a Pandoc document element of arbitrary name. This function is
only exported on request.
ELEMENTS AND METHODS
Document elements are encoded as Perl data structures equivalent to the
JSON structure, emitted with pandoc output format json. This JSON
structure is subject to minor changes between versions of pandoc. All
elements are blessed objects that provide common element methods (all
elements), attribute methods (elements with attributes), and additional
element-specific methods.
COMMON METHODS
to_json
Return the element as JSON encoded string. The following are
equivalent:
$element->to_json;
JSON->new->utf8->canonical->convert_blessed->encode($element);
The serialization format can be adjusted to different pandoc versions
with module and environment variable PANDOC_VERSION or with Document
element properties api_version and pandoc_version.
When writing filters you can normally just rely on the api version
value obtained from pandoc, since pandoc expects to receive the same
JSON format as it emits.
name
Return the name of the element, e.g. "Para" for a paragraph element.
content
Return the element content. For most elements (Para, Emph, Str...) the
content is an array reference with child elements. Other elements
consist of multiple parts; for instance the Link element has attributes
(attr, id, class, classes, keyvals) a link text (content) and a link
target (target) with url and title.
is_block
True if the element is a Block element
is_inline
True if the element is an inline Inline element
is_meta
True if the element is a Metadata element
is_document
True if the element is a Document element
walk(...)
Walk the element tree with Pandoc::Walker
query(...)
Query the element to extract results with Pandoc::Walker
transform(...)
Transform the element tree with Pandoc::Walker
string
Returns a concatenated string of element content, leaving out all
formatting.
ATTRIBUTE METHODS
Some elements have attributes which can be an identifier, ordered class
names and ordered key-value pairs. Elements with attributes provide the
following methods:
attr
Get or set the attributes in Pandoc internal structure:
[ $id, [ @classes ], [ [ key => $value ], ... ] ]
See helper function attributes to create this structure.
keyvals
Get all attributes (id, class, and key-value pairs) as new
Hash::MultiValue instance, or replace all key-value pairs plus id
and/or class if these are included as field names. All class fields are
split by whitespaces.
$e->keyvals # return new Hash::MultiValue
$e->keyvals( $HashMultiValue ) # update by instance of Hash::MultiValue
$e->keyvals( key => $value, ... ) # update by list of key-value pairs
$e->keyvals( \%hash ) # update by hash reference
$e->keyvals( { } ) # remove all key-value pairs
$e->keyvals( id => '', class => '' ) # remove all key-value pairs, id, class
id
Get or set the identifier. See also Pandoc::Filter::HeaderIdentifiers
for utility functions to handle Header identifiers.
class
Get or set the list of classes, separated by whitespace.
add_attribute( $name => $value )
Append an attribute. The special attribute names id and class set or
append identifier or class, respectively.
DOCUMENT ELEMENT
Document
Root element, consisting of metadata hash (meta), document element
array (content=blocks) and optional api_version. The constructor
accepts either two arguments and an optional named parameter
api_version:
Document { %meta }, [ @blocks ], api_version => $version_string
or a hash with three fields for metadata, document content, and an
optional pandoc API version:
{
meta => { %metadata },
blocks => [ @content ],
pandoc-api-version => [ $major, $minor, $revision ]
}
The latter form is used as pandoc JSON format since pandoc release
1.18. If no api version is given, it will be set 1.17 which was also
introduced with pandoc release 1.18.
A third ("old") form is accepted for compatibility with pandoc JSON
format before release 1.18 and since release 1.12.1: an array with two
elements for metadata and document content respectively.
[ { unMeta => { %meta } }, [ @blocks ] ]
The api version is set to 1.16 in this case, but older versions down to
1.12.3 used the same format.
Document elements provide the following special methods in addition to
common element methods:
api_version( [ $api_version ] )
Return the pandoc-types version (aka "pandoc-api-version") of this
document as Pandoc::Version object or sets it to a new value. This
version determines how method to_json serializes the document.
See "PANDOC VERSIONS" for details.
pandoc_version( [ $pandoc_version ] )
Return the minimum required version of pandoc executable compatible
with the api_version of this document. The following are equivalent:
$doc->pandoc_version;
pandoc_version( $doc );
If used as setter, sets the api version of this document to be
compatible with the given pandoc version.
content or blocks
Get or set the array of block elements of the document.
meta( [ $metadata ] )
Get and/or set document metadata elements.
metavalue( [ $field ] )
Shortcut for meta->value.
to_pandoc( [ [ $pandoc, ] @arguments ])
Process the document with Pandoc executable and return its output:
$doc->to_pandoc( -o => 'doc.html' );
my $markdown = $doc->to_pandoc( -t => 'markdown' );
The first argument can optionally be an instance of Pandoc to use a
specific executable.
to_...( [ @arguments ] )
Process the document into markdown (pandoc's extended Markdown),
latex (LaTeX), html (HTML), rst (reStructuredText), or plain (plain
text). The following are equivalent:
$doc->to_markdown( @args );
$doc->to_pandoc( @args, '-t' => 'markdown' );
outline( [ $depth ] )
Returns an outline of the document structure based on Header
elements. The outline is a hierarchical hash reference with the
following fields:
header
Header element (not included at the document root)
blocks
List of block elements before the next Header element (of given
depth or less if a maximum depth was given)
sections
List of subsections, each having the same outline structure.
BLOCK ELEMENTS
BlockQuote
Block quote, consisting of a list of blocks (content)
BlockQuote [ @blocks ]
BulletList
Unnumbered list of items (content=items), each a list of blocks
BulletList [ [ @blocks ] ]
CodeBlock
Code block (literal string content) with attributes (attr, id, class,
classes, keyvals)
CodeBlock $attributes, $content
DefinitionList
Definition list, consisting of a list of pairs (content=items), each a
term (term, a list of inlines) and one or more definitions
(definitions, a list of blocks).
DefinitionList [ @definitions ]
# each item in @definitions being a pair of the form
[ [ @inlines ], [ @blocks ] ]
Div
Generic container of blocks (content) with attributes (attr, id, class,
classes, keyvals).
Div $attributes, [ @blocks ]
Header
Header with level (integer), attributes (attr, id, class, classes,
keyvals), and text (content, a list of inlines).
Header $level, $attributes, [ @inlines ]
HorizontalRule
Horizontal rule
HorizontalRule
LineBlock
List of lines (content), each a list of inlines.
LineBlock [ @lines ]
This element was added in pandoc 1.18. Before it was represented Para
elements with embedded LineBreak elements. This old serialization form
can be enabled by setting $PANDOC_VERSION package variable to a lower
version number.
Null
Nothing
Null
OrderedList
Numbered list of items (content=items), each a list of blocks),
preceded by list attributes (start number, numbering style, and
delimiter).
OrderedList [ $start, $style, $delim ], [ [ @blocks ] ]
Supported styles are DefaultStyle, Example, Decimal, LowerRoman,
UpperRoman, LowerAlpha, and UpperAlpha.
Supported delimiters are DefaultDelim, Period, OneParen, and TwoParens.
Para
Paragraph, consisting of a list of Inline elements (content).
Para [ $elements ]
Plain
Plain text, not a paragraph, consisting of a list of Inline elements
(content).
Plain [ @inlines ]
RawBlock
Raw block with format and content string.
RawBlock $format, $content
Table
Table, with caption, column alignments, relative column widths (0 =
default), column headers (each a list of blocks), and rows (each a list
of lists of blocks).
Table [ @inlines ], [ @alignments ], [ @width ], [ @headers ], [ @rows ]
Possible alignments are AlignLeft, AlignRight, AlignCenter, and
AlignDefault.
An example:
Table [Str "Example"], [AlignLeft,AlignRight], [0.0,0.0],
[[Plain [Str "name"]]
,[Plain [Str "number"]]],
[[[Plain [Str "Alice"]]
,[Plain [Str "42"]]]
,[[Plain [Str "Bob"]]
,[Plain [Str "23"]]]];
INLINE ELEMENTS
Cite
Citation, a list of citations and a list of inlines (content). See
helper function citation to construct citations.
Cite [ @citations ], [ @inlines ]
Code
Inline code, a literal string (content) with attributes (attr, id,
class, classes, keyvals)
Code attributes { %attr }, $content
Emph
Emphasized text, a list of inlines (content).
Emph [ @inlines ]
Image
Image with alt text (content, a list of inlines) and target (list of
url and title) with attributes (attr, id, class, classes, keyvals).
Image attributes { %attr }, [ @inlines ], [ $url, $title ]
Serializing the attributes is disabled in api version less then 1.16.
LineBreak
Hard line break
LineBreak
Link
Hyperlink with link text (content, a list of inlines) and target (list
of url and title) with attributes (attr, id, class, classes, keyvals).
Link attributes { %attr }, [ @inlines ], [ $url, $title ]
Serializing the attributes is disabled in api version less then 1.16.
Math
TeX math, given as literal string (content) with type (one of
DisplayMath and InlineMath).
Math $type, $content
Note
Footnote or Endnote, a list of blocks (content).
Note [ @blocks ]
Quoted
Quoted text with quote type (one of SingleQuote and DoubleQuote) and a
list of inlines (content).
Quoted $type, [ @inlines ]
RawInline
Raw inline with format (a string) and content (a string).
RawInline $format, $content
SmallCaps
Small caps text, a list of inlines (content).
SmallCaps [ @inlines ]
SoftBreak
Soft line break
SoftBreak
This element was added in pandoc 1.16 as a matter of editing
convenience to preserve line breaks (as opposed to paragraph breaks)
from input source to output. If you are going to feed a document
containing SoftBreak elements to Pandoc < 1.16 you will have to set the
package variable or environment variable PANDOC_VERSION to 1.15 or
below.
Space
Inter-word space
Space
Span
Generic container of inlines (content) with attributes (attr, id,
class, classes, keyvals).
Span attributes { %attr }, [ @inlines ]
Str
Plain text, a string (content).
Str $content
Strikeout
Strikeout text, a list of inlines (content).
Strikeout [ @inlines ]
Strong
Strongly emphasized text, a list of inlines (content).
Strong [ @inlines ]
Subscript
Subscripted text, a list of inlines (content).
Supscript [ @inlines ]
Superscript
Superscripted text, a list of inlines (content).
Superscript [ @inlines ]
METADATA ELEMENTS
See Pandoc::Metadata for documentation.
TYPE KEYWORDS
The following document elements are only as used as type keywords in
other document elements:
* SingleQuote, DoubleQuote
* DisplayMath, InlineMath
* AuthorInText, SuppressAuthor, NormalCitation
* AlignLeft, AlignRight, AlignCenter, AlignDefault
* DefaultStyle, Example, Decimal, LowerRoman, UpperRoman, LowerAlpha,
UpperAlpha
* DefaultDelim, Period, OneParen, TwoParens
SEE ALSO
Perl module Pandoc implements a wrapper around the pandoc executable.
Similar libraries in other programming languages are listed at
https://github.com/jgm/pandoc/wiki/Pandoc-wrappers-and-interfaces.
AUTHOR
Jakob Voß
CONTRIBUTORS
Benct Philip Jonsson
COPYRIGHT AND LICENSE
Copyright 2014- Jakob Voß
GNU General Public License, Version 2
This module is heavily based on Pandoc by John MacFarlane.
Changes 100644 001750 001750 11504 13050301451 14561 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 Revision history for Pandoc-Elements
0.33 2017-02-13 10:57:59 CET
- Extend and document document metadata handling (#10)
- Fix $document->to_pandoc and friends with first Pandoc argument
0.32 2017-02-01 16:15:21 CET
- Deprecate Pandoc::Filter::Usage and remove circular dependency
0.31 2017-02-01 15:52:47 CET
- Remove deprecated script pandocwalk
- Remove module Pandoc::Filter::Lazy
0.30 2017-01-31 21:23:11 CET
- Fix and extend method to_pandoc
- Extend document method metavalues
0.29 2017-01-25 12:10:07 CET
- Add document methods: to_pandoc, to_markdown, ... (#48)
- Add document methods: outline
- Make Link/Image methods url/title also setters (#54)
- Let pod2pandoc include package name as title
- Fix metavalue for MetaBlocks
0.28 2016-11-29 06:49:57 CET
- Fix pod2pandoc
- Extend selection of serialization format (pandoc_version/api_version)
0.27 2016-11-21 19:36:29 CET
- Update internal Document structure and default to Pandoc 1.18
- Extend testing
0.26 2016-11-11 10:49:22 CET
- Extend Pod::Simple::Pandoc
- Add Pandoc::Filter::HeaderIdentifiers
- Mark pandocwalk and Pandoc::Filter::Lazy as deprecated
0.25 2016-10-11 21:32:00 CEST
- Improve pod2pandoc script
- Rename Pandoc::Filter::Usage::frompod to ::pod2usage
- Add example filter: section
- use new CPAN module Pandoc
0.24 2016-10-06 14:17:31 CEST
- Rewrite and rename pandoc-filters to multifilter
0.23 2016-09-30 22:35:22 CEST
- Add Pandoc::Filter::Usage and option --about for filter documentation
- Extend pandoc-filters to support future Pandoc filters directory
- Make most getters also setters
0.22 2016-09-22 12:03:38 CEST
- Add pandoc-filters script to run filters specified in document metadata
- Let pandoc_walk/pandoc_filter not filter metadata fields
- Add metavars example
0.21 2016-09-19 22:05:43 CEST
- extend method 'keyvals' as setter
- document and extend metadata elements by method 'metavalue'
- make content method an optional setter (not documented yet)
- let to_json return canonical JSON
0.20 2016-09-04 14:34:05 CEST
- Revert extended class selector, implement setter for id/class/keyvals instead
- Add graphviz example
0.19 2016-09-03 09:42:34 CEST
- Extend class selector to test existence of given class
- Extend attributes with Hash::MultiValue.
- Drop support of special key 'classes' in attributes helper function
0.18 2016-04-06 13:23:35 CEST
- Fix and extend attributes function (#29/#26/#14)
- Document and test removal of SoftBreak element
- fix json serialization to ensure right scalar types (#27)
0.17 2016-03-07 21:15:58 CET
- Support stringification of meta elements
- Add SoftBreak inline element, introduced in Pandoc 1.16
0.16 2016-02-23 20:16:52 CET
- Support new (Pandoc 1.16) document model with Link and Image attributes (issue #11)
- Fix blessing metadata top level values
0.15 2015-12-14 10:12:50 CET
- fix Pod::Simple::Pandoc for old Pod::Simple
- allow more lazy filter scripting
- add example to remove unnumbered sections
0.14 2015-12-11 14:11:51 CET
- refactor and introduce Pandoc::Filter::Lazy
0.13 2015-12-09 12:43:50 CET
- fix passing of output format
- add method match (experimental)
- added examples myemph.pl and theorem.pl
0.12 2015-12-08 13:55:43 CET
- added pod2pandoc script and Pod::Simple::Pandoc
- added string as method to replace function stringify
- fixed nasty bug in Pandoc::Element constructor reuse
0.11 2015-11-30 13:47:17 CET
- UTF-8 output with pandoc_walk and pandoc_filter
- include tests of pandoc-walk
0.10 2015-11-26 22:07:39 CET
- added utility script pandoc-walk
- new method: pandoc_walk
- provide special variable $_ to action functions
0.09 2015-11-22 20:40:49 CET
- support definition of filters as hash
0.08 2015-09-24 11:10:54 CEST
- new helper function: citation
0.07 2015-09-22 15:39:49 CEST
- extend documentation and examples
0.06 2015-01-19 12:58:09 CET
- fix endless recursion bug (issue #7)
- add walker methods to documente elements (issue #4)
- simplify access to attributes (issue #8, not documented yet)
- rename and document function pandoc_json
- extend documentation
0.05 2014-12-27 15:45:38 CET
- fixed filter bug (issue #5)
- added examples
- added more accessor methods
- remove method value
0.04 2014-10-27 14:09:21 CET
- added accessor methods (issue #1)
- refactoring
0.03 2014-10-26 20:52:58 CET
- use blessed objects
- new methods to_json and from_json
- added Pandoc::Filter
- changed calling syntax of Pandoc::Walker
0.02 2014-10-26 10:34:37 CET
- added Pandoc::Walker
- new helper method: element
0.01 2014-10-23 21:34:25 CEST
- initial release
t 000755 001750 001750 0 13050301451 13350 5 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 ast.t 100644 001750 001750 1341 13050301451 14463 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
my $doc = Document { title => MetaInlines [ Str 'test' ] },
[ Para [ Str 'test' ] ];
ok $doc->is_document, 'is_document';
is $doc->name, 'Document', 'name';
is_deeply $doc->content, [ Para [ Str 'test' ] ];
ok !$doc->is_block, 'is_block';
ok !$doc->is_inline, 'is_inline';
ok !$doc->is_meta, 'is_meta';
my $meta=$doc->meta;
ok $meta, '->meta';
ok $meta->{title}->is_meta, 'is_meta';
is $meta->{title}->name, 'MetaInlines', 'name';
my $para = $doc->{blocks}->[0];
is $para->name, 'Para', 'name';
is_deeply $para->content, [ Str 'test' ];
ok $para->is_block, 'is_block';
ok !$para->is_document, '!is_document';
$para->null;
is $para->name, 'Null', 'null';
done_testing;
LICENSE 100644 001750 001750 43525 13050301451 14303 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 This software is Copyright (c) 2014- by Jakob Voß .
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
cpanfile 100644 001750 001750 633 13050301451 14733 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 requires 'perl', '5.010001';
# core modules
requires 'Pod::Simple', '3.08';
requires 'List::Util';
requires 'Scalar::Util';
requires 'Pod::Usage';
# additional modules
requires 'JSON';
requires 'Hash::MultiValue', '0.06';
requires 'Pandoc', '0.6.0';
requires 'IPC::Run3'; # implied by Pandoc
on test => sub {
requires 'Test::More', '0.96';
requires 'Test::Output';
requires 'Test::Exception';
};
dist.ini 100644 001750 001750 132 13050301451 14665 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 author=Jakob Voß
[@Milla]
[PruneFiles]
filename=examples/Makefile
match=^examples/.*\.md
xt 000755 001750 001750 0 13050301451 13540 5 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 prove 100755 001750 001750 1243 13050301451 14761 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/xt #!/usr/bin/env perl
use strict;
use v5.10;
use Test::More;
use File::Basename;
# TODO: make this a subtest or something linke Pandoc::Test::Run?
use lib 'xt/lib';
use Pandoc::Releases;
my @version;
while (@ARGV and $ARGV[0] =~ /^[v0-9., <>=!]+$/) {
# Use only this version if a simple version number is specified
push @version, map { $_ =~ /[<>=]/ ? $_ : "==$_" } shift @ARGV;
}
my $PATH = $ENV{PATH};
foreach my $pandoc (pandoc_releases) {
next unless $pandoc->version(join ', ', @version);
note $pandoc->bin;
local $ENV{PATH} = dirname($pandoc->bin).":$PATH";
local $ENV{RELEASE_TESTING} = 1;
system('prove', '-l', @ARGV);
}
done_testing;
Build.PL 100644 001750 001750 265 13050301451 14524 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 # This Build.PL for Pandoc-Elements was generated by Dist::Zilla::Plugin::ModuleBuildTiny 0.010.
use strict;
use warnings;
use 5.010001;
use Module::Build::Tiny 0.039;
Build_PL();
META.yml 100644 001750 001750 2021 13050301451 14511 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 ---
abstract: 'create and process Pandoc documents'
author:
- 'Jakob Voß'
build_requires:
Test::Exception: '0'
Test::More: '0.96'
Test::Output: '0'
configure_requires:
Module::Build::Tiny: '0.039'
dynamic_config: 0
generated_by: 'Dist::Zilla version 5.036, Dist::Milla version v1.0.15, CPAN::Meta::Converter version 2.150001'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Pandoc-Elements
no_index:
directory:
- t
- xt
- inc
- share
- eg
- examples
requires:
Hash::MultiValue: '0.06'
IPC::Run3: '0'
JSON: '0'
List::Util: '0'
Pandoc: v0.6.0
Pod::Simple: '3.08'
Pod::Usage: '0'
Scalar::Util: '0'
perl: '5.010001'
resources:
bugtracker: https://github.com/nichtich/Pandoc-Elements/issues
homepage: https://github.com/nichtich/Pandoc-Elements
repository: https://github.com/nichtich/Pandoc-Elements.git
version: '0.33'
x_contributors:
- 'Benct Philip Jonsson '
- 'Jakob Voß '
MANIFEST 100644 001750 001750 3053 13050301451 14377 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.036.
Build.PL
Changes
LICENSE
MANIFEST
META.json
META.yml
README
cpanfile
dist.ini
examples/caps.pl
examples/comments.pl
examples/deemph.pl
examples/deflist.pl
examples/ditaa.pl
examples/graphviz.pl
examples/metavars.pl
examples/myemph.pl
examples/qids.pl
examples/remove-unnumbered-sections.pl
examples/section.pl
examples/theorem.pl
lib/Pandoc/Document/Element.pm
lib/Pandoc/Elements.pm
lib/Pandoc/Filter.pm
lib/Pandoc/Filter/HeaderIdentifiers.pm
lib/Pandoc/Filter/ImagesFromCode.pm
lib/Pandoc/Filter/Multifilter.pm
lib/Pandoc/Filter/Usage.pm
lib/Pandoc/Metadata.pm
lib/Pandoc/Walker.pm
script/multifilter
t/accessors.t
t/ast.t
t/attributes.t
t/citation.t
t/document-pandoc-version.t
t/document.t
t/documents/example.json
t/documents/example.md
t/documents/link-image-attributes.json
t/documents/link-image-oldstyle.json
t/documents/meta.json
t/documents/outline.md
t/elements.t
t/example.md
t/example.tex
t/examples/deemph.in.md
t/examples/deemph.out.md
t/filter.t
t/header-identifiers.t
t/invalid-version-from-env.t
t/lineblock.t
t/link-image-attributes.t
t/linkage-setters.t
t/match.t
t/meta-blessing.t
t/meta-filter.t
t/metadata.t
t/multifilter.t
t/outline
t/outline.t
t/pandoc-metadata.t
t/pandoc-version.t
t/pandoc/filters/caps
t/pandoc/filters/empty.pl
t/pandoc_filter.t
t/release-pod-syntax.t
t/scalar-types.t
t/softbreak.t
t/stringify.t
t/synopsis.t
t/to_pandoc.t
t/walker.t
xt/Makefile
xt/README.md
xt/get-pandoc-releases.pl
xt/lib/Pandoc/Releases.pm
xt/pod2pandoc.pl
xt/prove
xt/versions.t
match.t 100644 001750 001750 1431 13050301451 14770 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
ok Str('')->match('Str'), 'match name';
ok !Str('')->match('Para'), 'no match';
ok Str('')->match('str'), 'case-insensitive';
ok Str('')->match(':inline'), 'type match';
ok !Str('')->match(':block'), 'type not match';
ok Str('')->match('str:inline'), 'multiple match';
ok Str('')->match('Foo|Str'), '| match';
ok !Str('')->match('#id'), 'no id match';
my $e = Code attributes { id => 'abc', class => ['f0.0','bar']} , '';
ok $e->match('#abc'), 'id match';
ok !$e->match('#xyz'), 'id no match';
ok !$e->match('#1'), 'id no match';
ok $e->match('.f0.0'), 'class match';
ok $e->match('.bar .f0.0'), 'classes match';
ok !$e->match('.xyz'), 'class no match';
ok $e->match("code\t:inline .bar#abc .f0.0"), 'multiple match';
done_testing;
outline 100755 001750 001750 251 13050301451 15073 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t #!/usr/bin/env perl
use strict;
use 5.010;
use lib 'lib';
use Pandoc::Elements;
use Pandoc::Filter;
pandoc_walk( Header => sub{ say " " x ($_->level-1), $_->string } );
META.json 100644 001750 001750 3604 13050301451 14671 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 {
"abstract" : "create and process Pandoc documents",
"author" : [
"Jakob Voß"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 5.036, Dist::Milla version v1.0.15, CPAN::Meta::Converter version 2.150001",
"license" : [
"gpl_2"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Pandoc-Elements",
"no_index" : {
"directory" : [
"t",
"xt",
"inc",
"share",
"eg",
"examples"
]
},
"prereqs" : {
"configure" : {
"requires" : {
"Module::Build::Tiny" : "0.039"
}
},
"develop" : {
"requires" : {
"Dist::Milla" : "v1.0.15",
"Test::Pod" : "1.41"
}
},
"runtime" : {
"requires" : {
"Hash::MultiValue" : "0.06",
"IPC::Run3" : "0",
"JSON" : "0",
"List::Util" : "0",
"Pandoc" : "v0.6.0",
"Pod::Simple" : "3.08",
"Pod::Usage" : "0",
"Scalar::Util" : "0",
"perl" : "5.010001"
}
},
"test" : {
"requires" : {
"Test::Exception" : "0",
"Test::More" : "0.96",
"Test::Output" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/nichtich/Pandoc-Elements/issues"
},
"homepage" : "https://github.com/nichtich/Pandoc-Elements",
"repository" : {
"type" : "git",
"url" : "https://github.com/nichtich/Pandoc-Elements.git",
"web" : "https://github.com/nichtich/Pandoc-Elements"
}
},
"version" : "0.33",
"x_contributors" : [
"Benct Philip Jonsson ",
"Jakob Voß "
]
}
filter.t 100644 001750 001750 2504 13050301451 15163 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use 5.010;
use Test::More;
use Pandoc::Filter;
use Pandoc::Elements;
# action function
my $action = sub {
return unless $_[0]->name eq 'Header' and $_[0]->level >= 2;
Para [ Emph $_[0]->content ];
};
my $h1 = Header(1, attributes {}, [ Str 'hello']);
my $h2 = Header(2, attributes {}, [ Str 'hello']);
is $action->($h1), undef, 'action';
is_deeply $action->($h2), Para [ Emph [ Str 'hello' ] ], 'action';
{
my $doc = Document {}, [ $h1, $h2 ];
Pandoc::Filter->new($action)->apply($doc);
is_deeply $doc->content->[1], Para [ Emph [ Str 'hello' ] ], 'apply';
}
{
my $doc = Document { title => MetaInlines [ Str 'test' ] }, [ $h1, $h2 ];
Pandoc::Filter->new(
Header => sub {
Para [ Str $_[1] . ':' . $_[2]->{title}->string ]
}
)->apply($doc, 'html');
is_deeply $doc->content->[1], Para [ Str 'html:test' ], 'format and metadata';
}
# TODO: should croak because 1 is no selector ( 1 => sub { } )
# eval { Pandoc::Filter->new( 1 ) }; ok $@, 'invalid filter';
my $doc = Document {}, [ Str "hello" ];
my $filter = Pandoc::Filter->new(sub {
return if $_->name ne 'Str';
$_->{c} = uc $_->{c};
return [ $_, Str " world!" ];
});
$filter->apply($doc);
is_deeply $doc->content, [ Str('HELLO'), Str(' world!') ], "don't filter injected elements";
done_testing;
walker.t 100644 001750 001750 4144 13050301451 15165 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Walker;
use Pandoc::Filter;
use Pandoc::Elements qw(Str Space pandoc_json);
sub load {
local (@ARGV, $/) = ('t/documents/example.json');
pandoc_json(<>);
}
my $doc = load();
my $LINKS = [qw(
http://example.org/
image.png
http://example.com/
)];
sub urls {
return unless ($_->name eq 'Link' or $_->name eq 'Image');
return $_->target->[0];
};
my $links = query $doc, \&urls;
is_deeply $links, $LINKS, 'query( action )';
is_deeply $doc->query(\&urls), $LINKS, '->query';
$links = query $doc, 'Link|Image' => sub { $_->target->[0] };
is_deeply $links, $LINKS, 'query( name => action )';
sub links {
return unless ($_->name eq 'Link' or $_->name eq 'Image');
push @$links, $_->url;
}
{
$links = [ ];
walk $doc, \&links;
is_deeply $links, $LINKS, 'walk(sub)';
}
{
$links = [ ];
$doc->walk(\&links);
is_deeply $links, $LINKS, '->walk';
}
{
$links = [ ];
walk $doc, Pandoc::Filter->new(\&links);
is_deeply $links, $LINKS, 'walk(Filter)';
}
transform $doc, sub {
return ($_->name eq 'Link' ? [] : ());
};
is_deeply query($doc,\&urls), ['image.png'], 'transform, remove elements';
sub escape_links {
my ($e) = @_;
return unless $e->name eq 'Link';
my $a = [ Str "<", @{$e->content}, Str ">" ];
return $a;
}
$doc = load();
transform $doc, \&escape_links;
is scalar @{ query($doc, \&urls) }, 1, 'transform, escaped links';
$doc = load();
$doc->transform(\&escape_links);
is scalar @{ query($doc, \&urls) }, 1, '->transform, escaped links';
my $header = $doc->content->[0]->content;
is_deeply $header, [
Str 'Example', Space, Str '<', Str 'http://example.org/', Str '>', Str '!'
], 'transform, multiple elements';
$doc = load();
transform $doc, sub {
my $e = shift;
return unless $e->name eq 'Header';
$e->transform(\&escape_links);
};
is scalar @{ query($doc, \&urls) }, 2, 'nested transformation';
#SKIP: {
# $header = $doc->content->[0];
# $header->transform(sub {
# return unless $_[0]->name eq 'Header';
# return Para $_[0]->[0]->content;
# });
#}
done_testing;
outline.t 100644 001750 001750 3057 13050301451 15361 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use 5.010;
use Test::More;
use Pandoc::Elements;
use Pandoc;
plan skip_all => 'pandoc >= 1.12.1 not available'
unless (pandoc and pandoc->version > '1.12.1');
my $doc = pandoc->file('t/documents/outline.md');
my $outline = $doc->outline;
sub simplify {
my $o = shift;
$o->{header} //= Header 0, {}, [ Str '' ];
[
('#' x $o->{header}->level . ' ' . $o->{header}->string),
join(' / ', map { $_->string } @{$o->{blocks}}),
[ map { simplify($_) } @{$o->{sections}} ]
]
}
is_deeply simplify($doc->outline),
[
' ', 'test document',
[
[
'## section 0.1', '', [
[ '### section 0.1.1', '', [] ]
]
],
[ '# chapter 1', 'with / content', [] ],
[
'# chapter 2', '',
[
[ '## section 2.1', '', [] ],
[
'## section 2.2', 'text',
[
[ '#### subsubsection 2.2.1.1.1', '', [] ],
[ '### subsubsection 2.2.2', '', [] ]
]
]
]
],
[ '# chapter 3', 'header in table', [] ],
[ '# chapter 4', '', [] ]
]
], 'outline()';
is_deeply simplify($doc->outline(2)),
[
' ', 'test document', [
[ '## section 0.1', 'section 0.1.1', [] ],
[ '# chapter 1', 'with / content', [] ],
[
'# chapter 2', '',
[
[ '## section 2.1', '', [] ],
[
'## section 2.2',
'text / subsubsection 2.2.1.1.1 / subsubsection 2.2.2', []
]
]
],
[ '# chapter 3', 'header in table', [] ],
[ '# chapter 4', '', [] ]
]
], 'outline(2)';
done_testing;
Makefile 100644 001750 001750 140 13050301451 15313 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/xt index.html: ../lib/Pandoc/Elements.pm
perl -I../lib ../script/pod2pandoc $< -s -S --toc -o $@
citation.t 100644 001750 001750 633 13050301451 15471 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
my $c = citation {
id => 'foo',
prefix => [ Str "see" ],
suffix => [ Str "p.", Space, Str "42" ]
};
is_deeply $c, {
citationId => 'foo',
citationHash => 1,
citationMode => NormalCitation,
citationNoteNum => 0,
citationPrefix => [ Str "see" ],
citationSuffix => [ Str "p.", Space, Str "42" ],
};
done_testing;
document.t 100644 001750 001750 10522 13050301451 15533 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More 0.96; # subtests
use Test::Exception;
use Pandoc::Elements;
use JSON qw( decode_json );
use utf8;
sub list2content {
my @content = map { Str( $_ ), Space } @_;
pop @content; # remove trailing space
return \@content;
}
sub doc_meta() {
{ title => MetaInlines( [Plain [ Str 'A', SoftBreak, Str 'message' ] ] ) }
}
sub doc_blocks() {
[ Header( 1, attributes {}, list2content qw[Hej Världen!] ),
Para list2content qw[Hur mår du idag?] ]
}
my %data = (
1.16 => [
'meta, blocks, api_version' => [
doc_meta, doc_blocks, api_version => '1.16'
],
'[ { unMeta => meta }, blocks' => [
[ { unMeta => doc_meta }, doc_blocks ]
],
'{ meta =>, blocks =>, pandoc-api-version }' => [
{
meta => doc_meta,
blocks => doc_blocks,
'pandoc-api-version' => [ 1, 16 ],
}
],
],
1.17 => [
'meta, blocks' => [
doc_meta, doc_blocks,
],
'meta, blocks, api_version =>' => [
doc_meta,
doc_blocks,
api_version => '1.17',
],
'{ meta =>, blocks => }' => [
{ meta => doc_meta, blocks => doc_blocks }
],
'{ meta =>, blocks =>, pandoc-api-version => }' => [
{ meta => doc_meta,
blocks => doc_blocks,
'pandoc-api-version' => [ 1, 17 ],
}
],
],
);
my %json = (
'1.17' => '{"blocks":[{"c":[1,["",[],[]],[{"c":"Hej","t":"Str"},{"c":[],"t":"Space"},{"c":"V\u00e4rlden!","t":"Str"}]],"t":"Header"},{"c":[{"c":"Hur","t":"Str"},{"c":[],"t":"Space"},{"c":"m\u00e5r","t":"Str"},{"c":[],"t":"Space"},{"c":"du","t":"Str"},{"c":[],"t":"Space"},{"c":"idag?","t":"Str"}],"t":"Para"}],"meta":{"title":{"c":[{"c":[{"c":"A","t":"Str"},{"c":[],"t":"SoftBreak"},{"c":"message","t":"Str"}],"t":"Plain"}],"t":"MetaInlines"}},"pandoc-api-version":[1,17]}',
'1.16' => '[{"unMeta":{"title":{"c":[{"c":[{"c":"A","t":"Str"},{"c":[],"t":"SoftBreak"},{"c":"message","t":"Str"}],"t":"Plain"}],"t":"MetaInlines"}}},[{"c":[1,["",[],[]],[{"c":"Hej","t":"Str"},{"c":[],"t":"Space"},{"c":"V\u00e4rlden!","t":"Str"}]],"t":"Header"},{"c":[{"c":"Hur","t":"Str"},{"c":[],"t":"Space"},{"c":"m\u00e5r","t":"Str"},{"c":[],"t":"Space"},{"c":"du","t":"Str"},{"c":[],"t":"Space"},{"c":"idag?","t":"Str"}],"t":"Para"}]]',
'1.12.3' => '[{"unMeta":{"title":{"c":[{"c":[{"c":"A","t":"Str"},{"c":[],"t":"Space"},{"c":"message","t":"Str"}],"t":"Plain"}],"t":"MetaInlines"}}},[{"c":[1,["",[],[]],[{"c":"Hej","t":"Str"},{"c":[],"t":"Space"},{"c":"V\u00e4rlden!","t":"Str"}]],"t":"Header"},{"c":[{"c":"Hur","t":"Str"},{"c":[],"t":"Space"},{"c":"m\u00e5r","t":"Str"},{"c":[],"t":"Space"},{"c":"du","t":"Str"},{"c":[],"t":"Space"},{"c":"idag?","t":"Str"}],"t":"Para"}]]',
);
foreach (keys %json) {
$json{$_} = JSON->new->utf8->canonical->convert_blessed->encode( decode_json $json{$_} );
}
# create a document and check whether it equals to expected result
sub test_document(@) {
my ($args, $expect, $json, $message) = @_;
subtest $message => sub {
my $doc = Document @$args;
isa_ok $doc, 'Pandoc::Document', '$doc';
is_deeply $doc, $expect, 'expected';
is $doc->to_json, $json, 'to_json';
};
}
foreach my $api_version ( qw[ 1.16 1.17 ] ) {
subtest $api_version => sub {
my $expect = pandoc_json $json{$api_version};
is $expect->api_version, $api_version, 'api_version';
my @variants = @{ $data{$api_version} };
while (@variants) {
my ($name, $args) = splice @variants, 0, 2;
test_document $args, $expect, $json{$api_version}, $name;
}
};
}
subtest '1.12.3' => sub {
my $expect = Document pandoc_json($json{1.16});
$expect->api_version('1.12.3');
my $args = [ doc_meta, doc_blocks, api_version => '1.12.3' ];
test_document $args, $expect, $json{'1.12.3'}, 'api_version = 1.12.3';
};
throws_ok { Document doc_meta, doc_blocks, api_version => '1.12.1' }
qr{^api_version must be >= 1\.12\.3}, 'minimum api_version';
throws_ok { Document doc_meta, doc_blocks, '1.17.0.4' }
qr{Document: too many or ambiguous arguments}, 'invalid arguments';
throws_ok { Document 'hello' }
qr{expect array or hash reference}, 'invalid arguments';
done_testing;
elements.t 100644 001750 001750 1727 13050301451 15520 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements qw(Emph Str attributes element);
use JSON;
is_deeply [ Str 'hello' ],
[ { t => 'Str', c => 'hello' } ], 'Emph';
is_deeply [ Str 'hello', 'world' ],
[ { t => 'Str', c => 'hello' }, 'world' ], 'Emph';
is_deeply [ Emph Str 'hello' ],
[ { t => 'Emph', c => { t => 'Str', c => 'hello' } } ], 'Emph';
my $code = element( Code => attributes {}, 'x' );
is_deeply $code, { t => 'Code', c => [["",[],[]],"x"] }, 'element';
ok $code->is_inline, 'is_inline';
is_deeply $code->content, 'x', 'content';
eval { element ( Foo => 'bar' ) }; ok $@, 'unknown element';
eval { element ( Code => 'x' ) }; ok $@, 'wrong number of arguments';
is_deeply decode_json(Str('今日は')->to_json),
{ t => 'Str', c => '今日は' }, 'method to_json';
my $ast = element ( Header => 6, attributes { foo => 6 }, Str 6 );
is_deeply [ $ast->to_json =~ /(.6.)/g ], [ '[6,', '"6"', '"6"',], 'stringify numbers';
done_testing;
example.md 100644 001750 001750 127 13050301451 15445 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t # Section with *ÄÖÜ* and [link](http://example.org/)
## Subsection with **äöü**
metadata.t 100644 001750 001750 3043 13050301451 15455 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More 0.96;
use Pandoc::Elements;
use Scalar::Util qw[ blessed reftype ];
# MetaBool
my $doc = pandoc_json(<meta->{true}->content, 'true';
ok !$doc->meta->{false}->content, 'false';
foreach (1, '1', 'true', 'TRUE', 42, 'wtf') {
my $m = MetaBool($_);
ok $m->content;
is '{"c":true,"t":"MetaBool"}', $m->to_json, "true: $_";
}
foreach (0, '', 'false', 'FALSE', undef) {
my $m = MetaBool($_);
ok !$m->content;
is '{"c":false,"t":"MetaBool"}', $m->to_json, "false: $_";
}
# MetaString
is $doc->meta->{string}->content, "hello\nworld";
is $doc->meta->{string}->metavalue, "hello\nworld";
# MetaInlines
{
my $m = MetaInlines [ Str "foo" ];
is '{"c":[{"c":"foo","t":"Str"}],"t":"MetaInlines"}',
$m->to_json, 'MetaInlines';
}
# metavalue
is_deeply $doc->metavalue,
{ false => 0, true => 1, string => "hello\nworld", blocks => [ "x", "y" ] },
'metavalue';
# Stringify/bless
my $doc = do {
local (@ARGV, $/) = ('t/documents/meta.json');
pandoc_json(<>);
};
# note explain $doc->metavalue;
is_deeply { map { $_ => $doc->metavalue($_) } keys %{$doc->meta} },
$doc->metavalue, 'Document->metavalue';
done_testing;
synopsis.t 100644 001750 001750 2631 13050301451 15566 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
use JSON;
# Use Test::Deep because it handles blessed structures
# with overloaded stringification correctly.
BEGIN {
plan skip_all => 'Test::Deep not available' unless eval 'require Test::Deep; 1;';
Test::Deep->import( qw[cmp_deeply noclass] );
}
my $ast = Document {
title => MetaInlines [ Str 'Greeting' ]
}, [
Header( 1, attributes { id => 'de' }, [ Str 'Gruß' ] ),
Para [ Str 'hello, world!' ],
], api_version => '1.17.0.4';
# note explain $ast->TO_JSON;
cmp_deeply $ast, noclass { 'blocks' => [
{ 'c' => [ 1, [ 'de', [], [] ], [ { 'c' => 'Gruß', 't' => 'Str' } ] ],
't' => 'Header'
},
{ 'c' => [ { 'c' => 'hello, world!', 't' => 'Str' } ], 't' => 'Para' }
],
'meta' => {
'title' =>
{ 'c' => [ { 'c' => 'Greeting', 't' => 'Str' } ], 't' => 'MetaInlines' }
},
'pandoc-api-version' => [ 1, 17, 0, 4 ]
};
my $json = JSON->new->utf8->convert_blessed->encode($ast);
cmp_deeply decode_json($json), noclass($ast), 'encode/decode JSON';
cmp_deeply Pandoc::Elements::pandoc_json($json), noclass($ast), 'pandoc_json';
$json = $ast->to_json;
cmp_deeply decode_json($json), noclass($ast), 'to_json';
eval { Pandoc::Elements->pandoc_json(".") };
like $@, qr{.+at.+synopsis.*\.t}, 'error in pandoc_json';
done_testing;
__DATA__
% Greeting
# Gruß {.de}
hello, world!
README.md 100644 001750 001750 656 13050301451 15146 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/xt This directory contains tests to run with multiple versions of pandoc
executable.
Script `get-pandoc-releases.pl` downloads all available binary releases of
pandoc (limited to Debian 64bit) and stores them in subdirectory `bin`:
$ perl -Ilib xt/get-pandoc-releases.pl
Then run all or selected tests with all or selected pandoc releases:
$ ./xt/prove
$ ./xt/prove '>=1.17'
$ ./xt/prove '>=1.17' t/stringify.t
accessors.t 100644 001750 001750 3462 13050301451 15667 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
my $e = CodeBlock attributes { class => ['perl'], id => 2 }, 'say "Hi";';
is_deeply $e->attr, $e->{c}->[0], 'CodeBlock->attr';
is $e->id, '2', 'AttributeRole->id';
is $e->class, 'perl', 'AttributeRole->class';
is $e->content, 'say "Hi";', 'CodeBlock->content';
is $e->content('foo'), 'foo', 'setter';
is $e->content, 'foo', 'setter';
$e = Quoted SingleQuote, 'x';
is $e->type->name, 'SingleQuote', 'Quoted';
{
my $e = BulletList [];
is_deeply $e->items, [], 'BulletList: items';
my $items = [ [ Plain Str 'foo' ] ];
is_deeply $e->content($items), $items, 'BulletList: content(...)';
is_deeply $e->items, $items, 'BulletList: items set';
}
{
my $content = 'a';
my $attr = attributes {};
my $e = Span $attr, $content;
is_deeply $e->attr, $attr, 'Span: attr';
$attr = attributes { a => 1 };
is_deeply $e->attr($attr), $attr, 'Span: attr(...)';
is_deeply $e->attr, $attr, 'Span: attr set';
is_deeply $e->content, 'a', 'Span: content';
is_deeply $e->content('b'), 'b', 'Span: content(...)';
is_deeply $e->content, 'b', 'Span: content set';
}
{
my $e = DefinitionList [
[ [ Str 'term 1' ],
[ [ Para Str 'definition 1' ] ] ],
[ [ Str 'term 2' ],
[ [ Para Str 'definition 2' ],
[ Para Str 'definition 3' ] ] ],
];
is_deeply $e->items, $e->content, 'DefinitionList: items=content';
is scalar @{$e->items}, 2, 'DefinitionList->items';
is_deeply $e->items->[0]->term, [ Str 'term 1' ], '...->term';
is_deeply $e->items->[1]->definitions->[1],
[ Para Str 'definition 3' ], '...->definitions';
}
{
my $doc = Document { foo => 1 }, [];
note explain $doc->to_json;
is_deeply $doc->meta->value, { foo => 1 }, 'Document: meta';
$doc->meta({ bar => 0 });
is_deeply $doc->meta->value, { bar => 0 }, 'Document: meta(...)';
}
done_testing;
example.tex 100644 001750 001750 167 13050301451 15651 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t \section{Section with \emph{ÄÖÜ} and \href{http://example.org/}{link}}
\subsection{Subsection with \textbf{äöü}}
lineblock.t 100644 001750 001750 2135 13050301451 15640 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
use JSON;
# internal representation
my $lineblock = LineBlock [ [ Str " foo"], [ Str "bar"], [ Str " baz"], ];
ok $lineblock->is_block, 'is_block';
{
local $Pandoc::Elements::PANDOC_VERSION = '1.16';
my $expect = {
t => 'Para',
c => [
{ 'c' => "\x{a0}\x{a0}foo", 't' => 'Str' },
{ 'c' => [], 't' => 'LineBreak' },
{ 'c' => "bar", 't' => 'Str' },
{ 'c' => [], 't' => 'LineBreak' },
{ 'c' => "\x{a0}baz", 't' => 'Str' }
]
};
is_deeply $expect, decode_json($lineblock->to_json), 'PANDOC_VERSION < 1.18';
}
{
local $Pandoc::Elements::PANDOC_VERSION = '1.18';
my $expect = {
t => 'LineBlock',
c => [
[ { 'c' => "\x{a0}\x{a0}foo", 't' => 'Str' } ],
[ { 'c' => "bar", 't' => 'Str' } ],
[ { 'c' => "\x{a0}baz", 't' => 'Str' } ]
]
};
is_deeply $expect, decode_json($lineblock->to_json), 'PANDOC_VERSION >= 1.18';
}
done_testing;
softbreak.t 100644 001750 001750 2352 13050301451 15657 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements qw(pandoc_json Space);
my $json_in = ;
my $ast = pandoc_json( $json_in );
is $ast->string,
'Dolorem sapiente ducimus quia beatae sapiente perspiciatis quia. Praesentium est cupiditate architecto temporibus eos.',
'replaced SoftBreak with spaces';
$Pandoc::Elements::PANDOC_VERSION = '1.16';
like $ast->to_json, qr/"SoftBreak"/, 'keep SoftBreak by default';
$Pandoc::Elements::PANDOC_VERSION = '1.15';
unlike $ast->to_json, qr/"SoftBreak"/, 'no SoftBreak in modified ast';
done_testing;
__DATA__
[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"Dolorem"},{"t":"Space","c":[]},{"t":"Str","c":"sapiente"},{"t":"Space","c":[]},{"t":"Str","c":"ducimus"},{"t":"Space","c":[]},{"t":"Str","c":"quia"},{"t":"SoftBreak","c":[]},{"t":"Str","c":"beatae"},{"t":"Space","c":[]},{"t":"Str","c":"sapiente"},{"t":"Space","c":[]},{"t":"Str","c":"perspiciatis"},{"t":"Space","c":[]},{"t":"Str","c":"quia."},{"t":"SoftBreak","c":[]},{"t":"Str","c":"Praesentium"},{"t":"Space","c":[]},{"t":"Str","c":"est"},{"t":"Space","c":[]},{"t":"Str","c":"cupiditate"},{"t":"SoftBreak","c":[]},{"t":"Str","c":"architecto"},{"t":"Space","c":[]},{"t":"Str","c":"temporibus"},{"t":"Space","c":[]},{"t":"Str","c":"eos."}]}]]
stringify.t 100644 001750 001750 2011 13050301451 15705 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
my $doc = Document { }, [
Header(1,attributes {},[ Str 'hello', Code attributes {}, ', ' ]),
BulletList [ [ Plain [ Str 'world', Space, Str '!' ] ] ],
];
$doc->meta->{foo} = MetaInlines [ Emph [ Str "FOO" ] ];
$doc->meta->{bar} = MetaString "BAR";
$doc->meta->{doz} = MetaMap { x => MetaList [ MetaInlines [ Str "DOZ" ] ] };
is $doc->meta->{foo}->string, 'FOO', 'stringify MetaInlines';
is $doc->meta->{bar}->string, 'BAR', 'stringify MetaString';
is $doc->meta->{doz}->string, 'DOZ', 'stringify MetaMap>MetaList>MetaInlines';
is $doc->string, 'hello, world !', 'stringify Document with metadata';
is LineBreak->string, ' ', 'LineBreak to space';
is RawBlock('html','hi')->string, '', 'RawBlock has no string';
is RawInline('html','hi')->string, '', 'RawInline has no string';
is Code(attributes {},'#!$')->string, '#!$', 'Code has string';
is CodeBlock({}, 'Hi')->string, 'Hi', 'CodeBlock has string';
done_testing;
__DATA__
# hello`,`
* world !
to_pandoc.t 100644 001750 001750 1353 13050301451 15645 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use 5.010;
use Test::More;
use Pandoc::Elements;
use Pandoc;
use File::Temp;
plan skip_all => 'pandoc >= 1.12.1 not available'
unless (pandoc and pandoc->version > '1.12.1');
my $doc = pandoc->file('t/documents/outline.md');
{
my $html = $doc->to_pandoc( '-t' => 'html' );
ok $html =~ qr{^
test document
}, 'to_pandoc';
}
{
my $html = $doc->to_pandoc( '-t' => 'html', '--standalone' );
ok $html =~ qr{^to_markdown, $doc->to_pandoc( '-t' => 'markdown' ), 'to_markdown';
}
{
my $to_latex = new_ok Pandoc => [ '-t' => 'latex' ], 'to-latex-object';
is $doc->to_pandoc( $to_latex ), $doc->to_latex,'to latex with custom Pandoc';
}
done_testing;
versions.t 100644 001750 001750 333 13050301451 15714 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/xt use strict;
use Test::More;
use lib 'xt/lib';
use Pandoc::Releases;
foreach my $pandoc (pandoc_releases) {
my $version = $pandoc->version;
is $pandoc->bin, "xt/bin/$version/pandoc", $version;
}
done_testing;
attributes.t 100644 001750 001750 3743 13050301451 16072 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use v5.10;
use Test::More;
use Pandoc::Elements;
use Hash::MultiValue;
my $attr_hash = { class => [qw(x x y)], answer => 42, id => 0 };
is_deeply attributes {}, [ '', [], [] ], 'empty attributes';
is_deeply attributes(undef), [ '', [], [] ], 'empty attributes (undef)';
is_deeply attributes $attr_hash,
[ '0', [qw(x x y)], [ [ answer => '42' ] ] ], 'classes and id';
my $e = Code attributes {}, '';
is_deeply [], [ $e->keyvals->flatten ], 'empty attributes';
$e = Code attributes $attr_hash, '';
is_deeply [ id => '0', class => 'x x y', answer => '42', ],
[ $e->keyvals->flatten ], 'keyvals';
$e = Code [ '', [], [ [ foo => '1' ], [ bar => '2' ], [ foo => '3' ] ] ], '';
is_deeply [ $e->keyvals->flatten ], [ foo => 1, bar => 2, foo => 3 ], 'keyvals';
$e->keyvals( Hash::MultiValue->new(
foo => 9, id => 0, bar => 8, foo => 7, class => 'a', class => 'b c',
) );
is_deeply
[ '0', [qw(a b c)], [ [ foo => 9 ], [ bar => 8 ], [ foo => 7 ] ] ],
$e->attr, 'attributes via Hash::MultiValue';
$e->keyvals({ foo => 3, class => 'x y' });
is_deeply [ '0', [qw(x y)], [ [ foo => 3 ] ] ], $e->attr, 'keyvals as setter';
$e->keyvals({ });
is_deeply [ '0', [qw(x y)], [ ] ], $e->attr, 'keyvals as setter (no class)';
$e->keyvals( id => undef, class => undef );
is_deeply [ '', [], [ ] ], $e->attr, 'keyvals to remove id and classes';
$e->id(2);
is '2', $e->id, 'id setter';
$e->class('q r', 's ', [qw(x y)]);
is_deeply 'q r s x y', $e->class, 'class setter';
$e->keyvals( a => 1, class => ['s'], a => 2 );
is_deeply [ '2', ['s'], [ [ a => 1 ], [ a => 2 ] ] ], $e->attr, 'keyvals as setter';
my @class_hashes = (
{ class => [qw(foo bar doz)] },
{ class => 'foo bar doz ' },
{ class => " foo\t bar\n doz " },
);
foreach (@class_hashes) {
$e = CodeBlock attributes $_, '';
is_deeply $e->class, 'foo bar doz', 'class(es) attributes';
}
foreach (qw(foo bar doz)) {
ok $e->match(".$_"), 'class match';
}
ok !$e->match('.baz'), 'class selector';
done_testing;
meta-filter.t 100644 001750 001750 1752 13050301451 16113 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use 5.010;
use Test::More;
use Pandoc::Filter;
use Pandoc::Elements;
my $json = '[{"unMeta":{"foo":{"c":[{"c":"bar","t":"Str"}],"t":"MetaInlines"}}},[{"c":[{"c":"doz","t":"Str"}],"t":"Para"}]]';
my $allcaps = '[{"unMeta":{"foo":{"c":[{"c":"BAR","t":"Str"}],"t":"MetaInlines"}}},[{"c":[{"c":"DOZ","t":"Str"}],"t":"Para"}]]';
my $contentcaps = '[{"unMeta":{"foo":{"c":[{"c":"bar","t":"Str"}],"t":"MetaInlines"}}},[{"c":[{"c":"DOZ","t":"Str"}],"t":"Para"}]]';
my $filter = Pandoc::Filter->new( Str => sub { Str(uc $_->content) } );
my $doc = pandoc_json($json);
$doc->transform($filter),
is $doc->to_json, $allcaps, 'transform with metadata element';
$doc = pandoc_json($json);
$filter->apply($doc->content);
is $doc->to_json, $contentcaps, 'apply document content only';
{
open my $stdin, '<', \$json;
local *STDIN = $stdin;
my $doc = pandoc_walk Str => sub { Str(uc $_->content) };
is $doc->to_json, $contentcaps, 'pandoc_walk document content only';
}
done_testing;
multifilter.t 100644 001750 001750 3502 13050301451 16235 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Test::Exception;
use Pandoc::Elements;
use Pandoc::Filter::Multifilter qw(find_filter apply_filter);
use IPC::Cmd 'can_run';
use Pandoc;
# find_filter( ... )
{
my @tests = (
['script/multifilter']
=> ['script/multifilter'], 'absolute path',
['t/pandoc/filters/empty.pl']
=> ['perl', 't/pandoc/filters/empty.pl'], 'known extension',
['perl']
=> [can_run('perl')], 'executable in $PATH',
);
local $ENV{HOME} = 't';
if (-e 't/.pandoc') { # only in git repository
push @tests, (
['empty.pl']
=> ['perl', 't/.pandoc/filters/empty.pl'], 'known extension in DATA_DIR',
['caps']
=> ['t/.pandoc/filters/caps'], 'executable in DATA_DIR',
);
}
while (@tests) {
my @filter = find_filter(@{shift @tests});
is_deeply \@filter, shift @tests, join ' ', 'find_filter: '.shift @tests;
}
my $notfound = '0c9703d020ded30c97682e812636c9ef';
throws_ok { find_filter($notfound) } qr/^filter not found: $notfound/;
}
if ($ENV{RELEASE_TESTING} and pandoc and pandoc->version('1.12')) {
my $in = Document {}, [ Para [ Str 'hi' ] ];
my $out = apply_filter($in, 'html', find_filter('caps','t/pandoc'));
is $out->string, 'HI', 'apply_filter';
throws_ok {
apply_filter($in, 'html', find_filter('empty.pl','t/pandoc'));
} qr{^filter emitted no valid JSON};
if (-e 't/.pandoc') { # only in git repository
$in->meta({ multifilter => MetaList [ MetaInlines [ Str 'caps' ] ] });
local $ENV{HOME} = 't';
Pandoc::Filter::Multifilter->new->apply($in)->to_json;
is $in->string, 'HI', 'apply_filter';
}
} else {
note "Skipping detailed testing of Pandoc::Filter::Multifilter";
}
done_testing;
examples 000755 001750 001750 0 13050301451 14723 5 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 caps.pl 100755 001750 001750 1210 13050301451 16343 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 DESCRIPTION
Pandoc filter to convert all regular text to uppercase.
Code, link URLs, etc. are not affected.
=cut
use Pandoc::Filter;
use Pandoc::Elements qw(Str);
pandoc_filter Str => sub {
return Str(uc $_->content);
# alternatively to modify in-place (comment out previous line to enable)
$_->content(uc($_->content));
return
};
=head1 SYNOPSIS
pandoc --filter caps.pl -o output.html < input.md
=head1 SEE ALSO
This is a port of
L
from Python to Perl with L and L.
=cut
qids.pl 100644 001750 001750 1112 13050301451 16353 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 DESCRIPTION
Pandoc filter to link all Wikidata ids such as C<[Q123]>
=cut
use Pandoc::Filter;
use Pandoc::Elements;
pandoc_filter Str => sub {
my @split = split /\[([QP][0-9]+)\]/, $_->content;
return if @split < 2;
my @inlines;
while (@split) {
my $str = shift @split;
push @inlines, Str($str) if $str ne '';
my $id = shift @split or last;
my $url = "http://www.wikidata.org/entity/$id";
push @inlines, Link attributes {}, [ Str $id ], [ $url, '' ];
}
return \@inlines;
};
scalar-types.t 100644 001750 001750 6301 13050301451 16304 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements qw(pandoc_json);
use JSON qw(decode_json);
# deliberately erroneous,
# i.e. pandoc should choke on it unless the appropriate
# TO_JSON methods have done their magic on it!
my $bad_json = <<'JSON';
[{"unMeta":{"MetaBool":{"t":"MetaBool","c":true}}},[{"t":"Header","c":["1",["heading",[],[]],[{"t":"Str","c":"Heading"},{"c":[],"t":"Space"}]]},{"t":"Para","c":[{"c":[[{"citationMode":{"t":"NormalCitation","c":[]},"citationPrefix":[{"c":"citation","t":"Str"}],"citationSuffix":[{"c":[],"t":"Space"},{"c":"p.","t":"Str"},{"c":[],"t":"Space"},{"c":13,"t":"Str"}],"citationId":"author2015","citationNoteNum":"0","citationHash":"0"}],[{"t":"Str","c":"[citation"},{"t":"Space","c":[]},{"c":"@author2015","t":"Str"},{"t":"Space","c":[]},{"c":"p.","t":"Str"},{"c":[],"t":"Space"},{"c":"13]","t":"Str"}]],"t":"Cite"},{"c":",","t":"Str"},{"c":[],"t":"Space"}]},{"t":"OrderedList","c":[["2",{"t":"Decimal","c":[]},{"t":"OneParen","c":[]}],[[{"t":"Plain","c":[{"c":"#1=2","t":"Str"},{"t":"Space","c":[]}]}],[{"c":[{"t":"Str","c":"#2=3"}],"t":"Plain"}]]]},{"t":"Table","c":[[{"t":"Str","c":"Table"},{"t":"Space","c":[]}],[{"t":"AlignLeft","c":[]},{"t":"AlignLeft","c":[]},{"t":"AlignLeft","c":[]}],["0","0","0"],[[{"t":"Plain","c":[{"t":"Str","c":"M."}]}],[{"t":"Plain","c":[{"t":"Str","c":"F."}]}],[{"c":[{"t":"Str","c":"N."}],"t":"Plain"}]],[[[{"c":[{"t":"Str","c":"hic"}],"t":"Plain"}],[{"c":[{"c":"haec","t":"Str"}],"t":"Plain"}],[{"c":[{"c":"hoc","t":"Str"}],"t":"Plain"}]]]]}]]
JSON
my $good_json = <<'JSON';
[{"unMeta":{"MetaBool":{"c":true,"t":"MetaBool"}}},[{"t":"Header","c":[1,["heading",[],[]],[{"c":"Heading","t":"Str"},{"t":"Space","c":[]}]]},{"t":"Para","c":[{"t":"Cite","c":[[{"citationHash":0,"citationSuffix":[{"c":[],"t":"Space"},{"c":"p.","t":"Str"},{"c":[],"t":"Space"},{"c":"13","t":"Str"}],"citationId":"author2015","citationPrefix":[{"t":"Str","c":"citation"}],"citationNoteNum":0,"citationMode":{"c":[],"t":"NormalCitation"}}],[{"t":"Str","c":"[citation"},{"c":[],"t":"Space"},{"c":"@author2015","t":"Str"},{"c":[],"t":"Space"},{"t":"Str","c":"p."},{"c":[],"t":"Space"},{"t":"Str","c":"13]"}]]},{"c":",","t":"Str"},{"t":"Space","c":[]}]},{"t":"OrderedList","c":[[2,{"c":[],"t":"Decimal"},{"t":"OneParen","c":[]}],[[{"t":"Plain","c":[{"t":"Str","c":"#1=2"},{"c":[],"t":"Space"}]}],[{"c":[{"t":"Str","c":"#2=3"}],"t":"Plain"}]]]},{"t":"Table","c":[[{"t":"Str","c":"Table"},{"c":[],"t":"Space"}],[{"c":[],"t":"AlignLeft"},{"c":[],"t":"AlignLeft"},{"t":"AlignLeft","c":[]}],[0,0,0],[[{"c":[{"t":"Str","c":"M."}],"t":"Plain"}],[{"c":[{"c":"F.","t":"Str"}],"t":"Plain"}],[{"t":"Plain","c":[{"c":"N.","t":"Str"}]}]],[[[{"t":"Plain","c":[{"c":"hic","t":"Str"}]}],[{"c":[{"t":"Str","c":"haec"}],"t":"Plain"}],[{"c":[{"c":"hoc","t":"Str"}],"t":"Plain"}]]]]}]]
JSON
my $document = eval { pandoc_json( $bad_json ) };
my $error = $@;
is $error, "", 'no error reading "bad" JSON';
isa_ok $document, 'Pandoc::Document';
is_deeply decode_json($good_json), $document->TO_JSON, 'fixed JSON';
# IPC::Run3::run3( [pandoc => -f => 'json', -t => 'markdown'], \$json, \my $stdout, \my $stderr );
# is $stderr, "", 'no errors feeding JSON to pandoc' or note $stderr;
# note $document->to_json;
# note $stdout;
done_testing;
pod2pandoc.pl 100644 001750 001750 477 13050301451 16256 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/xt use strict;
use Test::More;
use File::Basename;
use lib 'xt/lib';
use Pandoc::Releases;
my $PATH = $ENV{PATH};
foreach my $pandoc (pandoc_releases) {
note $pandoc->bin;
local $ENV{PATH} = dirname($pandoc->bin).":$PATH";
system 'perl -Ilib script/pod2pandoc script/pod2pandoc -o tmp.md';
}
done_testing;
ditaa.pl 100644 001750 001750 1142 13050301451 16500 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
use Pandoc::Filter;
use Pandoc::Filter::ImagesFromCode;
pandoc_filter 'CodeBlock.ditaa' => Pandoc::Filter::ImagesFromCode->new(
from => 'ditaa',
to => 'png',
# TODO: support use of dita-eps for vector images
run => ['ditaa', '-o', '$infile$', '$outfile$'],
);
__END__
=head1 NAME
ditaa - process code blocks with C<.ditaa> into images
=head1 SYNOPSIS
pandoc --filter ditaa.pl -o output.html < input.md
=head1 SEE ALSO
This is a rewrite of the standalone-script C originally published at
L.
=cut
meta-blessing.t 100644 001750 001750 3272 13050301451 16433 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More 0.96;
use Pandoc::Elements;
use Scalar::Util qw[ blessed reftype ];
my $document = do {
local (@ARGV, $/) = ('t/documents/meta.json');
pandoc_json(<>);
};
isa_ok $document, 'Pandoc::Document', "it's a document" or note ref $document;
my $unblessed_counts = bless_check_loop($document->meta);
ok !keys(%$unblessed_counts), 'no unblessed metadata objects'
or note "There were some unblessed metadata objects:\n", explain $unblessed_counts;
my $undef_count = undef_check_loop( $document->meta );
ok !$undef_count, 'no undef values' or note "There were $undef_count undefined values";
sub bless_check_loop {
my @data = @_;
my %counts;
LOOP:
for ( my $i = 0; $i <= @data; $i++ ) {
my $item = $data[$i];
next LOOP unless reftype $item;
if ( 'ARRAY' eq reftype $item ) {
push @data, grep { reftype $_ } @$item;
}
elsif ( 'HASH' eq reftype $item ) {
if ( $item->{t} ) {
++$counts{$item->{t}} unless blessed $item;
}
push @data, grep { reftype $_ } values %$item;
}
}
return \%counts;
}
sub undef_check_loop {
my @data = @_;
my $count;
LOOP:
for ( my $i = 0; $i <= @data; $i++ ) {
my $item = $data[$i];
next LOOP unless reftype $item;
if ( 'ARRAY' eq reftype $item ) {
$count += grep { !defined($_) } @$item;
push @data, grep { reftype $_ } @$item;
}
elsif ( 'HASH' eq reftype $item ) {
$count += grep { !defined($_) } values %$item;
push @data, grep { reftype $_ } values %$item;
}
}
return $count;
}
done_testing;
__DATA__
pandoc_filter.t 100644 001750 001750 2210 13050301451 16501 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use Test::More;
use Pandoc::Filter;
use Pandoc::Elements;
use JSON;
use Encode;
use Test::Output;
# FIXME: don't require decode_utf8 (?)
my $ast = Pandoc::Elements::pandoc_json(
'{"blocks":[{"t":"Para","c":[{"t":"Str","c":"☃"}]}]}'
)->blocks->[0]->content->[0];
is_deeply $ast, { t => 'Str', c => decode_utf8("☃") }, 'JSON with Unicode';
Pandoc::Filter->new()->apply($ast);
is_deeply $ast, { t => 'Str', c => decode_utf8("☃") }, 'identity filter';
sub shout {
return unless $_[0]->name eq 'Str';
return Str($_[0]->content.'!');
}
# FIXME: cannot directly filter root element
$ast = [$ast];
Pandoc::Filter->new(\&shout)->apply($ast);
is_deeply $ast, [{ t => 'Str', c => "\x{2603}!" }], 'applied filter';
{
local *STDIN = *DATA;
my $data_start = tell DATA;
stdout_like(sub {
pandoc_filter( \&shout )
}, qr/"c":"☃!"/, 'pandoc_filter (sub)');
seek DATA, $data_start, 0;
stdout_like(sub {
pandoc_filter( Str => sub { Str($_[0]->content.'!') } )
}, qr/"c":"☃!"/, 'pandoc_filter (hash)');
}
done_testing;
__DATA__
[{"unMeta":{}},[{"t":"Para","c":[{"t":"Str","c":"☃"}]}]]
deemph.pl 100755 001750 001750 1026 13050301451 16664 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 DESCRIPTION
Pandoc filter that causes emphasized text to be displayed in ALL CAPS.
=cut
use Pandoc::Filter;
use Pandoc::Elements qw(Str);
pandoc_filter Emph => sub {
$_->transform( Str => sub { Str(uc($_->content)) });
};
=head1 SYNOPSIS
pandoc --filter deemph.pl -o output.html < input.md
=head1 SEE ALSO
This is a port of
L
from Python to Perl with L and L.
=cut
myemph.pl 100644 001750 001750 1411 13050301451 16714 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 NAME
myemph - use C<\myemp{...}> instead of C<\emph{...}> in LaTeX
=head1 DESCRIPTION
Pandoc filter that causes emphasized text to be rendered using the custom macro
C<\myemph{...}> rather than C<\emph{...}> in LaTeX. Other output formats are
unaffected.
=cut
use Pandoc::Filter;
use Pandoc::Elements;
pandoc_filter Emph => sub {
my ($e, $f, $m) = @_;
return if $f ne 'latex';
[ RawInline(latex => '\myemph{'), @{$e->content}, RawInline(latex => '}') ]
};
=head1 SYNOPSIS
pandoc --filter myemph.pl -o output.html < input.md
=head1 SEE ALSO
This is a port of
L
from Python to Perl with L and L.
=cut
script 000755 001750 001750 0 13050301451 14411 5 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33 multifilter 100755 001750 001750 1563 13050301451 17044 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/script #!/usr/bin/env perl
use strict;
use v5.10;
=head1 NAME
multifilter - Pandoc filter to apply filters listed in field C
=head1 DESCRIPTION
This Pandoc filter applies other filters listed in document metadata field
C. The filters can be specified like with pandoc option C<-F> or
C<--filter>. For instance C:
---
filters:
- filter1 # in $PATH or ~/.pandoc/filters
- ./filter2.pl # relative path
- /path/filter3 # absolute path
...
converted via
pandoc --filter multifilter input.md
will be filtered like
pandoc -F filter1 -F ./filter2.pl -F /path/filter3 input.md
In addition, filters are searched in C<~/.pandoc/filters>.
=head1 OPTIONS
=over
=item --help|-h
Print this help
=back
=cut
use Pandoc::Filter;
use Pandoc::Filter::Multifilter;
pandoc_filter_document( Pandoc::Filter::Multifilter->new );
pandoc-version.t 100644 001750 001750 1021 13050301451 16616 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Test::Exception;
local $ENV{PANDOC_VERSION} = '1.2.3';
require Pandoc::Elements;
is Pandoc::Elements::pandoc_version(), '1.2.3', 'pandoc_version from ENV';
Pandoc::Elements->import('pandoc_version');
$Pandoc::Elements::PANDOC_VERSION = 1.3;
is pandoc_version(), '1.3', 'set pandoc_version via variable';
{
local $Pandoc::Elements::PANDOC_VERSION = undef;
is pandoc_version(), '1.19', 'maximum supported version';
}
is pandoc_version(), '1.3', 'localize PANDOC_VERSION';
done_testing;
deflist.pl 100755 001750 001750 1504 13050301451 17055 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 NAME
deflist - convert definiton lists to bullet lists
=head1 DESCRIPTION
Pandoc filter to convert definition lists to bullet lists with the defined
terms in strong emphasis (for compatibility with standard markdown).
=cut
use Pandoc::Filter qw(pandoc_filter);
use Pandoc::Elements qw(BulletList Para Strong Str);
pandoc_filter DefinitionList => sub {
BulletList [ map { to_bullet($_) } @{ $_->items } ]
};
sub to_bullet {
my $item = shift;
[ Para [ Strong $item->term ], map { @$_} @{$item->definitions} ]
}
=head1 SYNOPSIS
pandoc --filter deflist.pl -o output.html < input.md
=head1 SEE ALSO
This is a port of
L
from Python to Perl with L and L.
=cut
section.pl 100644 001750 001750 1762 13050301451 17072 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 NAME
section - select document sections
=head1 SYNOPSIS
section --select-id foo --select-class bar --select-name "the title"
section --select '#foo' --select .bar --select '"the title"'
=cut
use Pandoc::Filter;
=head1 DESCRIPTION
---
multifilter:
- filter: section
- options:
- select: .keep
...
=cut
# TODO: get options
my @select = ('.keep'); # TODO: use Pandoc::Element::Selector;
my $level = 0;
# process all elements
pandoc_filter sub {
my $e = shift;
if ($level > 0) {
if ($_->name eq 'Header' and $e->level <= $level) {
$level = 0; # end of currently selected section
} else {
return; # keep element in selected section
}
}
if ($e->name eq 'Header' and grep { $e->match($_) } @select ) {
$level = $e->level; # new selected section
return; # keep Header
} else {
return []; # skip
}
};
theorem.pl 100644 001750 001750 2314 13050301451 17063 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 NAME
theorem - handle divs with C<.theorem> as theorems
=head1 DESCRIPTION
Pandoc filter to convert divs with C to LaTeX theorem
environments in LaTeX output, and to numbered theorems in HTML output.
=cut
use Pandoc::Filter;
use Pandoc::Elements;
my $theoremcount = 0;
sub latex { RawBlock latex => shift }
sub html { RawBlock html => shift }
pandoc_filter 'Div.theorem' => sub {
my ($e, $f, $m) = @_;
if ($f eq 'latex') {
my $label = $e->id ? '\label{'.$e->id.'}' : '';
return [
latex("\\begin{theorem}$label"),
@{$e->content},
latex('\end{theorem}')
];
} elsif ($f eq 'html' or $f eq 'html5') {
$theoremcount++;
return Div [@{$e->attr}], [
html("
Theorem $theoremcount
\n
"),
@{$e->content},
html("
\n")
];
}
return;
};
=head1 SYNOPSIS
pandoc --filter theorem.pl -o output.html < input.md
=head1 SEE ALSO
This is a port of
L
from Python to Perl with L and L.
=cut
linkage-setters.t 100644 001750 001750 1243 13050301451 16776 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use warnings;
use Test::More 0.96; # for subtests
use Pandoc::Elements qw[ attributes Str Link Image ];
my @tests = ( [ Link => \&Link ], [Image => \&Image], );
for my $test ( @tests ) {
my ( $type, $constr ) = @$test;
subtest $type => sub {
my $e = $constr->( attributes {}, [ Str $type], [] );
ok( ( can_ok( $e, 'name' ) and $e->name eq $type ), 'name' );
for my $method ( qw[ url title ] ) {
can_ok $e, $method;
is $e->$method, "", "$method unset";
is $e->$method( $method ), $method, "set $method";
is $e->$method, $method, "$method set";
}
};
}
done_testing;
pandoc-metadata.t 100644 001750 001750 1313 13050301451 16715 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/t use strict;
use Test::More;
use Pandoc::Elements;
use JSON;
is_deeply metadata 'foo', MetaString 'foo';
is_deeply metadata undef, MetaString '';
is_deeply metadata JSON::true(), MetaBool 1;
is_deeply metadata JSON::false(), MetaBool 0;
is_deeply metadata ['foo'], MetaList [ MetaString 'foo' ];
is_deeply metadata { x => [1] }, MetaMap { x => MetaList [ MetaString '1' ] };
is_deeply metadata MetaString 'foo', MetaString 'foo';
is_deeply metadata Str 'ä', MetaInlines [ Str 'ä' ];
is_deeply metadata Para [ Str 'ä' ], MetaBlocks [ Para [ Str 'ä' ] ];
my $ref = \'';
is_deeply metadata $ref, MetaString "$ref";
$ref = bless {}, 'Pandoc::Elements';
is_deeply metadata $ref, MetaString "$ref";
done_testing;
comments.pl 100755 001750 001750 1657 13050301451 17261 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
=head1 NAME
comments - remove everyting between C<< >>
=head1 DESCRIPTION
Pandoc filter to ignore everything between C<< >> and
C<< >> The comment lines must appear on lines by
themselves, with blank lines surrounding them.
=cut
use Pandoc::Filter;
my $incomment = 0;
pandoc_filter sub {
my $e = shift;
if ( $e->name eq 'RawBlock' and $e->format eq 'html' ) {
if ( $e->content =~ /^\s*\s*$/ ) {
$incomment = $1 eq 'BEGIN';
return [];
}
}
return $incomment ? [] : undef;
};
=head1 SYNOPSIS
pandoc --filter comments.pl -o output.html < input.md
=head1 SEE ALSO
This is a port of
L
from Python to Perl with L and L.
=cut
graphviz.pl 100755 001750 001750 1521 13050301451 17254 0 ustar 00voj voj 000000 000000 Pandoc-Elements-0.33/examples #!/usr/bin/env perl
use strict;
use Pandoc::Filter;
use Pandoc::Filter::ImagesFromCode;
pandoc_filter 'CodeBlock.graphviz' => Pandoc::Filter::ImagesFromCode->new(
from => 'dot',
to => sub { $_[0] eq 'latex' ? 'pdf' : 'png' },
run => ['dot', '-T$to$', '-o$outfile$', '$infile$'],
);
=head1 NAME
graphviz - process code blocks with C<.graphviz> into images
=head1 DESCRIPTION
Pandoc filter to process code blocks with class C into
graphviz-generated images. Attribute C