From: "Thomas S. Dye" <tsd@tsdye.online>
To: emacs-orgmode@gnu.org
Subject: Re: A simple Lua filter for Pandoc
Date: Tue, 04 Jan 2022 06:28:36 -1000 [thread overview]
Message-ID: <8735m3a2iz.fsf@tsdye.online> (raw)
In-Reply-To: <875yqzu7rx.fsf@posteo.net>
Juan Manuel Macías <maciaschain@posteo.net> writes:
> Hi,
>
> Very often I need to convert docx documents to Org. There are a
> series
> of characters that I prefer to be passed to Org as Org entities
> and not
> literally, so I have written this little filter in Lua for
> Pandoc. I
> share it here in case it could be useful to someone. Of course,
> the
> associative table can be expanded with more replacement cases:
>
> #+begin_src lua :tangle entities.lua
> local chars = {["/"] = "\\slash{}", ["*"] = "\\lowast{}",
> ["<"] = "\\lt{}",
> [">"] = "\\gt{}", ["†"] = "\\dagger{}", [utf8.char(0x00A0)]
> = "\\nbsp{}"}
>
> function Str (elem)
> x = elem.text:match 'http[^%s]'
> if not x then
> for i in pairs(chars) do
> elem = pandoc.Str(elem.text:gsub (i, chars[i]))
> end
> return elem
> end
> end
> #+end_src
Neat! Converting Word documents is no fun at all.
BTW, Babel support for Lua isn't very good AFAICT. I poked around
ob-lua.el recently and concluded that one problem is that the Lua
interpreter prints pointers for some data types instead of a
human-readable form that might be parsed.
All the best,
Tom
--
Thomas S. Dye
https://tsdye.online/tsdye
prev parent reply other threads:[~2022-01-04 16:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-04 10:14 A simple Lua filter for Pandoc Juan Manuel Macías
2022-01-04 11:26 ` Timothy
2022-01-04 15:11 ` Juan Manuel Macías
2022-01-04 14:05 ` Max Nikulin
2022-01-04 15:06 ` Juan Manuel Macías
2022-01-05 16:29 ` Max Nikulin
2022-01-05 17:08 ` Juan Manuel Macías
2022-01-07 14:29 ` Max Nikulin
2022-01-07 15:14 ` Juan Manuel Macías
2022-01-04 16:28 ` Thomas S. Dye [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735m3a2iz.fsf@tsdye.online \
--to=tsd@tsdye.online \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).