public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Filter help: apply LaTeX command to words matching pattern
@ 2022-11-28 19:53 Adin Klotz
       [not found] ` <CAFy2Trs7g+84uDfLAYOa+FZm7YmXfwCUiFiTbcCwyN56KEv8nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Adin Klotz @ 2022-11-28 19:53 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

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 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/CAFy2Trs7g%2B84uDfLAYOa%2BFZm7YmXfwCUiFiTbcCwyN56KEv8nQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 1696 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Filter help: apply LaTeX command to words matching pattern
       [not found] ` <CAFy2Trs7g+84uDfLAYOa+FZm7YmXfwCUiFiTbcCwyN56KEv8nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-11-28 20:07   ` Bastien DUMONT
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien DUMONT @ 2022-11-28 20:07 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-28 20:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28 19:53 Filter help: apply LaTeX command to words matching pattern Adin Klotz
     [not found] ` <CAFy2Trs7g+84uDfLAYOa+FZm7YmXfwCUiFiTbcCwyN56KEv8nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-11-28 20:07   ` Bastien DUMONT

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).