Commit graph

1510 commits

Author SHA1 Message Date
Albert Krewinkel
96db10c8d7 Require pandoc-lua-marshal 0.1.3.1
Fixes a problem with `List.includes` and `List.find` that caused a Lua
stackoverflow and subsequent program crash.

Fixes: #7831
2022-01-14 11:05:19 +01:00
John MacFarlane
95adabd3cc Bump version to 2.17. 2022-01-12 15:12:36 -08:00
John MacFarlane
c9d309d84b Use commonmark-extensions 0.2.3. 2022-01-12 09:58:45 -08:00
John MacFarlane
a416a2f243 Use citeproc 0.6.0.1. 2022-01-11 23:52:57 -08:00
John MacFarlane
a30b29624e Use latest texmath (0.12.4). 2022-01-11 19:19:27 -08:00
John MacFarlane
dd706bc49c Minor reformatting of cabal file 2022-01-10 10:13:13 -08:00
John MacFarlane
33da5833de Update commits for dev dependencies, allow text 2.0. 2022-01-09 15:30:22 -08:00
John MacFarlane
d9e9f119c5 pandoc.cabal: add a test file to extra-source-files. 2022-01-09 14:27:54 -08:00
John MacFarlane
a965111680 Fix parsing of footnotes in --metadata-file.
Closes #7813.
2022-01-07 15:58:26 -08:00
Albert Krewinkel
1f8638fb54 Lua: add pandoc.template module
The module provides a `compile` function to use strings as templates.
2022-01-04 11:55:59 -08:00
Albert Krewinkel
974a9d353a Lua: marshal templates as opaque userdata values 2022-01-04 11:55:59 -08:00
Albert Krewinkel
b7a44f9d19 Copyright notices: update for 2022 2022-01-02 11:59:22 -08:00
Albert Krewinkel
1e60181ee3 Lua: provide global PANDOC_WRITER_OPTIONS [API change]
API changes:

- The function T.P.Filter.applyFilters now takes a filter
  environment of type `Environment`, instead of a ReaderOptions value.
  The `Environment` type is exported from `T.P.Filter` and allows to
  combine ReaderOptions and WriterOptions in a single value.

- Global, exported from T.P.Lua, has a new type constructor
  `PANDOC_WRITER_OPTIONS`.

Closes: #5221
2022-01-01 14:31:42 -08:00
Albert Krewinkel
e58a5ceed8
Lua: marshal ReaderOptions field extensions, track_changes via JSON
Extensions are now available as a list of strings; the track-changes
settings are given as the kebab-case representation used in JSON.
2022-01-01 13:44:13 +01:00
John MacFarlane
822e1d6cdc pandoc.cabal: remove unnecessary QuickCheck dependency. 2021-12-30 21:26:30 -08:00
Albert Krewinkel
2dd1cde715 Lua: allow binary (byte string) readers to be used with pandoc.read 2021-12-30 22:41:15 +01:00
John MacFarlane
43a8931abf Add markua test files to extra-source-files. 2021-12-22 12:02:20 -08:00
John MacFarlane
7a9832166e Add text wrapping to HTML output.
Previously the HTML writer was exceptional in not being
sensitive to the `--wrap` option.  With this change `--wrap`
now works for HTML. The default (as with other formats) is
automatic wrapping to 72 columns.

A new internal module, T.P.Writers.Blaze, exports `layoutMarkup`.
This converts a blaze Html structure into a doclayout Doc Text.

In addition, we now add a line break between an `img` tag
and the associated `figcaption`.

Note: Output is never wrapped in `writeHtmlStringForEPUB`.
This accords with previous behavior since previously the HTML
writer was insensitive to `--wrap` settings.  There's no real
need to wrap HTML inside a zipped container.

Note that the contents of script, textarea, and pre tags are
always laid out with the `flush` combinator, so that unwanted
spaces won't be introduced if these occur in an indented context
in a template.

