From: Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Replace Str with HTML in Lua Filter
Date: Sat, 10 Aug 2019 18:02:30 +0200 [thread overview]
Message-ID: <8736i9qa95.fsf@zeitkraut.de> (raw)
In-Reply-To: <abe5ae45-2ad8-419b-a282-5b5e1b4fcda1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Ken Dow writes:
> My DOCX source document, which is being converted to HTML, uses some Google
> Material fonts. What shows up in the AST are values like
>
> Str "\8211"
>
> I'd like to find and replace those to produce something like the following
> HTML:
>
> <i class="material-icons">face</i>
>
> Is that possible and if so, how?
The way to go here is via `RawInline` elements, e.g.:
function Str (s)
if s.text == '–' then
return pandoc.RawInline(
'html',
'<i class="material-icons">face</i>'
)
end
end
Note matching on an exact string would fail if the character was
somewhere within a word (a typical would be em-dashes). One would have
to use the [utf8.codes] module to manually find and replace those
characters in that case.
[utf8.codes](https://www.lua.org/manual/5.3/manual.html#pdf-utf8.codes)
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8736i9qa95.fsf%40zeitkraut.de.
next prev parent reply other threads:[~2019-08-10 16:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-09 19:28 Ken Dow
[not found] ` <abe5ae45-2ad8-419b-a282-5b5e1b4fcda1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-08-10 16:02 ` Albert Krewinkel [this message]
[not found] ` <8736i9qa95.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2019-08-29 15:06 ` Ken Dow
[not found] ` <87a12669-ed81-4ce4-aa8e-eb5d3d64bf3d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-08-29 17:50 ` John MacFarlane
2019-08-29 17:51 ` John MacFarlane
[not found] ` <m2muframhm.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-08-29 20:24 ` Ken Dow
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8736i9qa95.fsf@zeitkraut.de \
--to=albert+pandoc-9eawchwdxg8hfhg+jk9f0w@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.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.
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 NNTP newsgroup(s).