Commit Graph
8122 Commits
Author SHA1 Message Date
John MacFarlane 7312e36104 Extensions: simpler implementation based on Set.
This implementation would allow us (if we wanted) to add
an extensible Ext_custom Text constructor.
2022-10-13 23:36:25 -07:00
John MacFarlane cc8ed74c25 FlavoredFormat: add Show, Semigroup, Monad instances 2022-10-13 23:36:25 -07:00
John MacFarlane f486fcde13 Rollback parameterize options on scripting engine.
Rolls back 0ab014ed1e.
We don't need this because we aren't needing to print the Lua
version in options any more; we're handling `--version` now at
the pandoc-cli level.
2022-10-13 17:59:49 -07:00
Albert Krewinkel 253d2e768a Lua: support extensions in custom readers.
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,
}
```
2022-10-12 11:58:18 +02:00
Albert Krewinkel 3cac33bdd2 Templates: use filename to search for default template of custom writers
The default template of a custom writer `/path/to/my-writer.lua` is
expected in the `templates/default.my-writer.lua` data file. Note that
templates are *not* applied automatically to the output of custom
writers; custom writer authors must ensure that the template is applied
if one is present in the writer options.

Closes: #8137
2022-10-11 18:19:31 +02:00
Albert Krewinkel 4a97f5799a Templates: do not try to normalize input to getDefaultTemplate
The function `getDefaultTemplate` no longer splits off extension
modifers from the given format, as that conflicts with using custom
writers as formats. Haskell library users should use `getDefaultTemplate
<=< (fmap formatName . parseFlavoredFormat)` if the input format can
still contain extensions. The same is true for `compileDefaultTemplate`,
which calls `getDefaultTemplate` internally.
2022-10-11 18:17:25 +02:00
John MacFarlane 1612cc3bf4 Simplify some citation code in LaTeX writer. 2022-10-10 21:17:56 -07:00
Albert Krewinkel a088cbf563 Lua: support extensions in custom writers
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,
    }
2022-10-10 09:39:18 -07:00
Amir Dekel 31aa660e65 Org reader: make #+pandoc-emphasis-pre work as expected. (#8360)
So far, `orgStateLastPreCharPos` wasn't updated appropriately after each
parsing to native Str (by the parser `str`). In addition to solving
this, the guard `notAfterString` in `emphasisStart` is removed to allow
emphasis after Str at the first place.
2022-10-10 12:20:58 +02:00
Albert Krewinkel d6fb8fb20f Remove redundant import from T.P.Scripting 2022-10-10 09:25:01 +02:00
Albert Krewinkel 3e1d3b5e5e Lua: use Reader type for custom readers. 2022-10-10 09:13:09 +02:00
John MacFarlane 5d858e4119 HTML writer; Properly merge classes for headings of level > 6.
Previously we got two separate `class` attributes in the `p`
tag. Closes #8363.
2022-10-09 16:04:36 -07:00
Albert Krewinkel 5589b1f8f9 [API Change] Change argument type of getReader, getWriter.
The functions now take a `FlavoredFormat` instead of a text argument.
2022-10-08 16:05:48 -07:00
Albert Krewinkel a4218b9719 [API Change] Add new module "Text.Pandoc.Format"
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.
2022-10-08 16:05:48 -07:00
Albert Krewinkel e663bb0e14 [API Change] T.P.Error: Add new constructor "PandocFormatError"
The new error is used to report problems with input or output format
specifications.

The use of PandocAppError is now limited to code in T.P.App and
T.P.Citeproc.
2022-10-08 16:05:48 -07:00
Albert Krewinkel 429606d5da Extensions: add new function readExtension
The function tries to read an extension from a string.
2022-10-08 16:05:48 -07:00
Albert Krewinkel 7b7a7d6742 LaTeX writer: add separator line between table's body and its foot.
The writer uses features from the longtable package to define the table
foot. Furthermore, the table's bottom rule is now part of the foot,
where it previously was given as part of the body.
2022-10-06 22:07:25 +02:00
John MacFarlane b05c380f6f HTML writer: replace deprecated aria roles for bibliography entries.
`doc-biblioentry` -> `listitem`
`doc-bibliography` -> `list`

Closes #8354.
2022-10-05 11:58:50 -07:00
Albert Krewinkel 9e3a2e0dde Extensions: fix JSON decoding of Extensions
Closes: #8352
2022-10-05 12:40:59 +02:00
John MacFarlane 87bff28298 Removed some final blank lines. 2022-10-04 21:48:17 -07:00
John MacFarlane 42566afa3f Rename T.P.Readers.LaTeX.Types -> T.P.TeX. 2022-10-03 22:49:22 -07:00
John MacFarlane d5c7996e21 Rename T.P.Network.HTTP -> T.P.URI.
This is still an unexported internal module.
Export `urlEncode`, `escapeURI`, `isURI`, `schemes`, `uriPathToPath`.

Re-export `escapeURI` and `isURI` from T.P.Shared (as they
were exported before); drop exports of `schemes` and `uriPathToPath`
[API change].

With this change, T.P.Class no longer depends on T.P.Shared.
2022-10-03 22:32:19 -07:00
John MacFarlane ad0532244a Separate out T.P.Data, T.P.Translations from T.P.Class. (#8348)
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`.
2022-10-03 13:05:38 -07:00
Albert Krewinkel 309163f5bc [API Change] Base custom writers on Writer type.
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.
2022-10-03 08:47:32 -07:00
John MacFarlane d9004c9e5c Officially deprecate writeJATS...
in favor of writeJatsArchiving.
2022-10-02 11:21:06 -07:00
John MacFarlane 8b004e0c26 Add T.P.Citeproc.Name.
This exports `toName`, which previously had been part of
T.P.Citeproc.BibTeX.  T.P.Readers.RIS,EndNote can now depend on
this module without transitively depending on the LaTeX reader,
which is used in T.P.Citeproc.BibTeX.

