Commit graph

15059 commits

Author SHA1 Message Date
Albert Krewinkel
b7a44f9d19 Copyright notices: update for 2022 2022-01-02 11:59:22 -08:00
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
John MacFarlane
6121de369c Use latest version of KaTeX. 2022-01-01 23:29:46 -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
b5da58e8b4
Apply some HLint suggestions 2022-01-01 20:22:24 +01:00
Albert Krewinkel
13740c4543
stack.yaml: add missing hslua-aeson entry to extra-deps 2022-01-01 17:02:07 +01:00
Albert Krewinkel
eae9be3a48
Org reader: allow trailing spaces after key/value pairs in directives
Ensures that spaces at the end of attribute directives like
`#+ATTR_HTML: :width 100%` (note the trailing spaces) are accepted.
2022-01-01 13:44:14 +01: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
d6e66b1f1d
Lua: cleanup stack in peekReadOptionsTable
A ReaderOptions element was left on top of the stack when the
`peekReadOptionsTable` function was invoked.
2021-12-31 11:02:16 +01:00
John MacFarlane
7ff1b798c4 Docx reader: handle multiple pic elements inside a drawing.
Closes #7786.
2021-12-30 21:26:30 -08:00
John MacFarlane
cc30d646ca Docx reader: change elemToParPart to return [ParPart]
...instead of ParPart.

Also remove NullParPart constructor, as it is no longer
needed.

This will allow us to handle elements that contain multiple
ParParts, e.g. w:drawing elements with multiple pic:pic.

See #7786.
2021-12-30 21:26:30 -08:00
John MacFarlane
4ff997bf68 Fix ghc 9.2.1 warnings. 2021-12-30 21:26:30 -08:00
John MacFarlane
2811468016 Use latest commonmark-hs.
This allows a bare-word class attribute on fenced divs,
as pandoc's Markdown reader now does.
2021-12-30 21:26:30 -08: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
ce7e1f5169 Fix macos build on GitHub actions release-candidate. 2021-12-29 23:31:49 -08:00
John MacFarlane
a6f62b2e79 Restore macos build on GitHub release-candidate action.
See #7767.
2021-12-29 16:45:16 -08:00
John MacFarlane
d960282b10 Use splitDirectories istead of splitPath.
We were using `splitPath` in two places in the code
where `splitDirectories` should have been used.

This led to a test for `..` in paths in `extractMedia`
failing, so that images with `..` in the path name
could be extracted outside the directory specified
by `extractMedia`.

It also led a test for `media` in resource paths to fail
in the docx reader.
2021-12-28 16:31:54 -08:00
John MacFarlane
7d56650e01 OpenDocument writer: fix vertical align bug with display math.
Previously some displayed formulas would be floated above
a preceding text line.  This is fixed by setting vertical-rel
to 'text' rather than 'paragraph-content'.

Closes #7777.
2021-12-28 16:06:25 -08:00
Albert Krewinkel
8bd22270c8
doc/lua-filters.md: improve documentation of make_sections 2021-12-28 12:35:22 +01:00
Albert Krewinkel
fbd2c8e376
Lua: improve handling of empty caption, body by from_simple_table
Create truly empty table caption and body when these are empty in the
simple table.

Fixes: #7776
2021-12-25 21:20:18 +01:00
Albert Krewinkel
e54f6dcd7a
JATS template: fix position of contrib affiliations in authoring set
Any `<aff>` element must come before any `<email>` element.
2021-12-23 19:09: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
John MacFarlane
43a8931abf Add markua test files to extra-source-files. 2021-12-22 12:02:20 -08:00
John MacFarlane
811601aa8b RTF writer: properly handle images in data URIs.
See #7771.
2021-12-22 11:59:07 -08:00
John MacFarlane
c4f6e6cb57 HTML writer: make line breaks more consistent.
- With `--wrap=none`, we now output line breaks between
  block-level elements. Previously they were omitted
  entirely, so the whole document was on one line, unless
  there were literal line breaks in pre sections.  This makes
  the HTML writer's behavior more consistent with that of
  other writers.

- Put newline after `<dd>`.

- Put newlines after block-level elements in footnote section.
2021-12-22 09:45:02 -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
Albert Krewinkel
0bdf373157
Lua: simplify code of pandoc.utils.stringify
Minor behavior change: plain strings nested in tables are now included
in the result string.
2021-12-21 21:50:13 +01:00
Albert Krewinkel
edb04a78db
Lua tests: add more tests for pandoc.utils.stringify. 2021-12-21 21:25:16 +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
1c389bf6b6
Lua: add tests for pandoc.utils.equals 2021-12-21 19:00:21 +01:00
John MacFarlane
8734057dff Put sourcepos attribute on header, not enclosing div...
with `-f commonmark+sourcepos`.

Closes #7769.
2021-12-21 09:55:17 -08: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
c90802d7d8
Lua: fix return types of blocks_to_inlines, make_sections
Ensures the returned lists have the correct type (`Inlines` and
`Blocks`, respectively).
2021-12-21 09:53:44 +01:00
Albert Krewinkel
cd2bffee1e
Lua: use more natural representation for Reference values
Omit `false` boolean values, push integers as numbers.
2021-12-20 09:41:03 +01:00
Albert Krewinkel
993222d2c9
Custom writer: assign default Pandoc object to global PANDOC_DOCUMENT
The default Pandoc object is now non-strict, i.e., only the parts of the
document that are accessed will be marshaled to Lua. A special type is
no longer necessary.

This change also makes it possible to use the global variable with
library functions such as `pandoc.utils.references`, or to inspect the
document contents with `walk()`.
2021-12-19 23:17:27 +01: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
f8f03c2ffc JATS writer: keep quotes in element-citations
The JATS writer was losing quotes in element-citations, as it uses the
`T.P.Citeproc.getReferences` function to get references. That function
replaces `Quoted` elements with spans. That transformation is required
in `T.P.Citeproc.processCitations`, so it has been moved there.
2021-12-19 12:03:01 -08:00
Albert Krewinkel
74c2d9eb07
doc/lua-filters: numbers are now accepted as MetaValue 2021-12-19 15:59:05 +01:00
Albert Krewinkel
dc3dcc2ccd
Lua: fixup, should have been part of previous commit 2021-12-19 14:31:52 +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
John MacFarlane
4b220d592c Citeproc: avoid adding comma before an author-in-text citation...
...in a note if it begins with a title (no author).

Closes #7761.
2021-12-18 12:13:06 -08:00
John MacFarlane
6b0a560ae7 Improve 'make check'. 2021-12-18 09:55:16 -08:00
John MacFarlane
bc947a4496 Use latest doctemplates, commonmark-extensions in stack.yaml. 2021-12-18 09:49:09 -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