Commit graph

302 commits

Author SHA1 Message Date
Albert Krewinkel
efdba79ad1 Lua writer: allow variables to be set via second return value of Doc
New templates variables can be added by giving variable-value pairs as a
second return value of the global function `Doc`.

Example:

    function Doc (body, meta, vars)
      vars.date = vars.date or os.date '%B %e, %Y'
      return body, vars
    end

Closes: #6731
2022-01-02 11:55:02 -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
ddd1b85608
JATS templates: fix affiliation tagging in articleauthoring output
Affiliations were `xlink`ed even in the articleauthoring tag set, but
`<aff>` are not allowed as children of `contrib-group` elements in that
tag set. Each affiliation must be listed directly in the contrib
element.
2021-12-23 09:11:54 +01:00
Albert Krewinkel
7954070b01
JATS templates: add support for article subtitles 2021-12-23 09:11:54 +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
e88224621d Custom reader: ensure old Readers continue to work
Retry conversion by passing a string instead of sources when the
`Reader` fails with a message that hints at an outdated function. A
deprecation notice is reported in that case.
2021-12-11 08:59:11 -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
72075423d0 custom-writers.md: use filter to include source of example. 2021-12-06 13:04:51 -08:00
John MacFarlane
0892af33ae Suggest VSCode as a possible editor in getting-started.md. 2021-12-02 08:28:18 -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
Mauro Bieg
136739b7ed
fix typo in custom-readers.md (#7722) 2021-11-29 08:59:37 -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
John MacFarlane
b72ba3ed6d Simplify sample ris reader in doc/custom-readers.md.
Made possible by #7712.
2021-11-23 09:57:09 -08: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
John MacFarlane
a039f024f2 Add an example to custom-readers.md. 2021-11-22 14:58:18 -08:00
John MacFarlane
1d56e6059e Add custom-writers.md. 2021-11-21 10:10:27 -08:00
Albert Krewinkel
464abdc854
Rename doc/custom-reader.lua to doc/custom-readers.md 2021-11-21 10:16:20 +01:00
John MacFarlane
3e5af46471 Add doc for custom-readers. 2021-11-18 09:04:24 -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
fe113dd5fa
JATS template: fix incomplete previous commit 2021-11-11 09:44:49 +01: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
John MacFarlane
84e4222fed short-guide: Transitions -> Transformations. 2021-10-27 16:19:39 -07:00
Albert Krewinkel
3849e12d45 Update description of T.P.PDF
Co-authored-by: Mauro Bieg <mb21@users.noreply.github.com>
2021-10-27 16:16:53 -07:00
Albert Krewinkel
25b031e3c3 Add a short guide to pandoc's sources 2021-10-27 16:16:53 -07:00
John MacFarlane
26a8de684e Change JSON encodings of some types.
- For LineEnding use lowercase constructors, e.g. `crlf`, `native`.
  This was the original intent, but there was a bug in the
  implementation.
- For HTMLSlideVariant use lowercase constructors.
- For ReaderOptions use e.g. `default-image-extension`
  instead of `readerDefaultImageExtension` for field names.
- For Extension, use e.g. `tex_math_dollars` instead of
  `Ext_tex_math_dollars` as constructor.
- For Extensions, use an array of Extensions, instead of
  an object wrapping the tag `Extensions` and an integer.
  (The representation is not supposed to be part of the
  public API.)
- For Opt, use field names like `tab-stop` instead of `optTabStop`.
2021-10-27 12:50:51 -07:00
Quinn
2b427331d9
Rephrase pandoc.path docs (#7548) 2021-09-04 22:47:01 -07:00
Quinn
db03e75e27 Improve order of Image fields
Ensure consistency throughout docs
2021-09-04 09:52:43 -07:00
Quinn
531eb2a92a Add missing type for Image title 2021-09-04 09:51:58 -07:00
Jeroen de Haas
7d91ff28ac Do not leak working directory in TikZ filter 2021-08-30 08:35:35 -07:00
John MacFarlane
c1ab55793b Add a faq about the "Cannot allocate memory" error on M1 macs. 2021-08-01 10:29:47 -06:00
John MacFarlane
95541294d3 Add FAQ on converting from/to PDF 2021-07-03 15:51:07 -07:00
John MacFarlane
e00e5a4cc2 Add doc/faqs.md.
This is imported from the website; in the future the website
version will be drawn from here.

Added a FAQ on the use of `\AtEndPreamble` for cases when
the contents of `header-includes` need to refer to definitions
that come later in the preamble.  See #7422.
2021-07-03 15:19:39 -07:00
Albert Krewinkel
e66960fe4f
using-the-pandoc-api.md: switch from String to Text
Fixed examples that would no longer compile with current library
versions, as the API now uses Text instead of String in most places.
2021-06-08 12:38:20 +02:00
Sebastian Humenda
39afd4297f Mention GladTeX for EPUB export
This updates the manual and the web site about the GladTeX usage.
2021-06-07 19:17:39 -06:00
John MacFarlane
f69f1101e6 Update doc/using-the-pandoc-api.md for new reader types. 2021-05-09 19:11:34 -06:00
John MacFarlane
56a0d874c7 Add instructions for installing pandoc-types before compiling filter. 2021-04-30 08:35:52 -07:00
John MacFarlane
d0d8bb9818 Add unicode-collation to list of libraries developed to support pandoc. 2021-04-26 09:29:47 -07:00
Charanjit Singh
b159daa8e9
docs/org.md: Add note about default export behavior of org-mode in (#7238)
Since it seem to be a common source of confusion, this commit adds a note in
org-mode documentation referring users to consult org-mode's export
documentation when they find themselves in a pinch.
2021-04-26 11:54:25 +02:00
obcat
08598dedb1
Fix typo (#7200) 2021-04-03 09:36:54 -07:00
Anti-Distinctlyminty
7e887c0a22
Update org.md (#7189)
SELECT_TAGS supported since ac83b9c37c
2021-03-30 08:34:44 -07:00
TatianaPorras
a02ab4622d Fixed typo #7159
This commit fixes the typo in the Lua filters documentation, see #7159
2021-03-28 14:16:32 +02:00
TatianaPorras
69d44b2c82 Fixed "The this" typo in lua-filters.md
The documentation for Lua filters said "The this module defines..."

This has been fixed to say "This module defines..."
2021-03-28 14:14:13 +02:00
Albert Krewinkel
872b4313a1
JATS templates: support 'equal-contrib' attrib for authors
Authors who contributed equally to a paper may be marked with
`equal-contrib`.
2021-03-11 11:07:59 +01:00
John MacFarlane
50e6d3ed23 Add doc/libraries.md.
A description of libraries that support pandoc.
2021-03-02 17:44:19 -08:00
Salim B
fae6a204f1
Fix/update URLs and use HTTP**S** where possible (#7122) 2021-02-26 17:56:04 -08:00
Albert Krewinkel
b5b576184c
JATS writer: add date-type to pub-date elements 2021-02-15 13:15:14 +01:00
Albert Krewinkel
2c99e0e358
JATS writer: replace attribute "pub-type" with "publication-format".
The former attribute is deprecated.
2021-02-15 13:15:14 +01:00
Albert Krewinkel
57e56ed55c
doc/lua-filters.md: improve docs for pandoc.mediabag.insert 2021-02-04 19:07:59 +01:00
Albert Krewinkel
364fe4a03b
doc/lua-filters.md: fix, improve docs for pandoc.mediabag.fetch 2021-02-04 15:32:35 +01:00
Albert Krewinkel
f84512228e Improve docs for directory, normalize 2021-02-02 21:04:30 -08:00
Albert Krewinkel
61b108d527 Lua: add module "pandoc.path"
The module allows to work with file paths in a convenient and
platform-independent manner.

Closes: #6001
Closes: #6565
2021-02-02 21:04:30 -08:00
Albert Krewinkel
d82fe52a02
JATS templates: tag author.name as string-name
The partitioning the components of a name into surname, given names,
etc. is not always possible or not available. Using `author.name` allows
to give the full name as a fallback to be used when `author.surname` is
not available.
2021-01-29 09:51:20 +01:00
wuffi
7e98562c04 Fixed table with file extensions and interpreters
Assigned .pl file extension to perl interpreter and .rb to ruby
2020-12-20 14:44:15 +01:00
Ian Sullivan
c1fb4d3729
typo 2020-12-14 12:37:17 -05:00
Randolf J
f1bd176d81
filters.md: document a new Pandoc filtering framework (#6908) 2020-12-02 12:28:38 -08:00
Albert Krewinkel
f7d80b4170
JATS template: allow array of persistent institute ids in pid 2020-11-23 10:27:57 +01:00
Albert Krewinkel
5344dab8eb
Org reader: parse #+LANGUAGE into lang metadata field
Fixes: #6845
2020-11-22 12:53:05 +01:00
Albert Krewinkel
797db8d306
JATS writer: support author affiliations (#6867)
Closes: #6687
2020-11-20 09:57:06 -08:00
Albert Krewinkel
0ed3436588
doc/filters.md: describe technical details of filter invocations (#6815) 2020-11-06 15:37:24 -08:00
Albert Krewinkel
6463901fac
Document pandoc's handling of metadata in JATS output (#6794) 2020-11-03 11:39:59 -08:00
John MacFarlane
ba4dfd4f58 Fix code example in lua-filters.md.
Closes #6795, thanks to Odin Kroeger.
2020-11-01 10:48:47 -08:00
Michael Hoffmann
988d381aad
Fix some small typos in the API documentation (#6751)
While reading the docs I found a couple of small typos.
2020-10-15 17:09:29 -07:00
Albert Krewinkel
74be44f91f
doc/org.md: fix typos 2020-10-12 17:01:04 +02:00
Albert Krewinkel
4d564ce597
doc/lua-filters.md: fix typos
Use American spelling.
2020-10-12 16:58:23 +02:00
Albert Krewinkel
3bad78ca96
doc/lua-filters.md: describe parameters to pandoc.pipe 2020-10-11 13:05:27 +02:00
Ian Max Andolina
d1e1898c52
Add info on how to debug Lua filters (#6732)
Add info on debugging Lua filters.
2020-10-08 11:56:08 +02:00
Albert Krewinkel
68454e0812
doc/lua-filters.md: document Underline type and constructor 2020-10-04 21:55:48 +02:00
Albert Krewinkel
29baaa2acb
doc/org.md: add section on tables 2020-09-25 09:44:00 +02:00
Albert Krewinkel
29d4753cd9
doc/org.md: add section on handling of unknown directives 2020-09-21 11:35:28 +02:00
Albert Krewinkel
acbea6b8c6
Lua filters: add SimpleTable for backwards compatibility (#6575)
A new type `SimpleTable` is made available to Lua filters. It is
similar to the `Table` type in pandoc versions before 2.10;
conversion functions from and to the new Table type are provided.

Old filters using tables now require minimal changes and can use,
e.g.,

    if PANDOC_VERSION > {2,10,1} then
      pandoc.Table = pandoc.SimpleTable
    end

and

    function Table (tbl)
      tbl = pandoc.utils.to_simple_table(tbl)
      …
      return pandoc.utils.from_simple_table(tbl)
    end

to work with the current pandoc version.
2020-09-20 15:48:31 -07:00
the-solipsist
214f2f08e4 Make the setting-the-date example conditional
This makes the example a bit more realistic/valuable by checking if the metadata value "date" is already present, before changing the value.
2020-08-26 13:36:06 +02:00
Albert Krewinkel
45ed1b6b1c
doc/lua-filters.md: add missing Link.title field 2020-08-07 11:27:34 +02:00
Albert Krewinkel
857eb46793
doc/lua-filters.md: add missing header attribute 2020-07-29 18:32:56 +02:00
Albert Krewinkel
1e1c5e7f4c
Lua filter docs: remove link table example
The example is outdated and requires a complete overhaul.
2020-07-28 22:30:56 +02:00
Albert Krewinkel
6448bd30c4
doc/lua-filters.md: document body field 2020-07-25 20:57:09 +02:00
Albert Krewinkel
44c4660a31
Lua filters: make attr argument optional in Table constructor
This changes the Lua API. It is highly unlikely for this change to
affect existing filters, since the documentation for the new Table
constructor (and type) was incomplete and partly wrong before.

The Lua API is now more consistent, as all constructors for elements
with attributes now take attributes as the last parameter.
2020-07-25 20:37:57 +02:00
Albert Krewinkel
9dd4d077c0
doc/lua-filters.md: fix documentation for tables 2020-07-25 19:27:29 +02:00
favonia
2bdb1e64eb
Update using-the-pandoc-api.md 2020-07-21 14:31:46 -05:00
tajmone
bf7c624c80
Fix Typos in Lua Filters Doc 2020-07-09 18:48:52 +02:00
Albert Krewinkel
90ac70c79c
Org reader: unify keyword handling
Handling of export settings and other keywords (like `#+LINK`) has been
combined and unified.
2020-06-29 20:53:25 +02:00
Albert Krewinkel
1480606174
Org reader: support LATEX_HEADER_EXTRA and HTML_HEAD_EXTRA settings
These export settings are treated like their non-extra counterparts,
i.e., the values are added to the `header-includes` metadata list.
2020-06-29 17:04:29 +02:00
Albert Krewinkel
d17b257c89
Org reader: allow multiple #+SUBTITLE export settings
The values of all lines are read as inlines and collected in the
`subtitle` metadata field.
2020-06-29 17:03:33 +02:00