38 Commits
Author SHA1 Message Date
John MacFarlane 19c1f6552b pandoc-cli: rearrange build.
Hackage rejected the previous version, though it worked fine.
The problem was that with two pandoc.hs files in different
directories, one of them wasn't being included in the sdist tarball.

To work around this, put the WASM exported functions in a
library module that is conditionally imported.
2026-02-04 00:44:15 +01:00
John MacFarlane f91faefbeb wasm: change interface.
We now provide two functions: convert and query.
extensions_for_format has been dropped, as query can do the
work.

convert is what pandoc used to be.

query takes a JSON object describing the information needed,
and returns information. Currently only "extensions-for-format"
is implemented.

Also: the use of multiple main-is causes problems with cabal.
Instead, we use pandoc.hs as main throughout, but change the
hs-src-dir for wasm.
2026-02-02 11:58:18 +01:00
John MacFarlane 648999286d wasm: Rename wasm_main -> convert. 2026-02-02 09:12:14 +01:00
John MacFarlane 45241fe784 pandoc-wasm: factor out getCString pattern. 2026-02-02 09:00:03 +01:00
John MacFarlane e59d5444dd Document pandoc-wasm functions. 2026-02-01 14:50:50 +01:00
John MacFarlane 4b26f50118 Add support for compiling pandoc.wasm.
'make pandoc.wasm' will compile a wasm version of pandoc.

This also adds a 'repl' flag to pandoc-lua-engine, so that
support for a Lua repl can be disabled for the wasm build.

A new wasm directory contains:

- pandoc.js, a JavaScript wrapper for pandoc.wasm
- index.html + index.js, a web app exposing all of pandoc's
  functionality in a GUI interface
- a set of illustrative examples that can be loaded from the web app

Most of the code in index.html and index.js has been produced in
interaction with Claude code.
2026-02-01 14:50:50 +01:00
John MacFarlane ee4c9352ee Remove code duplication around version info.
Text.Pandoc.App.CommandLineOptions and pandoc-cli/src/pandoc.hs
had similar code for generating version information.

To avoid duplication, we now export `versionInfo` from
Text.Pandoc.App [API change]. (The function is reexported from the
non-public module Text.Pandoc.App.CommandLineOptions.)  This function
has three parameters that can be filled in when it is called by
pandoc-cli.

This change will make it simpler to revise version information.
2025-07-13 22:47:11 -07:00
John MacFarlane cff9ace0db Revert "Export copyrightMessage from Text.Pandoc.App module."
This reverts commit 2cf9b55421.
2025-07-13 22:46:10 -07:00
John MacFarlane 2cf9b55421 Export copyrightMessage from Text.Pandoc.App module.
Export `copyrightMessage` from the unexported module
Text.Pandoc.App.CommandLineOptions
and reexport from Text.Pandoc.App [API change].

This avoids the need for a duplicated version in pandoc-cli, which can
now depend on the library's exported version.
2025-07-13 12:33:32 -07:00
John MacFarlane 2e3cb483e9 Use hardcoded string "pandoc" for program name in --version.
Per GNU guidelines:
https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html
2025-07-13 12:23:56 -07:00
Albert Krewinkel 522302a97e pandoc-cli: Refer printing of version info to the Lua interpreter
The Lua interpreter no longer terminates when called with `-v` or
`--version` arguments, thus improving compatibility with the default
`lua` interpreter program.
2024-06-28 10:03:14 +02:00
John MacFarlane 03630a2c6e Update copyright dates to 2024. 2024-04-25 18:16:49 -07:00
John MacFarlane 1904fa53fa pandoc-cli: ensure UTF8 when emitting version info. 2024-04-25 17:49:38 -07:00
John MacFarlane bec5429e4f Fix regression on short boolean arguments.
In 3.1.5 boolean arguments were allowed an optional argument
(true|false).  This created a regression for uses of fused
short arguments, e.g. `-somyfile.html`, which was equivalent
to `-s -omyfile.html`, but now raised an error because
pandoc attempted to parse `o` as a boolean `true` or `false`.

