Commit graph

178 commits

Author SHA1 Message Date
luz paz
aff726b460 Fix typos
Found via `codespell -q 3 -S changelog.md -L bu,fo,ist,mke,multline,noes,ot,pard,pres,tabl,te,tothe`
2022-08-21 20:23:00 -07:00
Albert Krewinkel
5a99747063 Lua: add function pandoc.utils.citeproc
The function runs the *citeproc* processor on a Pandoc document.
Exposing this functionality to Lua allows to make citation processing
part of a filter or writer, simplifies the creation of multiple
bibliographies, and enables the use of varying citation styles in
different parts of a document.
2022-08-13 12:30:13 -07:00
Albert Krewinkel
daef24f022
Lua: extend pandoc.system module. (#8184)
The module now has the additional functions `list_directory`,
`make_directory`, and `remove_directory`. This makes it easier to write
cross-platform scripts that need to inspect or modify the file system.
2022-07-15 21:22:33 +02:00
John MacFarlane
7119fee963 lua-filters.md: Add link to @wlupton's logging.lua.
Closes #8146.
2022-07-15 21:18:21 +02:00
Albert Krewinkel
12cc140272
Lua: add fields pandoc.readers and pandoc.writers. (#8177)
The set of supported input and output formats is made available to Lua
users.
2022-07-12 20:14:42 +02:00
Albert Krewinkel
37fc412daa
doc/lua-filters.html: add list of common pitfalls
A list with common filtering and Lua pitfalls is added to the
"debugging" section.

Closes: #6077
2022-06-16 17:40:33 +02:00
Elliot Bobrow
6ff4972ca9
add --embed-resources flag (#8121)
* Add `--embed-resources` flag for `--self-contained` without implying
  `--standalone`
* Deprecate `--self-contained flag`

Closes #7331
2022-06-14 17:00:18 -06:00
Bastien Dumont
7244821705
Make clear that walk performs a deep copy (#8124)
Relevant discussion here: https://groups.google.com/g/pandoc-discuss/c/-NoL3Ft9AC8

I felt that it could be useful to inform that walk is the only way to get a deep copy of a List. I wrote this where I think that users will likely loop up for this feature, but it may be out of place.
2022-06-14 16:14:19 -06:00
Albert Krewinkel
b2b21bb4c5
Lua: add function pandoc.mediabag.fill (#8104)
The function allows to fill the mediabag with all images in a given
document. Images that cannot be fetched are replaced with a Span
containing the image description.
2022-06-06 09:25:09 -07:00
Albert Krewinkel
ad726953b9
Lua: allow to pass Sources to pandoc.read (#8002)
Sources, the data type passed to the `Reader` function in custom
readers, are now accepted as input to `pandoc.read`.
2022-03-30 14:10:30 -07:00
Mario Lang
6e94c8ddcd
doc/lua-filters.md: Fix typo (#7981) 2022-03-23 11:15:43 +01:00
Albert Krewinkel
7d3db1dd2d
Lua docs: fix typos, missing links 2022-02-07 09:30:12 +01:00
Albert Krewinkel
49f1e7608e Lua: add module pandoc.layout to format and layout text 2022-02-06 16:01:24 -08:00
Albert Krewinkel
faf99ad356
docs/lua-filters.md: revert changes made in 3169367475
Partially reverts 3169367475. The result is
unpleasant, auto-generating module docs requires a different approach.
2022-02-06 09:43:58 +01:00
Albert Krewinkel
3169367475
Lua docs: allow to auto-generate Lua module documentations
No documentations are generated for now, this just adds the necessary
code and auto-formats file `doc/lua-filters.md`.
2022-02-05 13:32:02 +01:00
John MacFarlane
5c6b0c3abd Fix identifier in lua-filters doc. 2022-01-30 11:07:44 -08:00
John MacFarlane
96ab241056 lua-filters: put all parameters in code font. 2022-01-30 11:06:30 -08:00
John MacFarlane
623fa4e1b9 Fix lua-filters documentation for table column widths.
See #7864.
2022-01-24 09:29:34 -08:00
John MacFarlane
268bec1808 Further improvements to doc/lua-filters.md. 2022-01-07 23:35:32 -08:00
John MacFarlane
95b0645276 lua-filters.doc: use header attributes, not spans. 2022-01-07 23:24:39 -08:00
John MacFarlane
2fb903336b lua-filters.doc: use headings instead of nested def lists.
See #7807.
2022-01-07 23:22:18 -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
6a5ac90bf1 Lua: add pandoc.WriterOptions constructor 2022-01-04 11:55:59 -08:00
Albert Krewinkel
0d1d52f0a0 Lua: add function pandoc.write 2022-01-04 11:55:59 -08:00
Albert Krewinkel
60fc05e2ce
doc/lua-filters.md: fix and improve documentation 2022-01-02 14:50:56 +01:00
Albert Krewinkel
85334eb6c4
Lua writer: provide global PANDOC_WRITER_OPTIONS
Closes: #6731
2022-01-02 13:57:01 +01: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
Albert Krewinkel
03054a33e8 Lua: use global state when parsing documents in pandoc.read
The function `pandoc.read` is updated to use the same state that was
used while parsing the main input files. This ensures that log messages
are preserved and that images embedded in the input are added to the
mediabag.
2021-12-31 17:35:52 -08:00
Albert Krewinkel
8bd22270c8
doc/lua-filters.md: improve documentation of make_sections 2021-12-28 12:35:22 +01:00
Albert Krewinkel
fae63b09bb
Lua: use released pandoc-lua-marshal-0.1.3.
Inlines, Blocks, and List objects now have an `__eq` metamethod, testing
equality by comparing two lists element-wise.
2021-12-23 16:04:35 +01:00
Albert Krewinkel
17a32a99a5
Lua: simplify and deprecate function pandoc.utils.equals
The function is no longer required for element comparisons; it is now an
alias for the `==` operator.
2021-12-21 19:01:11 +01:00
Albert Krewinkel
d7cab51982 Lua: add new library function pandoc.utils.type.
The function behaves like the default `type` function from Lua's
standard library, but is aware of pandoc userdata types. A typical
use-case would be to determine the type of a metadata value.
2021-12-21 09:24:21 -08:00
Albert Krewinkel
74c2d9eb07
doc/lua-filters: numbers are now accepted as MetaValue 2021-12-19 15:59:05 +01:00
Albert Krewinkel
a0af1b5926
Lua: change representation of TableHead, TableFoot, and Row values.
The objects now also follow the principle that element attributes are
accessible through the `.attr` field. Rows in `TableHead` and
`TableFoot` are available via the `.rows` field. Row objects have a
`.cells` field, containing the list of table cells.

Closes: #7718
2021-12-19 09:44:56 +01: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
ce44cf688a
doc/lua-filters.md: add docs for Cell constructor 2021-12-14 09:13:38 +01:00
Albert Krewinkel
b8ada284b1
doc/lua-filters.md: update description of walk methods, fix typos 2021-12-13 21:03:26 +01: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
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
Albert Krewinkel
fa838deefc
Lua: remove pandoc.utils.text (#7720)
The new `pandoc.Inlines` function behaves identical on string input, but
allows other Inlines-like arguments as well.

The `pandoc.utils.text` function could be written as

    function pandoc.utils.text (x)
      assert(type(x) == 'string')
      return pandoc.Inlines(x)
    end
2021-11-29 09:12:30 -08:00
Albert Krewinkel
32a4c331d2
doc/lua-filters.md: update docs on Blocks, Inlines, MetaValue 2021-11-28 16:02:48 +01:00
Albert Krewinkel
b9222e5cb1
Lua: add constructors pandoc.Blocks and pandoc.Inlines
The functions convert their argument into a list of Block and Inline
values, respectively.
2021-11-28 16:02:42 +01:00
Albert Krewinkel
bffd74323c
Lua: add function pandoc.utils.text (#7710)
The function converts a string to `Inlines`, treating interword spaces
as `Space`s or `SoftBreak`s. If you want a `Str` with literal spaces,
use `pandoc.Str`.

Closes: #7709
2021-11-23 09:32:53 -08:00
Albert Krewinkel
cd91f72843
Lua: set lpeg, re as globals; allow shared lib access via require
The `lpeg` and `re` modules are loaded into globals of the respective
name, but they are not necessarily registered as loaded packages. This
ensures that

- the built-in library versions are preferred when setting the globals,
- a shared library is used if pandoc has been compiled without `lpeg`,
  and
- the `require` mechanism can be used to load the shared library if
  available, falling back to the internal version if possible and
  necessary.
2021-11-17 10:03:04 +01:00
Albert Krewinkel
ebf7f782d3 Lua: load re module available into global of the same name 2021-11-11 10:32:37 -08:00
Albert Krewinkel
6b462e5933 Lua: allow to pass custom reader options to pandoc.read
Reader options can now be passed as an optional third argument to
`pandoc.read`. The object can either be a table or a ReaderOptions value
like `PANDOC_READER_OPTIONS`. Creating new ReaderOptions objects is
possible through the new constructor `pandoc.ReaderOptions`.

Closes: #7656
2021-11-06 09:04:29 -07:00
Albert Krewinkel
1fa6e53425
doc/lua-filters.md: add section on global modules, including lpeg 2021-11-05 22:38:40 +01:00