Closes #7764.
2021-12-22 09:45:02 -08:00
binaarinen
0610f16f7f
Add a writer for Markua 0.10 (#7729)
Markua is a markdown variant used by Leanpub.
More information about Markua can be found at https://leanpub.com/markua/read.

Adds a new exported function `writeMarkua` from T.P.Writers.Markdown.
[API change]

Closes #1871.

Co-authored by Tim Wisotzki and Samuel Lemmenmeier.
2021-12-19 12:10:41 -08:00
Albert Krewinkel
7a70b87fac Lua: add function pandoc.utils.references
List with all cited references of a document.

Closes: #7752
2021-12-17 14:45:27 -08:00
Albert Krewinkel
b79bf192ec Lua: support topdown traversals
The traversal order of filters can now be selected by setting the key
`traverse` of the filter to either `'topdown'` or `'typewise'`; the
default remains `'typewise'`.

Topdown traversals can be cut short by returning `false` as a second
value from the filter function. No child-element of the returned element
is processed in that case.
2021-12-13 08:52:19 -08:00
Kolen Cheung
a9a9a2c62a fix(IpynbOutput)!: rank always favors output format
Previously, both `fmt == f` case and Image have a rank of 1.
In the end, e.g. from ipynb to html conversion,
if both html and image exists, it actually prefers the image.
This commit changes this, so that fmt == f is always highest rank,
and rank never collides.
This is achieved by keeping fmt == f case having rank 1,
and every other rank increased by 1.
2021-12-11 09:42:30 -08:00
Albert Krewinkel
83b5b79c0e Custom reader: pass list of sources instead of concatenated text
The first argument passed to Lua `Reader` functions is no longer a plain
string but a richer data structure. The structure can easily be
converted to a string by applying `tostring`, but is also a list with
elements that contain each the *text* and *name* of each input source as
a property of the respective name.

A small example is added to the custom reader documentation, showcasing
its use in a reader that creates a syntax-highlighted code block for
each source code file passed as input.

Existing readers must be updated.
2021-12-11 08:59:11 -08:00
Albert Krewinkel
3e7b46af64
Switch to released pandoc-lua-marshal-0.1.2
Cell values are now marshaled as userdata objects; a constructor
function for table cells is provided as `pandoc.Cell`.
2021-12-10 17:24:50 +01:00
Albert Krewinkel
fa643ba6d7 Lua: update to latest pandoc-lua-marshal (0.1.1)
- `walk` methods are added to `Block` and `Inline` values; the methods
  are similar to `pandoc.utils.walk_block` and
  `pandoc.utils.walk_inline`, but apply to filter also to the element
  itself, and therefore return a list of element instead of a single
  element.

- Functions of name `Doc` are no longer accepted as alternatives for
  `Pandoc` filter functions. This functionality was undocumented.
2021-12-09 09:22:29 -08:00
John MacFarlane
51142c6803 Ipynb reader & writer: properly handle cell "id".
This is passed through if it exists (in Nb4); otherwise
the writer will add a random one so that cells all have
an "id".

Closes #7728.
2021-12-06 23:40:51 -08:00
John MacFarlane
928c120806 Allow unicode-transforms 0.4.0. 2021-12-02 09:00:33 -08:00
John MacFarlane
6e712fa10a Update cabal description. 2021-11-30 10:12:42 -08:00
John MacFarlane
e30be56fc3 Bump pandoc-lua-marshall lower bound to 0.1.0.1 in cabal file.
Closes #7721.
2021-11-28 17:43:22 -08:00
Albert Krewinkel
3692a1d1e8
Lua: use package pandoc-lua-marshal (#7719)
The marshaling functions for pandoc's AST are extracted into a separate
package. The package comes with a number of changes:

  - Pandoc's List module was rewritten in C, thereby improving error
    messages.

  - Lists of `Block` and `Inline` elements are marshaled using the new
    list types `Blocks` and `Inlines`, respectively. These types
    currently behave identical to the generic List type, but give better
    error messages. This also opens up the possibility of adding
    element-specific methods to these lists in the future.

  - Elements of type `MetaValue` are no longer pushed as values which
    have `.t` and `.tag` properties. This was already true for
    `MetaString` and `MetaBool` values, which are still marshaled as Lua
    strings and booleans, respectively. Affected values:

      + `MetaBlocks` values are marshaled as a `Blocks` list;

      + `MetaInlines` values are marshaled as a `Inlines` list;

      + `MetaList` values are marshaled as a generic pandoc `List`s.

      + `MetaMap` values are marshaled as plain tables and no longer
        given any metatable.

  - The test suite for marshaled objects and their constructors has
    been extended and improved.

  - A bug in Citation objects, where setting a citation's suffix
    modified it's prefix, has been fixed.
2021-11-27 17:08:01 -08:00
John MacFarlane
572d801738 Bump to 2.16.2 2021-11-20 23:19:20 -08:00
Fabián Heredia Montiel
51c85b46ba
Update build files (#7696)
* Drop old windows 32-bit constraints

- basement >= 0.0.10 was 0.0.12 on stackage-18.10
- foundation >= 0.0.23 was 0.0.26.1 on stackage-18.10

* Update cabal `tested-with` field to correspond to `ci.yml` matrix

* ghc: 8.10.{2,4} → 8.10.7
2021-11-17 17:29:01 -08:00
John MacFarlane
4e50706924 Remove unneeded package dependencies from benchmark target. 2021-11-10 09:46:47 -08:00
John MacFarlane
03f9a0c61e Require ghc >= 8.6, base >= 4.12.
This allows us to get rid of the old custom prelude and
some crufty cpp.  But the primary reason for this is that
conduit has bumped its base lower bound to 4.12, making it
impossible for us to support lower base versions.
2021-11-09 23:43:12 -08:00
John MacFarlane
09748669b0 Require Cabal 2.4. Use wildcards...
...to ensure that all pptx tests are included.

Closes #7677.
2021-11-09 22:56:31 -08:00
Albert Krewinkel
ab0fe676a8
Lua: ensure that 're' module is always available.
The module is shipped with LPeg.
2021-11-08 12:22:33 +01:00
John MacFarlane
881b45209e Replace old sample custom reader with a full-featured reader for creole.
This is better as an example.  And it is faster than pandoc's
regular creole parser, which shows that high-performance readers
can be developed this way.
2021-11-07 14:34:56 -08:00
John MacFarlane
ee2f0021f9
Add interface for custom readers written in Lua. (#7671)
New module Text.Pandoc.Readers.Custom, exporting
readCustom [API change].

Users can now do `-f myreader.lua` and pandoc will treat the
script myreader.lua as a custom reader, which parses an input
string to a pandoc AST, using the pandoc module defined for
Lua filters.

A sample custom reader can be found in data/reader.lua.

Closes #7669.
2021-11-05 22:10:29 -07:00
Albert Krewinkel
a1b6bf69f2
Lua: include lpeg module (#7649)
Compiles the 'lpeg' library (Parsing Expression Grammars For Lua) into
the program.

Package maintainers may choose to rely on package dependencies to make
lpeg available, in which case they can compile the with the constraint
`lpeg +rely-on-shared-lpeg-library`.
2021-11-04 19:25:29 -07:00
Albert Krewinkel
4ea2baf814
Require latest hslua (2.0.1).
This fixes issues with

  - misleading error messages when a required function parameter is
    omitted;
  - absent properties still being listed in the output of `pairs`; and
  - alias accessing leading to errors instead of returning `nil`, e.g.
    with `(pandoc.Str '').identifier`.

Fixes: #7661
See also: #7657
2021-11-04 12:34:07 +01:00
John MacFarlane
6c1ef00de5 Allow tasty-bench 0.3.x. 2021-11-02 16:21:16 -07:00
John MacFarlane
d1789dda75 Bump to 2.16.1, update changelog. 2021-11-02 16:16:21 -07:00
John MacFarlane
40655b54a2 Bump to 2.16, update changelog. 2021-10-31 00:01:03 -07:00
John MacFarlane
621397f42e Allow time 1.13 2021-10-30 23:48:06 -07:00
John MacFarlane
a1e422097a Require latest skylighting (0.12.1). 2021-10-27 21:13:29 -07:00
John MacFarlane
d226a35c0a Switch back from HsYAML to yaml.
Reasons:

- Performance: HsYAML is around 20 times slower in parsing
  large YAML bibliographies (#6084).
- An issue was submitted to HsYAML, but it hasn't gotten
  any attention.  HsYAML seems borderline unmaintained; it hasn't
  had a commit in over a year.
- Unfortunately this goes back on our attempts to free ourselves
  from C dependencies (#4535).  But I don't see a better alternative
  until a better pure Haskell parser is available.

Closes #6084.

Notes:

- We've removed the FromYAML instances for all types that had
  them, since this is a HsYAML-specific typeclass [API change].
  (The yaml package just uses From/ToJSON.)
- Unlike HsYAML (in the configuration we were using), yaml
  parses 'Y', 'N', 'Yes', 'No', 'On', 'Off' as boolean values.
  Users may need to quote these when they are meant to be
  interpreted as strings.  Similarly, 'null' is parsed as
  a YAML null value (and will be treated as an empty string
  by pandoc rather than the string 'null').  Quoting it will
  force it to be interpreted as a string.
- Some tests had to be adjusted accordingly.
- Pandoc now behaves better when the YAML metadata contains
  escaping errors: instead of just falling back on treating
  the section as a table, it raises a YAML parsing error.
2021-10-27 12:50:51 -07:00
Albert Krewinkel
f56d870631
Lua: marshal ListAttributes values as userdata objects 2021-10-26 14:40:11 +02:00
John MacFarlane
87a98b76ce Use ipynb 0.1.0.2.
With this change pandoc can be built with aeson >= 2.
2021-10-23 16:27:51 -07:00
John MacFarlane
51e1a8601f Bump to 2.15, updaet man page. 2021-10-22 22:15:37 -07:00
John MacFarlane
45054733fa Use citeproc 0.6, commonmark 0.2.2.1, commonmark-extensions 0.2.2 2021-10-22 17:31:40 -07:00