This change adds a preprocessing step on the raw arguments
before they are sent to the option parser. In this preprocessing
step, `-somyfile.html` would be split into two arguments,
`-s` and `-omyfile.html`.  The splitting happens when a
short boolean option is followed by another short option.

Closes #8956.
2023-07-19 11:56:58 -07:00
Andreas Scherer 6da429f829 Purge double space. 2023-04-05 07:52:52 -07:00
Albert Krewinkel b55cd83a60 Update copyright years, it's 2023! 2023-01-10 20:28:27 +01:00
John MacFarlane 848f6b51b2 Text.Pandoc.App: Change parseOptionsFromArgs and parseOptions... (#8406)
They now return `Either OptInfo Opt`.

Add `OptInfo` type.

Add `handleOptInfo` function.  This performs the IO actions for
things like `--version` that were previously done in `parseOptionsFromArgs`.
An argument for a `ScriptingEngine` has been added, to facilitate
printing custom templates and custom extensions for Lua filters.
(However, at this stage nothing is yet done with it.)

[API change]
2022-11-02 19:07:22 -07:00
John MacFarlane 3e48d9701d Re-add TemplateHaskell pragma in pandoc-cli.
This was an hlint false positive.
2022-10-31 09:03:10 -07:00
John MacFarlane 8b3be07ae8 hlint suggestions. 2022-10-30 11:02:00 -07:00
John MacFarlane 2e1f424daa Move defaultUserDataDir from T.P.Shared to T.P.Data [API change]. 2022-10-19 10:48:49 -07:00
John MacFarlane fde8635a18 Split Text.Pandoc.Version from Text.Pandoc.Shared.
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).
2022-10-19 09:16:13 -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
John MacFarlane 42b6e3907c Fix nightly flag build. 2022-10-01 09:56:50 -07:00
John MacFarlane 215d62ccd6 Remove build versions info from --version output. 2022-09-30 17:18:15 -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 cfc2024d37 Use server as command to start the pandoc server 2022-09-30 18:41:51 +02:00
Albert Krewinkel b6a571d577 pandoc-cli: Allow building a binary without Lua support
Disabling the `lua` cabal flag will result in a binary without Lua.
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 0ab014ed1e [API Change] App: parameterize options over the scripting engine 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
Albert Krewinkel efecff1f2f pandoc-cli: support -E flag in pandoc-lua 2022-09-27 08:42:27 -07:00
Albert Krewinkel 175b791529 pandoc-cli: support "lua" and "serve" as commands
Pandoc behaves like `pandoc-lua` and `pandoc-server` if the first
argument is `lua` and `serve`, respectively.
2022-09-27 08:42:27 -07:00
Albert Krewinkel a3fd6c674d pandoc-cli: update to hslua-cli-1.2 2022-09-27 08:42:27 -07:00
Albert Krewinkel 2bad9a9aa4 pandoc-cli: Avoid the CPP language extension
Alternative behavior for the *server* flag is implemented by using
separate modules.
2022-09-27 08:42:27 -07:00
John MacFarlane 13ee8b82da Add server flag to pandoc-cli.
This allows the executable to be built without support for
"server mode."
2022-09-26 09:25:54 -07:00
Albert Krewinkel e3648357cf Use hslua-cli package for pandoc-lua interface 2022-09-23 22:26:37 +02:00
Albert Krewinkel 22fa51ded1 Make pandoc behave like a Lua interpreter when called as pandoc-lua. (#8311) 2022-09-22 14:39:25 -07:00
John MacFarlane bd1d923b86 Split pandoc-server, pandoc-cli into separate packages. (#8309)
This also removes the unnecessary Setup.hs from pandoc.
Cabal does not need this with build-type 'simple'.
2022-09-22 09:47:07 -07:00