Closes #8345.
2022-10-02 10:59:14 -07:00
John MacFarlane dd07d8002f JATS writer: use <break/> for LineBreak...
in the limited contexts that accept it.

Closes #8344.
2022-10-01 17:46:13 -07:00
John MacFarlane aa0e9c4d6e Move --version handling to pandoc-cli.
Print flag settings (lua, server) and versions of all relevant packages.
Add suffix for nightly builds.

Move `nightly` flag from pandoc to pandoc-cli.

Closes #8339.
2022-09-30 16:46:39 -07:00
Albert Krewinkel 1148ead64c App: move initial input-to-Pandoc code to internal submodule 2022-09-30 23:42:41 +02:00
Albert Krewinkel 5be9052f5f [API Change] Extract Lua code into new package pandoc-lua-engine
The flag 'lua53` must now be used with that package if pandoc is to be
compiled against Lua 5.3.
2022-09-30 08:33:40 -07:00
Albert Krewinkel 79980eee4a [API Change] Parameterize convertWithOpts over scripting engine. 2022-09-30 08:33:40 -07:00
Albert Krewinkel eaf702a10f Change imports in Lua code to only use exported pandoc modules 2022-09-30 08:33:40 -07:00
Albert Krewinkel a20b92097a App: stop including the HsLua version in version info output 2022-09-30 08:33:40 -07:00
Albert Krewinkel 0ab014ed1e [API Change] App: parameterize options over the scripting engine 2022-09-30 08:33:40 -07:00
Albert Krewinkel 78814f27e0 [API Change] Filter: Parameterize applyFilters over scripting engine.
Pass the scripting engine as a parameter so it can be swapped out.
2022-09-30 08:33:40 -07:00
Albert Krewinkel 4d365ca3ff [API Change] Lua: export new function T.P.Lua.getEngine
The function returns the Lua scripting engine.
2022-09-30 08:33:40 -07:00
Albert Krewinkel 04902d26da [API Change] Change type of Text.Pandoc.Lua.applyFilter
The module Text.Pandoc.Filter.Lua has been merged into Text.Pandoc.Lua.
The function `applyFilter` now has type

``` haskell
applyFilter :: (PandocMonad m, MonadIO m)
            => Environment-> [String]-> FilePath-> Pandoc-> m Pandoc
```

where `Environment` is defined in Text.Pandoc.Filter.Environment.
2022-09-30 08:33:40 -07:00
Albert Krewinkel 0e947c7473 [API Change] Filter: export function applyJSONFilter 2022-09-30 08:33:40 -07:00
Albert Krewinkel 084e246126 [API Change] Remove modules T.P.Writers.Custom and T.P.Readers.Custom.
The functions `writeCustom` and `readCustom` are available from module
Text.Pandoc.Lua.
2022-09-30 08:33:40 -07:00
Albert Krewinkel 14bcb4268b [API Change] Add new error constructor PandocNoScriptingEngine.
The exit code for this error is 89.
2022-09-30 08:33:40 -07:00
Albert Krewinkel 704f337697 [API Change] Export new module Text.Pandoc.Scripting
The module contains the central data structure for scripting engines.
2022-09-30 08:33:40 -07:00
Albert Krewinkel ddaadc88bc [API Change] Rename pandocVersion to pandocVersionText...
and add a new `pandocVersion` value with type `Version`. This is
consistent with the type used for `pandocTypesVersion` and allows to use
the value where a Version type is required.
2022-09-30 08:33:40 -07:00
John MacFarlane e099de1d4d Factor out xml-light into an internal library. 2022-09-29 10:53:16 -07:00
John MacFarlane 931ccd0376 Remove deprecated option --strip-empty-paragraphs. 2022-09-29 10:37:46 -07:00
John MacFarlane 6227144216 Remove deprecated --atx-headers option. 2022-09-29 10:29:29 -07:00
John MacFarlane 48d0bfc675 Add --list-tables option.
[API change] Add writerListTables to WriterOptions.

RST writer: Remove sensitivity to "list-table" class in table attributes.
Instead, just check `writerListTables` in writer options.

See #4564.
2022-09-29 10:20:58 -07:00
danse c974ed0cae rST writer: list tables rendering, closes #4564
When a table is marked with a "list-table" attribute class, it will
now be rendered using the list table syntax documented here
http://docutils.sourceforge.net/docs/ref/rst/directives.html#list-table
2022-09-29 09:56:00 -07:00
John MacFarlane 1393037f4e LaTeX writer: use \includesvg for SVGs...
...and include the `svg` package.
Closes #8334.
2022-09-29 09:31:39 -07:00
Justin Wood 740396d1ed HTML Reader: Tests for 'tt' and 'code' elements (#8330).
tt is a deprecated element in HTML, but is still used in the wild in
some places, support reading it as just another 'code' element.

Commit 4abb9d0ad8 was originally
part of this PR as well.
2022-09-28 14:04:07 -07:00
John MacFarlane 4abb9d0ad8 HTML reader: fix regression for <tt>.
It was no longer being parsed as Code.

See #8330.
2022-09-28 13:45:48 -07:00