Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pandoc behave like a Lua interpreter when called as pandoc-lua. #8311

Merged
merged 2 commits into from Sep 22, 2022

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Sep 22, 2022

A program name of pandoc-lua, e.g., when the binary was invoked through a symlink with that name, will make pandoc behave like a Lua interpreter: the first command line argument is run as a Lua script, and the remaining arguments are passed to the interpreter in the global table arg. Lua options are not supported yet.

@tarleb
Copy link
Collaborator Author

tarleb commented Sep 22, 2022

Todo:

  • docs
  • possibly add support for more CLI options
  • 🔜 medium term: extract the runScript function into an HsLua package
  • 🔜 medium term: ensure signals like SIGTERM are handled in the way that the lua binary handles them.
  • ❔ later: find a way to give script authors access to pandoc's cli parsing

@jgm
Copy link
Owner

jgm commented Sep 22, 2022

Nice. Is an interactive REPL possible?

@jgm
Copy link
Owner

jgm commented Sep 22, 2022

If we had a REPL, it might be worth adding some fancy pretty-printing of the userdata Haskell values, similar to https://github.com/wlupton/pandoc-lua-logging

@tarleb
Copy link
Collaborator Author

tarleb commented Sep 22, 2022

I'd like to do a REPL-less version first to avoid the need for an additional library (like haskeline). But it would be great to add one if the extra dependencies turn out to be small.

@jgm
Copy link
Owner

jgm commented Sep 22, 2022

I think you'd add the following dependencies with haskeline:
Win32 nats unbuildable stm semigroups
That's not huge. And assuming we split the package, these would only be dependencies of pandoc-cli, not pandoc library.

src/Text/Pandoc/Lua.hs Outdated Show resolved Hide resolved
@tarleb tarleb force-pushed the pandoclua branch 3 times, most recently from c846dd7 to caa329a Compare September 22, 2022 19:00
@tarleb tarleb marked this pull request as ready for review September 22, 2022 19:01
@tarleb
Copy link
Collaborator Author

tarleb commented Sep 22, 2022

The current state is quite usable already and ready to merge from my side.

I plan to write a "hslua-cli" package, with a proper REPL, in the not-too-distant future. But I'd like to finish some other things first (e.g., Markdown tables).

@tarleb tarleb force-pushed the pandoclua branch 2 times, most recently from 02eae65 to c4e6d58 Compare September 22, 2022 19:09
@jgm
Copy link
Owner

jgm commented Sep 22, 2022

Can you add a doc/pandoc-lua.md and adjust Makefile so it can be compiled to man/pandoc-lua.1 just as we now handle doc/pandoc-server.md?

@tarleb
Copy link
Collaborator Author

tarleb commented Sep 22, 2022

Done. 👍

BTW, to avoid complications, I'd like to limit support of the hslua-cli package to Lua 5.4. This would mean that we'd need to drop support for the lua53 flag at that point.

@tarleb tarleb changed the title Make exe behave like a lua interpreter when called as pandoc-lua. Make exe behave like a Lua interpreter when called as pandoc-lua. Sep 22, 2022
@tarleb tarleb changed the title Make exe behave like a Lua interpreter when called as pandoc-lua. Make pandoc behave like a Lua interpreter when called as pandoc-lua. Sep 22, 2022
@jgm jgm merged commit 22fa51d into jgm:master Sep 22, 2022
@tarleb tarleb deleted the pandoclua branch September 23, 2022 06:15
@tarleb
Copy link
Collaborator Author

tarleb commented Sep 23, 2022

I've extracted most of the code to the new package hslua-cli and fixed some more issues along the way. I'm dabbling with haskeline and may try isocline as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants