| Age | Commit message (Collapse) | Author |
|
The function returns the CPU time consumed by pandoc and can be used to
benchmark Lua computations.
|
|
Closes: #8605
|
|
The PathTemplate type exported from Text.Pandoc.Chunks is now an
instance of the ToJSON and FromJSON classes.
Closes: #8607
|
|
Otherwise sections are always numbered in the TOC,
even if `--number-sections` is not used.
|
|
This simplifies the creation of custom readers and writers that are
based on built-in formats.
|
|
Allows to write the complete mediabag or just a specific file to a given
directory.
|
|
Adds support for table of contents and chunks handling. The function
`make_sections` has been given a friendlier interface and was moved to
the new module; the old `pandoc.utils.make_sections` has been
deprecated.
|
|
It has been removed from pandoc-types.
|
|
Thanks and credit go to Aner Lucero, who laid the groundwork for this
feature in the 2021 GSoC project. He contributed many changes, including
modifications to the readers for HTML, JATS, and LaTeX, and to the HTML
and JATS writers.
Shared (Albert Krewinkel):
- The new function `figureDiv`, exported from `Text.Pandoc.Shared`,
offers a standardized way to convert a figure into a Div element.
Readers (Aner Lucero):
- HTML reader: `<figure>` elements are parsed as figures, with the
caption taken from the respective `<figcaption>` elements.
- JATS reader: The `<fig>` and `<caption>` elements are parsed into
figure elements, even if the contents is more complex.
- LaTeX reader: support for figures with non-image contents and for
subfigures.
- Markdown reader: paragraphs containing just an image are treated as
figures if the `implicit_figures` extension is enabled. The identifier
is used as the figure's identifier and the image description is also
used as figure caption; all other attributes are treated as belonging
to the image.
Writers (Aner Lucero, Albert Krewinkel):
- DokuWiki, Haddock, Jira, Man, MediaWiki, Ms, Muse, PPTX, RTF, TEI,
ZimWiki writers: Figures are rendered like Div elements.
- Asciidoc writer: The figure contents is unwrapped; each image in the
the figure becomes a separate figure.
- Classic custom writers: Figures are passed to the global function
`Figure(caption, contents, attr)`, where `caption` and `contents` are
strings and `attr` is a table of key-value pairs.
- ConTeXt writer: Figures are wrapped in a "placefigure" environment
with `\startplacefigure`/`\endplacefigure`, adding the features
caption and listing title as properties. Subfigures are place in a
single row with the `\startfloatcombination` environment.
- DocBook writer: Uses `mediaobject` elements, unless the figure contains
subfigures or tables, in which case the figure content is unwrapped.
- Docx writer: figures with multiple content blocks are rendered as
tables with style `FigureTable`; like before, single-image figures are
still output as paragraphs with style `Figure` or `Captioned Figure`,
depending on whether a caption is attached.
- DokuWiki writer: Caption and "alt-text" are no longer combined. The
alt text of a figure will now be lost in the conversion.
- FB2 writer: The figure caption is added as alt text to the images in
the figure; pre-existing alt texts are kept.
- ICML writer: Only single-image figures are supported. The contents of
figures with additional elements gets unwrapped.
- HTML writer: the alt text is no longer constructed from the caption,
as was the case with implicit figures. This reduces duplication, but
comes at the risk of images that are missing alt texts. Authors should
take care to provide alt texts for all images.
Some readers, most notably the Markdown reader with the
`implicit_figures` extension, add a caption that's identical to the
image description. The writer checks for this and adds an
`aria-hidden` attribute to the `<figcaption>` element in that case.
- JATS writer: The `<fig>` and `<caption>` elements are used write
figures.
- LaTeX writer: complex figures, e.g. with non-image contents and
subfigures, are supported. The `subfigure` template variable is set if
the document contains subfigures, triggering the conditional loading
of the *subcaption* package. Contants of figures that contain tables
are become unwrapped, as longtable environments are not allowed within
figures.
- Markdown writer: figures are output as implicit figures if possible,
via HTML if the `raw_html` extension is enabled, and as Div elements
otherwise.
- OpenDocument writer: A separate paragraph is generated for each block
element in a figure, each with style `FigureWithCaption`. Behavior for
single-image figures therefore remains unchanged.
- Org writer: Only the first element in a figure is given a caption;
additional block elements in the figure are appended without any
caption being added.
- RST writer: Single-image figures are supported as before; the contents
of more complex images become nested in a container of type `float`.
- Texinfo writer: Figures are rendered as float with type `figure`.
- Textile writer: Figures are rendered with the help of HTML elements.
- XWiki: Figures are placed in a group.
Co-authored-by: Aner Lucero <[email protected]>
|
|
Rationale: we need this splitting level now not just in
EPUB but in chunked HTML.
`--epub-chapter-level` will still function as a deprecated
synonynm. `epub-chapter-level` will also continue to work in
defaults files, ande `epub_chapter_level` will still work for
Lua marshalling.
[API changes]
Text.Pandoc.App.Opt: remove `optEpubChapterLevel`, add
`optSplitLevel`.
Text.Pandoc.Options: remove `writerEpubChapterLevel`, add
`writerSplitLevel`.
|
|
|
|
The new type CustomComponents is exported from T.P.Scripting, and the
ScriptEngine fields are changed. Instead of separate fields for custom
readers and writers, we now have a single function that loads any number
of "components" from a script: these may be custom readers, custom
writers, templates for writers, or extension configs. (Note: it's
possible to have a custom reader and a custom writer for a format
together in the same file.)
Pandoc now checks the folder `custom` in the user's data directory for a
matching script if it can't find one in the local directory. Previously,
the `readers` and `writers` data directories were search for custom
readers and writers, respectively. Scripts in those directories must be
moved to the `custom` folder.
Custom readers used to implement a fallback behavior that allowed to
consume just a string value as input to the `Reader` function. This has
been removed, the first argument is now always a list of sources. Use
`tostring` on that argument to get a string.
Closes #8417.
Signed-off-by: Albert Krewinkel <[email protected]>
|
|
This change also affects the `pandoc.utils.blocks_to_inlines` Lua
function.
Closes: #8499
|
|
This allows to pass structured values as format specifiers to
`pandoc.write` and `pandoc.read`.
|
|
Allow processing of CLI options in Lua.
|
|
A new error `PandocNoTemplateError` (code 87) is thrown if a template is
required but cannot be found.
|
|
|
|
|
|
This allows to use a string as parameter to `pandoc.template.apply` and
in the WriterOptions `template` field.
Closes: #8321
|
|
...as `Extensions`.
Update documnetation.
Include a custom extension in the documentation example.
See #8390.
|
|
This can be used to reduce boilerplate in custom writers.
|
|
This is not used and is not an exported function; it's dead code.
@tarleb if there is some reason to keep this here, please feel
free to revert this.
|
|
T.P.Extensions [API change]:
+ Add CustomExtension constructor to Extension.
+ Remove Bounded, Enum instances for Extension.
+ Add `extensionsToList` function.
+ Revise `readExtension` so it can handle CustomExtension, and so
that it returns a Text rather than Maybe Text.
+ Add `showExtension`.
T.P.Format:
+ Revise error checking to handle CustomExtension.
|
|
Allows to handle docx and epub files.
|
|
This new module exports `pandocVersion` and `pandocVersionText`,
which are no longer exported from Text.Pandoc.Shared. [API change]
Also, we now set the `pandoc-version` variable centrally rather
than in the writers. One effect is the man writer now emits
a comment with the pandoc version (this was intended before,
judging from the template, but it didn't happen because the
vairable wasn't set).
|
|
Otherwise the `Error running Lua` message can be prepended multiple
times.
|
|
String error messages were incorrectly popped of the stack when
retrieving a PandocError.
|
|
Custom writers can define a default template via a global `Template`
function; the data directory is no longer searched for a default
template.
Writer authors can restore the old lookup behavior with
``` lua
Template = function ()
local template
return template.compile(template.default(PANDOC_SCRIPT_FILE))
end
```
|
|
The functions converts Meta values to template contexts; the intended
use is in combination with `pandoc.template.apply`.
|
|
Like custom readers, like writers, can define the set of supported
extensions by setting a global. E.g.:
``` lua
reader_extensions = {
smart = true,
citations = false,
}
```
|
|
The specialized peeker and pusher function for `Context Text` values
does not go via JSON, and thus keeps Doc values unchanged during
round-tripping.
|
|
The new function applies a context, containing variable assignments, to
a template.
|
|
Custom writers can define the extensions that they support via the
global `writer_extensions`. The variable's value must be a table with
all supported extensions as keys, and their default status as values.
E.g., the below specifies that the writer support the extensions `smart`
and `sourcepos`, but only the `smart` extension is enabled by default:
writer_extensions = {
smart = true,
sourcepos = false,
}
|
|
|
|
|
|
The functions now take a `FlavoredFormat` instead of a text argument.
|
|
The module provides functions and types for format spec parsing and
processing.
The function `parseFormatSpec` was moved from Text.Pandoc.Extensions to
the new module and renamed to `parseFlavoredFormat`. It now operates in
a PandocMonad and is based on the updated types.
|
|
Ensures a cleaner module dependency graph.
|
|
Errors are reported in Lua in the same words in which they would be
reported in the terminal.
|
|
The module provides functions to query the set of extensions supported
by formats, and the set of extension enabled per default.
|
|
|
|
This makes T.P.Class more self-contained, and suitable for extraction
into a separate package if desired.
[API changes]
- T.P.Data is now an exported module, providing `readDataFile`,
`readDefaultDataFile` (both formerly provided by T.P.Class),
and also `getDataFileNames` (formerly unexported in
T.P.App.CommandLineOptions).
- T.P.Translations is now an exported module (along with
T.P.Translations.Types), providing `readTranslations`,
`getTranslations`, `setTranslations`, `translateTerm`,
`lookupTerm`, `readTranslations`, `Term(..)`, and `Translations`.
- T.P.Class: `readDataFile`, `readDefaultDataFile`, `setTranslations`,
and `translateTerm` are no longer exported.
`checkUserDataDir` is now exported.
- Text.Pandoc now exports Text.Pandoc.Data and `setTranslations`
and `translateTerm`.
|
|
New-style custom Lua writers can now define an alternative entry function
`BinaryWriter`. If a function with that name is defined, then pandoc
will treat the returned string as binary output. This allows to generate
formats like docx and odt with custom writers.
|
|
The `T.P.Lua.writeCustom` function changed to allow either a TextWriter
or ByteStringWriter to be returned. The global variables
`PANDOC_DOCUMENT` and `PANDOC_WRITER_OPTIONS` are no longer set when the
writer script is loaded. Both variables are still set in classic writers
before the conversion is started, so they can be used when they are
wrapped in functions.
|
|
The function can be used to convert a classic writer into a new-style
writer by setting it as the value of `Writer`:
``` lua
Writer = pandoc.write_classic
```
or to fully restore the old behavior:
``` lua
function Writer (doc, opts)
PANDOC_DOCUMENT = doc
PANDOC_WRITER_OPTIONS = opts
load(PANDOC_SCRIPT_FILE)()
return pandoc.write_classic(doc, opts)
end
```
|
|
|
|
The flag 'lua53` must now be used with that package if pandoc is to be
compiled against Lua 5.3.
|