public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Bastien DUMONT <bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Filter help: apply LaTeX command to words matching pattern
Date: Mon, 28 Nov 2022 20:07:44 +0000	[thread overview]
Message-ID: <Y4UVEL2T+Nlv53bi@localhost> (raw)
In-Reply-To: <CAFy2Trs7g+84uDfLAYOa+FZm7YmXfwCUiFiTbcCwyN56KEv8nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

You have to insert the LaTeX code as RawInlines and to return a table of Inlines containing them. For instance:

```
local should_be_lining(str)
  -- returns true if str.text matches one of the patterns
end

function Str(str)
  if should_be_lining(str) then
    return { pandoc.RawInline('latex', '\\liningnums{'), str, pandoc.RawInline('latex', '}') }
  end
end
```

Le Monday 28 November 2022 à 02:53:48PM, Adin Klotz a écrit :
> Background: I like the look of old-style numerals in text, but they look bad in
> acronyms or other all-caps blocks, so I’d like to switch to lining numerals
> there. I couldn’t find an all-LaTeX way to do this so simplest way seemed to be
> a filter. I want to match words containing and only containing capital letters
> and numbers and surround them with \liningnums{}
> 
> For example:
> NUMBER1 -> \liningnums{NUMBER1}
> 2022 -> 2022
> A1B2C3 -> \liningnums{A1B2C3}
> A1b2c3 -> A1b2c3
> 
> I’ve played around a bit but don’t know enough Lua or Pandoc internals to get
> there. I have patterns to check the words but haven’t managed to successfully
> add the latex macro. Can someone point me in the right direction?
> 
> Thanks!
> 
> --
> 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 [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [2]https://groups.google.com/d/msgid/
> pandoc-discuss/
> CAFy2Trs7g%2B84uDfLAYOa%2BFZm7YmXfwCUiFiTbcCwyN56KEv8nQ%40mail.gmail.com.
> 
> References:
> 
> [1] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] https://groups.google.com/d/msgid/pandoc-discuss/CAFy2Trs7g%2B84uDfLAYOa%2BFZm7YmXfwCUiFiTbcCwyN56KEv8nQ%40mail.gmail.com?utm_medium=email&utm_source=footer

-- 
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/Y4UVEL2T%2BNlv53bi%40localhost.


      parent reply	other threads:[~2022-11-28 20:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 19:53 Adin Klotz
     [not found] ` <CAFy2Trs7g+84uDfLAYOa+FZm7YmXfwCUiFiTbcCwyN56KEv8nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-11-28 20:07   ` Bastien DUMONT [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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y4UVEL2T+Nlv53bi@localhost \
    --to=bastien.dumont-vwifzpto/vqstnjn9+bgxg@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).