public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Changing LaTeX output for citations inside footnotes
@ 2022-07-25 19:46       ` Lyndon Drake
       [not found]         ` <bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-25 19:46 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1404 bytes --]

Hi,

So this is a slightly odd request, which really comes because of the 
unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
that style, \textcite inside a footnote produces an unwanted result. \cite 
produces the expected output. I have generally just gone through and 
hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
stage, but that's painful, and I also thought that maybe this is possible 
to do in a Lua filter.

But I don't quite know where to start - obviously this is a bit different 
from the internal Pandoc citations. I'm going to begin the filter with this:

if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
function 

but what would the function be? If it is Footnote, then I don't really want 
the AST, I want the LaTeX that forms the footnote contents, and I suppose 
then I can just replace any occurrences of the string \textcite with the 
string \cite?

Any help would be awesome!

Best,
Lyndon

-- 
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/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2016 bytes --]

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

* AW: Changing LaTeX output for citations inside footnotes
       [not found]         ` <bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-25 21:02           ` denis.maier-NSENcxR/0n0
       [not found]             ` <ea8df9c4b2d1418882909bb8a789d95f-NSENcxR/0n0@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-07-25 21:02 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I can't come up with a code example now, bit you can use the walk function (https://pandoc.org/lua-filters.html#type-block:walk) to modify the citations with a given mode inside notes. You'll need to build the citation via Pandoc.RawInline
Maybe that would be a good example of a new style Lua writer.
________________________________________
Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon Drake <isenguard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Gesendet: Montag, 25. Juli 2022 21:46:28
An: pandoc-discuss
Betreff: Changing LaTeX output for citations inside footnotes

Hi,

So this is a slightly odd request, which really comes because of the unusual behaviour of the specific BibLaTeX bibliography style I'm using. In that style, \textcite inside a footnote produces an unwanted result. \cite produces the expected output. I have generally just gone through and hand-edited my Pandoc-produced LaTeX files when they get to the final copy stage, but that's painful, and I also thought that maybe this is possible to do in a Lua filter.

But I don't quite know where to start - obviously this is a bit different from the internal Pandoc citations. I'm going to begin the filter with this:

if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> function

but what would the function be? If it is Footnote, then I don't really want the AST, I want the LaTeX that forms the footnote contents, and I suppose then I can just replace any occurrences of the string \textcite with the string \cite?

Any help would be awesome!

Best,
Lyndon

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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/ea8df9c4b2d1418882909bb8a789d95f%40unibe.ch.


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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]             ` <ea8df9c4b2d1418882909bb8a789d95f-NSENcxR/0n0@public.gmane.org>
@ 2022-07-26  9:00               ` Lyndon Drake
       [not found]                 ` <d25cee8b-7cb2-4fe9-b44d-f288a8fef728n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-26  9:00 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 3148 bytes --]

Thanks for this. I can see how that could work.

Can you point me to another example that uses the walk function?

Regarding a new-style Lua writer, is there a way to get the current LaTeX 
writer as Lua code? Or is it just the Haskell code? (I once knew Haskell 
but that was rather a long time ago.)

On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:

> I can't come up with a code example now, bit you can use the walk function 
> (https://pandoc.org/lua-filters.html#type-block:walk) to modify the 
> citations with a given mode inside notes. You'll need to build the citation 
> via Pandoc.RawInline
> Maybe that would be a good example of a new style Lua writer.
> ________________________________________
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag 
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Gesendet: Montag, 25. Juli 2022 21:46:28
> An: pandoc-discuss
> Betreff: Changing LaTeX output for citations inside footnotes
>
> Hi,
>
> So this is a slightly odd request, which really comes because of the 
> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
> that style, \textcite inside a footnote produces an unwanted result. \cite 
> produces the expected output. I have generally just gone through and 
> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
> stage, but that's painful, and I also thought that maybe this is possible 
> to do in a Lua filter.
>
> But I don't quite know where to start - obviously this is a bit different 
> from the internal Pandoc citations. I'm going to begin the filter with this:
>
> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
> function
>
> but what would the function be? If it is Footnote, then I don't really 
> want the AST, I want the LaTeX that forms the footnote contents, and I 
> suppose then I can just replace any occurrences of the string \textcite 
> with the string \cite?
>
> Any help would be awesome!
>
> Best,
> Lyndon
>
> --
> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 5410 bytes --]

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

* AW: Changing LaTeX output for citations inside footnotes
       [not found]                 ` <d25cee8b-7cb2-4fe9-b44d-f288a8fef728n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-27 10:27                   ` denis.maier-NSENcxR/0n0
       [not found]                     ` <97765931b0a740ed8a84ba4337bed661-NSENcxR/0n0@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-07-27 10:27 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

What kind of example do you need? I only know about the examples in the documentation.

I think this here is a nice one :
https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages

Or : the new style writer
https://pandoc.org/custom-writers.html#example-modified-markdown-writer

So, something like this here could be start:

```
function Writer(doc, opts)
  local filter = {
    Note = function(el)
        return el:walk {
          Cite = function(el)
            -- processing logic
           return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}')
          end
      }
    end
  }
  return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

I don’t think you can get the current writer in Lua.


Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
Gesendet: Dienstag, 26. Juli 2022 11:00
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Thanks for this. I can see how that could work.

Can you point me to another example that uses the walk function?

Regarding a new-style Lua writer, is there a way to get the current LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew Haskell but that was rather a long time ago.)
On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org<mailto:denis...@unibe.ch> wrote:
I can't come up with a code example now, bit you can use the walk function (https://pandoc.org/lua-filters.html#type-block:walk) to modify the citations with a given mode inside notes. You'll need to build the citation via Pandoc.RawInline
Maybe that would be a good example of a new style Lua writer.
________________________________________
Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Gesendet: Montag, 25. Juli 2022 21:46:28
An: pandoc-discuss
Betreff: Changing LaTeX output for citations inside footnotes

Hi,

So this is a slightly odd request, which really comes because of the unusual behaviour of the specific BibLaTeX bibliography style I'm using. In that style, \textcite inside a footnote produces an unwanted result. \cite produces the expected output. I have generally just gone through and hand-edited my Pandoc-produced LaTeX files when they get to the final copy stage, but that's painful, and I also thought that maybe this is possible to do in a Lua filter.

But I don't quite know where to start - obviously this is a bit different from the internal Pandoc citations. I'm going to begin the filter with this:

if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> function

but what would the function be? If it is Footnote, then I don't really want the AST, I want the LaTeX that forms the footnote contents, and I suppose then I can just replace any occurrences of the string \textcite with the string \cite?

Any help would be awesome!

Best,
Lyndon

--
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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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/97765931b0a740ed8a84ba4337bed661%40unibe.ch.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                     ` <97765931b0a740ed8a84ba4337bed661-NSENcxR/0n0@public.gmane.org>
@ 2022-07-28 17:17                       ` Lyndon Drake
       [not found]                         ` <90c69f14-e16a-44d6-91ec-a6f6dca3ca45n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-28 17:17 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 7367 bytes --]

Thanks for this - exactly what I needed. I've added my attempt at the code 
below, but I must be missing some basic part of it because it doesn't do 
anything. I added a couple of print statements that never get executed:

```
function Writer(doc, opts)
    print "got here"
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    print "got further"
                    local citation = ""
                    if #el.citations > 1 then
                        if citations[1].mode == "AuthorInText" then
                            citation = '\\textcites*'
                        elseif citations[1].mode == "SuppressAuthor" then
                            citation = '\\cites*'
                        elseif citations[1].mode == "NormalCitation" then
                            citation = '\\cites'
                        end
                    else
                        if citations[1].mode == "AuthorInText" then
                            citation = '\\textcite*'
                        elseif citations[1].mode == "SuppressAuthor" then
                            citation = '\\cite*'
                        elseif citations[1].mode == "NormalCitation" then
                            citation = '\\cite'
                        end
                    end
                    for c in el.citations do
                        if c.prefix ~= "" then
                            citation = citation .. '[' .. c.prefix .. ']'
                        end
                        if c.suffix ~= "" then
                            citation = citation .. '[' .. c.suffix .. ']'
                        end
                        citation = citation .. '{' .. c.id .. '}'
                    end
                    return pandoc.RawInline('latex', citation)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

Apologies for what must be a very basic question, but what am I missing 
here?

On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:

> What kind of example do you need? I only know about the examples in the 
> documentation.
>
>  
>
> I think this here is a nice one :
>
>
> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>
>  
>
> Or : the new style writer
>
> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>
>  
>
> So, something like this here could be start:
>
>  
>
> ```
>
> function Writer(doc, opts)
>
>   local filter = {
>
>     Note = function(el)
>
>         return el:walk {
>
>           Cite = function(el)
>
>             -- processing logic
>
>            return pandoc.RawInline('latex', 
> '\\cite[prenote][postnote]{key}')
>
>           end
>
>       }
>
>     end
>
>   }
>
>   return pandoc.write(doc:walk(filter), 'latex', opts)
>
> end
>
> ```
>
>  
>
> I don’t think you can get the current writer in Lua.
>
>  
>
>  
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im 
> Auftrag von *Lyndon Drake
> *Gesendet:* Dienstag, 26. Juli 2022 11:00
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Re: Changing LaTeX output for citations inside footnotes
>
>  
>
> Thanks for this. I can see how that could work.
>
>  
>
> Can you point me to another example that uses the walk function?
>
>  
>
> Regarding a new-style Lua writer, is there a way to get the current LaTeX 
> writer as Lua code? Or is it just the Haskell code? (I once knew Haskell 
> but that was rather a long time ago.)
>
> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
> I can't come up with a code example now, bit you can use the walk function 
> (https://pandoc.org/lua-filters.html#type-block:walk) to modify the 
> citations with a given mode inside notes. You'll need to build the citation 
> via Pandoc.RawInline 
> Maybe that would be a good example of a new style Lua writer. 
> ________________________________________ 
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag 
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
> Gesendet: Montag, 25. Juli 2022 21:46:28 
> An: pandoc-discuss 
> Betreff: Changing LaTeX output for citations inside footnotes 
>
> Hi, 
>
> So this is a slightly odd request, which really comes because of the 
> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
> that style, \textcite inside a footnote produces an unwanted result. \cite 
> produces the expected output. I have generally just gone through and 
> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
> stage, but that's painful, and I also thought that maybe this is possible 
> to do in a Lua filter. 
>
> But I don't quite know where to start - obviously this is a bit different 
> from the internal Pandoc citations. I'm going to begin the filter with 
> this: 
>
> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
> function 
>
> but what would the function be? If it is Footnote, then I don't really 
> want the AST, I want the LaTeX that forms the footnote contents, and I 
> suppose then I can just replace any occurrences of the string \textcite 
> with the string \cite? 
>
> Any help would be awesome! 
>
> Best, 
> Lyndon 
>
> -- 
> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 17200 bytes --]

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

* AW: Changing LaTeX output for citations inside footnotes
       [not found]                         ` <90c69f14-e16a-44d6-91ec-a6f6dca3ca45n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-28 20:31                           ` denis.maier-NSENcxR/0n0
       [not found]                             ` <b1e75d01e60647dc89b599683996c6b1-NSENcxR/0n0@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-07-28 20:31 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

How do you run this ?
I’ve tested with a minimal markdown file :

```markdown
asdf
```

Run with :
pandoc asdf.md -t mylatex.lua

Result :
got here
asdf

So, it prints the first print statement of the writer.

Denis

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
Gesendet: Donnerstag, 28. Juli 2022 19:17
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Thanks for this - exactly what I needed. I've added my attempt at the code below, but I must be missing some basic part of it because it doesn't do anything. I added a couple of print statements that never get executed:

```
function Writer(doc, opts)
    print "got here"
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    print "got further"
                    local citation = ""
                    if #el.citations > 1 then
                        if citations[1].mode == "AuthorInText" then
                            citation = '\\textcites*'
                        elseif citations[1].mode == "SuppressAuthor" then
                            citation = '\\cites*'
                        elseif citations[1].mode == "NormalCitation" then
                            citation = '\\cites'
                        end
                    else
                        if citations[1].mode == "AuthorInText" then
                            citation = '\\textcite*'
                        elseif citations[1].mode == "SuppressAuthor" then
                            citation = '\\cite*'
                        elseif citations[1].mode == "NormalCitation" then
                            citation = '\\cite'
                        end
                    end
                    for c in el.citations do
                        if c.prefix ~= "" then
                            citation = citation .. '[' .. c.prefix .. ']'
                        end
                        if c.suffix ~= "" then
                            citation = citation .. '[' .. c.suffix .. ']'
                        end
                        citation = citation .. '{' .. c.id .. '}'
                    end
                    return pandoc.RawInline('latex', citation)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

Apologies for what must be a very basic question, but what am I missing here?
On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org<mailto:denis...@unibe.ch> wrote:
What kind of example do you need? I only know about the examples in the documentation.

I think this here is a nice one :
https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages

Or : the new style writer
https://pandoc.org/custom-writers.html#example-modified-markdown-writer

So, something like this here could be start:

```
function Writer(doc, opts)
  local filter = {
    Note = function(el)
        return el:walk {
          Cite = function(el)
            -- processing logic
           return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}')
          end
      }
    end
  }
  return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

I don’t think you can get the current writer in Lua.


Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
Gesendet: Dienstag, 26. Juli 2022 11:00
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Thanks for this. I can see how that could work.

Can you point me to another example that uses the walk function?

Regarding a new-style Lua writer, is there a way to get the current LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew Haskell but that was rather a long time ago.)
On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
I can't come up with a code example now, bit you can use the walk function (https://pandoc.org/lua-filters.html#type-block:walk) to modify the citations with a given mode inside notes. You'll need to build the citation via Pandoc.RawInline
Maybe that would be a good example of a new style Lua writer.
________________________________________
Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Gesendet: Montag, 25. Juli 2022 21:46:28
An: pandoc-discuss
Betreff: Changing LaTeX output for citations inside footnotes

Hi,

So this is a slightly odd request, which really comes because of the unusual behaviour of the specific BibLaTeX bibliography style I'm using. In that style, \textcite inside a footnote produces an unwanted result. \cite produces the expected output. I have generally just gone through and hand-edited my Pandoc-produced LaTeX files when they get to the final copy stage, but that's painful, and I also thought that maybe this is possible to do in a Lua filter.

But I don't quite know where to start - obviously this is a bit different from the internal Pandoc citations. I'm going to begin the filter with this:

if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> function

but what would the function be? If it is Footnote, then I don't really want the AST, I want the LaTeX that forms the footnote contents, and I suppose then I can just replace any occurrences of the string \textcite with the string \cite?

Any help would be awesome!

Best,
Lyndon

--
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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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/b1e75d01e60647dc89b599683996c6b1%40unibe.ch.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                             ` <b1e75d01e60647dc89b599683996c6b1-NSENcxR/0n0@public.gmane.org>
@ 2022-07-29  5:15                               ` Lyndon Drake
       [not found]                                 ` <c4609f20-77f3-4427-83ae-6c79ba48ed5bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-29  5:15 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 9219 bytes --]

My command line is:

pandoc -dbookends-latex --template 
/Users/lyndon/.local/share/pandoc/templates/book.latex 
--lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
-s -o thesis_jeremiah_32.tex jer-32-thesis.md

It's definitely picking up the lua file because if I have a syntax error, 
pandoc tells me. But I don't get any output.

On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:

> How do you run this ?
>
> I’ve tested with a minimal markdown file :
>
>  
>
> ```markdown
>
> asdf
>
> ```
>
>  
>
> Run with :
>
> pandoc asdf.md -t mylatex.lua
>
>  
>
> Result :
>
> got here
>
> asdf
>
>  
>
> So, it prints the first print statement of the writer.
>
>  
>
> Denis
>
>  
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im 
> Auftrag von *Lyndon Drake
> *Gesendet:* Donnerstag, 28. Juli 2022 19:17
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Re: Changing LaTeX output for citations inside footnotes
>
>  
>
> Thanks for this - exactly what I needed. I've added my attempt at the code 
> below, but I must be missing some basic part of it because it doesn't do 
> anything. I added a couple of print statements that never get executed:
>
>  
>
> ```
>
> function Writer(doc, opts)
>     print "got here"
>     local filter = {
>         Note = function(el)
>             return el:walk {
>                 Cite = function(el)
>                     -- processing logic
>                     print "got further"
>                     local citation = ""
>                     if #el.citations > 1 then
>                         if citations[1].mode == "AuthorInText" then
>                             citation = '\\textcites*'
>                         elseif citations[1].mode == "SuppressAuthor" then
>                             citation = '\\cites*'
>                         elseif citations[1].mode == "NormalCitation" then
>                             citation = '\\cites'
>                         end
>                     else
>                         if citations[1].mode == "AuthorInText" then
>                             citation = '\\textcite*'
>                         elseif citations[1].mode == "SuppressAuthor" then
>                             citation = '\\cite*'
>                         elseif citations[1].mode == "NormalCitation" then
>                             citation = '\\cite'
>                         end
>                     end
>                     for c in el.citations do
>                         if c.prefix ~= "" then
>                             citation = citation .. '[' .. c.prefix .. ']'
>                         end
>                         if c.suffix ~= "" then
>                             citation = citation .. '[' .. c.suffix .. ']'
>                         end
>                         citation = citation .. '{' .. c.id .. '}'
>                     end
>                     return pandoc.RawInline('latex', citation)
>                 end
>             }
>         end
>     }
>     return pandoc.write(doc:walk(filter), 'latex', opts)
> end
>
> ```
>
>  
>
> Apologies for what must be a very basic question, but what am I missing 
> here?
>
> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
> What kind of example do you need? I only know about the examples in the 
> documentation.
>
>  
>
> I think this here is a nice one :
>
>
> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>
>  
>
> Or : the new style writer
>
> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>
>  
>
> So, something like this here could be start:
>
>  
>
> ```
>
> function Writer(doc, opts)
>
>   local filter = {
>
>     Note = function(el)
>
>         return el:walk {
>
>           Cite = function(el)
>
>             -- processing logic
>
>            return pandoc.RawInline('latex', 
> '\\cite[prenote][postnote]{key}')
>
>           end
>
>       }
>
>     end
>
>   }
>
>   return pandoc.write(doc:walk(filter), 'latex', opts)
>
> end
>
> ```
>
>  
>
> I don’t think you can get the current writer in Lua.
>
>  
>
>  
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im 
> Auftrag von *Lyndon Drake
> *Gesendet:* Dienstag, 26. Juli 2022 11:00
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Re: Changing LaTeX output for citations inside footnotes
>
>  
>
> Thanks for this. I can see how that could work.
>
>  
>
> Can you point me to another example that uses the walk function?
>
>  
>
> Regarding a new-style Lua writer, is there a way to get the current LaTeX 
> writer as Lua code? Or is it just the Haskell code? (I once knew Haskell 
> but that was rather a long time ago.)
>
> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
> I can't come up with a code example now, bit you can use the walk function 
> (https://pandoc.org/lua-filters.html#type-block:walk) to modify the 
> citations with a given mode inside notes. You'll need to build the citation 
> via Pandoc.RawInline 
> Maybe that would be a good example of a new style Lua writer. 
> ________________________________________ 
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag 
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
> Gesendet: Montag, 25. Juli 2022 21:46:28 
> An: pandoc-discuss 
> Betreff: Changing LaTeX output for citations inside footnotes 
>
> Hi, 
>
> So this is a slightly odd request, which really comes because of the 
> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
> that style, \textcite inside a footnote produces an unwanted result. \cite 
> produces the expected output. I have generally just gone through and 
> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
> stage, but that's painful, and I also thought that maybe this is possible 
> to do in a Lua filter. 
>
> But I don't quite know where to start - obviously this is a bit different 
> from the internal Pandoc citations. I'm going to begin the filter with 
> this: 
>
> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
> function 
>
> but what would the function be? If it is Footnote, then I don't really 
> want the AST, I want the LaTeX that forms the footnote contents, and I 
> suppose then I can just replace any occurrences of the string \textcite 
> with the string \cite? 
>
> Any help would be awesome! 
>
> Best, 
> Lyndon 
>
> -- 
> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 20566 bytes --]

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

* AW: Changing LaTeX output for citations inside footnotes
       [not found]                                 ` <c4609f20-77f3-4427-83ae-6c79ba48ed5bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-29  5:44                                   ` denis.maier-NSENcxR/0n0
       [not found]                                     ` <ae44d2fa18454bbf80aa666040dee1f7-NSENcxR/0n0@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-07-29  5:44 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

That's the problem. This is a writer, not a filter. So you need to call it via
-t latex-footcite.lua
________________________________________
Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon Drake <isenguard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Gesendet: Freitag, 29. Juli 2022 07:15:08
An: pandoc-discuss
Betreff: Re: Changing LaTeX output for citations inside footnotes

My command line is:

pandoc -dbookends-latex --template /Users/lyndon/.local/share/pandoc/templates/book.latex --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua -s -o thesis_jeremiah_32.tex jer-32-thesis.md

It's definitely picking up the lua file because if I have a syntax error, pandoc tells me. But I don't get any output.

On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
How do you run this ?
I’ve tested with a minimal markdown file :

```markdown
asdf
```

Run with :
pandoc asdf.md -t mylatex.lua

Result :
got here
asdf

So, it prints the first print statement of the writer.

Denis

Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
Gesendet: Donnerstag, 28. Juli 2022 19:17
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Thanks for this - exactly what I needed. I've added my attempt at the code below, but I must be missing some basic part of it because it doesn't do anything. I added a couple of print statements that never get executed:

```
function Writer(doc, opts)
    print "got here"
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    print "got further"
                    local citation = ""
                    if #el.citations > 1 then
                        if citations[1].mode == "AuthorInText" then
                            citation = '\\textcites*'
                        elseif citations[1].mode == "SuppressAuthor" then
                            citation = '\\cites*'
                        elseif citations[1].mode == "NormalCitation" then
                            citation = '\\cites'
                        end
                    else
                        if citations[1].mode == "AuthorInText" then
                            citation = '\\textcite*'
                        elseif citations[1].mode == "SuppressAuthor" then
                            citation = '\\cite*'
                        elseif citations[1].mode == "NormalCitation" then
                            citation = '\\cite'
                        end
                    end
                    for c in el.citations do
                        if c.prefix ~= "" then
                            citation = citation .. '[' .. c.prefix .. ']'
                        end
                        if c.suffix ~= "" then
                            citation = citation .. '[' .. c.suffix .. ']'
                        end
                        citation = citation .. '{' .. c.id<http://c.id> .. '}'
                    end
                    return pandoc.RawInline('latex', citation)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

Apologies for what must be a very basic question, but what am I missing here?
On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
What kind of example do you need? I only know about the examples in the documentation.

I think this here is a nice one :
https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages

Or : the new style writer
https://pandoc.org/custom-writers.html#example-modified-markdown-writer

So, something like this here could be start:

```
function Writer(doc, opts)
  local filter = {
    Note = function(el)
        return el:walk {
          Cite = function(el)
            -- processing logic
           return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}')
          end
      }
    end
  }
  return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

I don’t think you can get the current writer in Lua.


Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
Gesendet: Dienstag, 26. Juli 2022 11:00
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Thanks for this. I can see how that could work.

Can you point me to another example that uses the walk function?

Regarding a new-style Lua writer, is there a way to get the current LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew Haskell but that was rather a long time ago.)
On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
I can't come up with a code example now, bit you can use the walk function (https://pandoc.org/lua-filters.html#type-block:walk) to modify the citations with a given mode inside notes. You'll need to build the citation via Pandoc.RawInline
Maybe that would be a good example of a new style Lua writer.
________________________________________
Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Gesendet: Montag, 25. Juli 2022 21:46:28
An: pandoc-discuss
Betreff: Changing LaTeX output for citations inside footnotes

Hi,

So this is a slightly odd request, which really comes because of the unusual behaviour of the specific BibLaTeX bibliography style I'm using. In that style, \textcite inside a footnote produces an unwanted result. \cite produces the expected output. I have generally just gone through and hand-edited my Pandoc-produced LaTeX files when they get to the final copy stage, but that's painful, and I also thought that maybe this is possible to do in a Lua filter.

But I don't quite know where to start - obviously this is a bit different from the internal Pandoc citations. I'm going to begin the filter with this:

if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> function

but what would the function be? If it is Footnote, then I don't really want the AST, I want the LaTeX that forms the footnote contents, and I suppose then I can just replace any occurrences of the string \textcite with the string \cite?

Any help would be awesome!

Best,
Lyndon

--
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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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/ae44d2fa18454bbf80aa666040dee1f7%40unibe.ch.


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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                     ` <ae44d2fa18454bbf80aa666040dee1f7-NSENcxR/0n0@public.gmane.org>
@ 2022-07-29  8:51                                       ` Lyndon Drake
       [not found]                                         ` <e578ff2f-aab9-45da-93ef-d8b5705b14f8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-29  8:51 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 9392 bytes --]

Ah yep, that works. Next thing is I have to debug my obviously incorrect 
code :-)

On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:

> That's the problem. This is a writer, not a filter. So you need to call it 
> via
> -t latex-footcite.lua
> ________________________________________
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag 
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Gesendet: Freitag, 29. Juli 2022 07:15:08
> An: pandoc-discuss
> Betreff: Re: Changing LaTeX output for citations inside footnotes
>
> My command line is:
>
> pandoc -dbookends-latex --template 
> /Users/lyndon/.local/share/pandoc/templates/book.latex 
> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
> -s -o thesis_jeremiah_32.tex jer-32-thesis.md
>
> It's definitely picking up the lua file because if I have a syntax error, 
> pandoc tells me. But I don't get any output.
>
> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
> How do you run this ?
> I’ve tested with a minimal markdown file :
>
> ```markdown
> asdf
> ```
>
> Run with :
> pandoc asdf.md -t mylatex.lua
>
> Result :
> got here
> asdf
>
> So, it prints the first print statement of the writer.
>
> Denis
>
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag 
> von Lyndon Drake
> Gesendet: Donnerstag, 28. Juli 2022 19:17
> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> Betreff: Re: Changing LaTeX output for citations inside footnotes
>
> Thanks for this - exactly what I needed. I've added my attempt at the code 
> below, but I must be missing some basic part of it because it doesn't do 
> anything. I added a couple of print statements that never get executed:
>
> ```
> function Writer(doc, opts)
> print "got here"
> local filter = {
> Note = function(el)
> return el:walk {
> Cite = function(el)
> -- processing logic
> print "got further"
> local citation = ""
> if #el.citations > 1 then
> if citations[1].mode == "AuthorInText" then
> citation = '\\textcites*'
> elseif citations[1].mode == "SuppressAuthor" then
> citation = '\\cites*'
> elseif citations[1].mode == "NormalCitation" then
> citation = '\\cites'
> end
> else
> if citations[1].mode == "AuthorInText" then
> citation = '\\textcite*'
> elseif citations[1].mode == "SuppressAuthor" then
> citation = '\\cite*'
> elseif citations[1].mode == "NormalCitation" then
> citation = '\\cite'
> end
> end
> for c in el.citations do
> if c.prefix ~= "" then
> citation = citation .. '[' .. c.prefix .. ']'
> end
> if c.suffix ~= "" then
> citation = citation .. '[' .. c.suffix .. ']'
> end
> citation = citation .. '{' .. c.id<http://c.id> .. '}'
> end
> return pandoc.RawInline('latex', citation)
> end
> }
> end
> }
> return pandoc.write(doc:walk(filter), 'latex', opts)
> end
> ```
>
> Apologies for what must be a very basic question, but what am I missing 
> here?
> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
> What kind of example do you need? I only know about the examples in the 
> documentation.
>
> I think this here is a nice one :
>
> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>
> Or : the new style writer
> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>
> So, something like this here could be start:
>
> ```
> function Writer(doc, opts)
> local filter = {
> Note = function(el)
> return el:walk {
> Cite = function(el)
> -- processing logic
> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}')
> end
> }
> end
> }
> return pandoc.write(doc:walk(filter), 'latex', opts)
> end
> ```
>
> I don’t think you can get the current writer in Lua.
>
>
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag 
> von Lyndon Drake
> Gesendet: Dienstag, 26. Juli 2022 11:00
> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> Betreff: Re: Changing LaTeX output for citations inside footnotes
>
> Thanks for this. I can see how that could work.
>
> Can you point me to another example that uses the walk function?
>
> Regarding a new-style Lua writer, is there a way to get the current LaTeX 
> writer as Lua code? Or is it just the Haskell code? (I once knew Haskell 
> but that was rather a long time ago.)
> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
> I can't come up with a code example now, bit you can use the walk function 
> (https://pandoc.org/lua-filters.html#type-block:walk) to modify the 
> citations with a given mode inside notes. You'll need to build the citation 
> via Pandoc.RawInline
> Maybe that would be a good example of a new style Lua writer.
> ________________________________________
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag 
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Gesendet: Montag, 25. Juli 2022 21:46:28
> An: pandoc-discuss
> Betreff: Changing LaTeX output for citations inside footnotes
>
> Hi,
>
> So this is a slightly odd request, which really comes because of the 
> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
> that style, \textcite inside a footnote produces an unwanted result. \cite 
> produces the expected output. I have generally just gone through and 
> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
> stage, but that's painful, and I also thought that maybe this is possible 
> to do in a Lua filter.
>
> But I don't quite know where to start - obviously this is a bit different 
> from the internal Pandoc citations. I'm going to begin the filter with this:
>
> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
> function
>
> but what would the function be? If it is Footnote, then I don't really 
> want the AST, I want the LaTeX that forms the footnote contents, and I 
> suppose then I can just replace any occurrences of the string \textcite 
> with the string \cite?
>
> Any help would be awesome!
>
> Best,
> Lyndon
>
> --
> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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/e578ff2f-aab9-45da-93ef-d8b5705b14f8n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 17231 bytes --]

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                         ` <e578ff2f-aab9-45da-93ef-d8b5705b14f8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-29  8:58                                           ` Lyndon Drake
       [not found]                                             ` <a1e38719-d239-44af-84b0-67a1764dbb70n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-29  8:58 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 9977 bytes --]

So I have the citation prefix, which I guess I have to convert to a valid 
LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?

On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:

> Ah yep, that works. Next thing is I have to debug my obviously incorrect 
> code :-)
>
> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
>> That's the problem. This is a writer, not a filter. So you need to call 
>> it via 
>> -t latex-footcite.lua 
>> ________________________________________ 
>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>> Gesendet: Freitag, 29. Juli 2022 07:15:08 
>> An: pandoc-discuss 
>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>
>> My command line is: 
>>
>> pandoc -dbookends-latex --template 
>> /Users/lyndon/.local/share/pandoc/templates/book.latex 
>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md 
>>
>> It's definitely picking up the lua file because if I have a syntax error, 
>> pandoc tells me. But I don't get any output. 
>>
>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>> How do you run this ? 
>> I’ve tested with a minimal markdown file : 
>>
>> ```markdown 
>> asdf 
>> ``` 
>>
>> Run with : 
>> pandoc asdf.md -t mylatex.lua 
>>
>> Result : 
>> got here 
>> asdf 
>>
>> So, it prints the first print statement of the writer. 
>>
>> Denis 
>>
>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>> Auftrag von Lyndon Drake 
>> Gesendet: Donnerstag, 28. Juli 2022 19:17 
>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>
>> Thanks for this - exactly what I needed. I've added my attempt at the 
>> code below, but I must be missing some basic part of it because it doesn't 
>> do anything. I added a couple of print statements that never get executed: 
>>
>> ``` 
>> function Writer(doc, opts) 
>> print "got here" 
>> local filter = { 
>> Note = function(el) 
>> return el:walk { 
>> Cite = function(el) 
>> -- processing logic 
>> print "got further" 
>> local citation = "" 
>> if #el.citations > 1 then 
>> if citations[1].mode == "AuthorInText" then 
>> citation = '\\textcites*' 
>> elseif citations[1].mode == "SuppressAuthor" then 
>> citation = '\\cites*' 
>> elseif citations[1].mode == "NormalCitation" then 
>> citation = '\\cites' 
>> end 
>> else 
>> if citations[1].mode == "AuthorInText" then 
>> citation = '\\textcite*' 
>> elseif citations[1].mode == "SuppressAuthor" then 
>> citation = '\\cite*' 
>> elseif citations[1].mode == "NormalCitation" then 
>> citation = '\\cite' 
>> end 
>> end 
>> for c in el.citations do 
>> if c.prefix ~= "" then 
>> citation = citation .. '[' .. c.prefix .. ']' 
>> end 
>> if c.suffix ~= "" then 
>> citation = citation .. '[' .. c.suffix .. ']' 
>> end 
>> citation = citation .. '{' .. c.id<http://c.id> .. '}' 
>> end 
>> return pandoc.RawInline('latex', citation) 
>> end 
>> } 
>> end 
>> } 
>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>> end 
>> ``` 
>>
>> Apologies for what must be a very basic question, but what am I missing 
>> here? 
>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>> What kind of example do you need? I only know about the examples in the 
>> documentation. 
>>
>> I think this here is a nice one : 
>>
>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages 
>>
>> Or : the new style writer 
>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer 
>>
>> So, something like this here could be start: 
>>
>> ``` 
>> function Writer(doc, opts) 
>> local filter = { 
>> Note = function(el) 
>> return el:walk { 
>> Cite = function(el) 
>> -- processing logic 
>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}') 
>> end 
>> } 
>> end 
>> } 
>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>> end 
>> ``` 
>>
>> I don’t think you can get the current writer in Lua. 
>>
>>
>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>> Auftrag von Lyndon Drake 
>> Gesendet: Dienstag, 26. Juli 2022 11:00 
>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>
>> Thanks for this. I can see how that could work. 
>>
>> Can you point me to another example that uses the walk function? 
>>
>> Regarding a new-style Lua writer, is there a way to get the current LaTeX 
>> writer as Lua code? Or is it just the Haskell code? (I once knew Haskell 
>> but that was rather a long time ago.) 
>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>> I can't come up with a code example now, bit you can use the walk 
>> function (https://pandoc.org/lua-filters.html#type-block:walk) to modify 
>> the citations with a given mode inside notes. You'll need to build the 
>> citation via Pandoc.RawInline 
>> Maybe that would be a good example of a new style Lua writer. 
>> ________________________________________ 
>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>> Gesendet: Montag, 25. Juli 2022 21:46:28 
>> An: pandoc-discuss 
>> Betreff: Changing LaTeX output for citations inside footnotes 
>>
>> Hi, 
>>
>> So this is a slightly odd request, which really comes because of the 
>> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
>> that style, \textcite inside a footnote produces an unwanted result. \cite 
>> produces the expected output. I have generally just gone through and 
>> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
>> stage, but that's painful, and I also thought that maybe this is possible 
>> to do in a Lua filter. 
>>
>> But I don't quite know where to start - obviously this is a bit different 
>> from the internal Pandoc citations. I'm going to begin the filter with 
>> this: 
>>
>> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
>> function 
>>
>> but what would the function be? If it is Footnote, then I don't really 
>> want the AST, I want the LaTeX that forms the footnote contents, and I 
>> suppose then I can just replace any occurrences of the string \textcite 
>> with the string \cite? 
>>
>> Any help would be awesome! 
>>
>> Best, 
>> Lyndon 
>>
>> -- 
>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>> <
>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>> <
>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>> <
>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>> <
>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 17425 bytes --]

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                             ` <a1e38719-d239-44af-84b0-67a1764dbb70n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-29  9:49                                               ` Sukil Etxenike arizaleta
       [not found]                                                 ` <8976ce00-3fbe-bf27-898f-0470cba1fec1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Sukil Etxenike arizaleta @ 2022-07-29  9:49 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

I don't know, but the building blocks you'll need are `pandoc.stringify` 
which takes any object and converts it into a string, and 
`pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a 
raw block or inline, and take the format as first argument and the 
string as second.

Hth,

Sukil


El 29/07/2022 a las 10:58, Lyndon Drake escribió:
> So I have the citation prefix, which I guess I have to convert to a 
> valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a 
> string?
>
> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>
>     Ah yep, that works. Next thing is I have to debug my obviously
>     incorrect code :-)
>
>     On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
>         That's the problem. This is a writer, not a filter. So you
>         need to call it via
>         -t latex-footcite.lua
>         ________________________________________
>         Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>         im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>         Gesendet: Freitag, 29. Juli 2022 07:15:08
>         An: pandoc-discuss
>         Betreff: Re: Changing LaTeX output for citations inside footnotes
>
>         My command line is:
>
>         pandoc -dbookends-latex --template
>         /Users/lyndon/.local/share/pandoc/templates/book.latex
>         --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
>         -s -o thesis_jeremiah_32.tex jer-32-thesis.md
>
>         It's definitely picking up the lua file because if I have a
>         syntax error, pandoc tells me. But I don't get any output.
>
>         On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>         wrote:
>         How do you run this ?
>         I’ve tested with a minimal markdown file :
>
>         ```markdown
>         asdf
>         ```
>
>         Run with :
>         pandoc asdf.md -t mylatex.lua
>
>         Result :
>         got here
>         asdf
>
>         So, it prints the first print statement of the writer.
>
>         Denis
>
>         Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>         Im Auftrag von Lyndon Drake
>         Gesendet: Donnerstag, 28. Juli 2022 19:17
>         An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>         Betreff: Re: Changing LaTeX output for citations inside footnotes
>
>         Thanks for this - exactly what I needed. I've added my attempt
>         at the code below, but I must be missing some basic part of it
>         because it doesn't do anything. I added a couple of print
>         statements that never get executed:
>
>         ```
>         function Writer(doc, opts)
>         print "got here"
>         local filter = {
>         Note = function(el)
>         return el:walk {
>         Cite = function(el)
>         -- processing logic
>         print "got further"
>         local citation = ""
>         if #el.citations > 1 then
>         if citations[1].mode == "AuthorInText" then
>         citation = '\\textcites*'
>         elseif citations[1].mode == "SuppressAuthor" then
>         citation = '\\cites*'
>         elseif citations[1].mode == "NormalCitation" then
>         citation = '\\cites'
>         end
>         else
>         if citations[1].mode == "AuthorInText" then
>         citation = '\\textcite*'
>         elseif citations[1].mode == "SuppressAuthor" then
>         citation = '\\cite*'
>         elseif citations[1].mode == "NormalCitation" then
>         citation = '\\cite'
>         end
>         end
>         for c in el.citations do
>         if c.prefix ~= "" then
>         citation = citation .. '[' .. c.prefix .. ']'
>         end
>         if c.suffix ~= "" then
>         citation = citation .. '[' .. c.suffix .. ']'
>         end
>         citation = citation .. '{' .. c.id <http://c.id><http://c.id>
>         .. '}'
>         end
>         return pandoc.RawInline('latex', citation)
>         end
>         }
>         end
>         }
>         return pandoc.write(doc:walk(filter), 'latex', opts)
>         end
>         ```
>
>         Apologies for what must be a very basic question, but what am
>         I missing here?
>         On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>         wrote:
>         What kind of example do you need? I only know about the
>         examples in the documentation.
>
>         I think this here is a nice one :
>         https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>
>
>         Or : the new style writer
>         https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>
>
>         So, something like this here could be start:
>
>         ```
>         function Writer(doc, opts)
>         local filter = {
>         Note = function(el)
>         return el:walk {
>         Cite = function(el)
>         -- processing logic
>         return pandoc.RawInline('latex',
>         '\\cite[prenote][postnote]{key}')
>         end
>         }
>         end
>         }
>         return pandoc.write(doc:walk(filter), 'latex', opts)
>         end
>         ```
>
>         I don’t think you can get the current writer in Lua.
>
>
>         Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>         Im Auftrag von Lyndon Drake
>         Gesendet: Dienstag, 26. Juli 2022 11:00
>         An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>         Betreff: Re: Changing LaTeX output for citations inside footnotes
>
>         Thanks for this. I can see how that could work.
>
>         Can you point me to another example that uses the walk function?
>
>         Regarding a new-style Lua writer, is there a way to get the
>         current LaTeX writer as Lua code? Or is it just the Haskell
>         code? (I once knew Haskell but that was rather a long time ago.)
>         On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>         wrote:
>         I can't come up with a code example now, bit you can use the
>         walk function
>         (https://pandoc.org/lua-filters.html#type-block:walk) to
>         modify the citations with a given mode inside notes. You'll
>         need to build the citation via Pandoc.RawInline
>         Maybe that would be a good example of a new style Lua writer.
>         ________________________________________
>         Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>         im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>         Gesendet: Montag, 25. Juli 2022 21:46:28
>         An: pandoc-discuss
>         Betreff: Changing LaTeX output for citations inside footnotes
>
>         Hi,
>
>         So this is a slightly odd request, which really comes because
>         of the unusual behaviour of the specific BibLaTeX bibliography
>         style I'm using. In that style, \textcite inside a footnote
>         produces an unwanted result. \cite produces the expected
>         output. I have generally just gone through and hand-edited my
>         Pandoc-produced LaTeX files when they get to the final copy
>         stage, but that's painful, and I also thought that maybe this
>         is possible to do in a Lua filter.
>
>         But I don't quite know where to start - obviously this is a
>         bit different from the internal Pandoc citations. I'm going to
>         begin the filter with this:
>
>         if FORMAT:match 'latex' then
>         <https://pandoc.org/lua-filters.html#cb9-3> function
>
>         but what would the function be? If it is Footnote, then I
>         don't really want the AST, I want the LaTeX that forms the
>         footnote contents, and I suppose then I can just replace any
>         occurrences of the string \textcite with the string \cite?
>
>         Any help would be awesome!
>
>         Best,
>         Lyndon
>
>         -- 
>         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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
>
>         To view this discussion on the web visit
>         https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com?utm_medium=email&utm_source=footer
>         <https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>         To view this discussion on the web visit
>         https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com?utm_medium=email&utm_source=footer
>         <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>         To view this discussion on the web visit
>         https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com?utm_medium=email&utm_source=footer
>         <https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
>
>         To view this discussion on the web visit
>         https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com?utm_medium=email&utm_source=footer
>         <https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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/8976ce00-3fbe-bf27-898f-0470cba1fec1%40gmail.com.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                 ` <8976ce00-3fbe-bf27-898f-0470cba1fec1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-07-29 14:58                                                   ` Lyndon Drake
       [not found]                                                     ` <0e10379f-d1c0-4024-b98a-5c7ba703f561n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-29 14:58 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 14584 bytes --]

Thanks for all the help - definitely getting somewhere now!

I guess what I want to avoid is replicating in my not-great-Lua code all 
the work Pandoc already has to take a string of Markdown and convert it to 
LaTeX. I'm using pandoc.write to attempt that, and it seems to be working 
to some degree. The code as it is now is below. I have two problems:

1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my 
calling of pandoc.write into:

```
\cite[165

n.~9,

172]{Haran1982}
```

and I can't figure out why the blank lines are turning up. I imagine I need 
to do something more clever with the Inlines?


2. Despite the fact that my output in the terminal shows that I am 
constructing the citetext variable as I am intending to, and I have this 
line of code:

                    return pandoc.RawInline('latex', citetext)

The output .tex file still has the normal Pandoc citations. In other words, 
my writer is constructing a nice LaTeX string with what I want in it, and 
then discards it in favour of the normal Pandoc code, which is a little bit 
depressing.

Can anyone spot what I'm missing now?

Best,
Lyndon

```
function Writer(doc, opts)
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    local citetext = ""
                    if #el.citations > 1 then
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\textcites*'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\cites*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\cites'
                        end
                    else
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\textcite*'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\cite*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\cite'
                        end
                    end
                    for _, c in pairs(el.citations) do
                        if #c.prefix > 0 then
                            local doc = pandoc.Pandoc(c.prefix)
                            local citeprefix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citeprefix .. ']'
                        end
                        if #c.suffix > 0 then
                            local doc = pandoc.Pandoc(c.suffix)
                            local citesuffix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citesuffix .. ']'
                        end
                        citetext = citetext .. '{' .. c.id .. '}'
                        print(citetext)
                    end
                    return pandoc.RawInline('latex', citetext)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:

> I don't know, but the building blocks you'll need are `pandoc.stringify` 
> which takes any object and converts it into a string, and `pandoc.RawBlock` 
> or `pandoc.RawInline` which convert a string into a raw block or inline, 
> and take the format as first argument and the string as second.
>
> Hth,
>
> Sukil
>
>
> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>
> So I have the citation prefix, which I guess I have to convert to a valid 
> LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>
> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>
>> Ah yep, that works. Next thing is I have to debug my obviously incorrect 
>> code :-)
>>
>> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>
>>> That's the problem. This is a writer, not a filter. So you need to call 
>>> it via 
>>> -t latex-footcite.lua 
>>> ________________________________________ 
>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>> Gesendet: Freitag, 29. Juli 2022 07:15:08 
>>> An: pandoc-discuss 
>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>
>>> My command line is: 
>>>
>>> pandoc -dbookends-latex --template 
>>> /Users/lyndon/.local/share/pandoc/templates/book.latex 
>>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
>>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md 
>>>
>>> It's definitely picking up the lua file because if I have a syntax 
>>> error, pandoc tells me. But I don't get any output. 
>>>
>>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>> How do you run this ? 
>>> I’ve tested with a minimal markdown file : 
>>>
>>> ```markdown 
>>> asdf 
>>> ``` 
>>>
>>> Run with : 
>>> pandoc asdf.md -t mylatex.lua 
>>>
>>> Result : 
>>> got here 
>>> asdf 
>>>
>>> So, it prints the first print statement of the writer. 
>>>
>>> Denis 
>>>
>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>> Auftrag von Lyndon Drake 
>>> Gesendet: Donnerstag, 28. Juli 2022 19:17 
>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>
>>> Thanks for this - exactly what I needed. I've added my attempt at the 
>>> code below, but I must be missing some basic part of it because it doesn't 
>>> do anything. I added a couple of print statements that never get executed: 
>>>
>>> ``` 
>>> function Writer(doc, opts) 
>>> print "got here" 
>>> local filter = { 
>>> Note = function(el) 
>>> return el:walk { 
>>> Cite = function(el) 
>>> -- processing logic 
>>> print "got further" 
>>> local citation = "" 
>>> if #el.citations > 1 then 
>>> if citations[1].mode == "AuthorInText" then 
>>> citation = '\\textcites*' 
>>> elseif citations[1].mode == "SuppressAuthor" then 
>>> citation = '\\cites*' 
>>> elseif citations[1].mode == "NormalCitation" then 
>>> citation = '\\cites' 
>>> end 
>>> else 
>>> if citations[1].mode == "AuthorInText" then 
>>> citation = '\\textcite*' 
>>> elseif citations[1].mode == "SuppressAuthor" then 
>>> citation = '\\cite*' 
>>> elseif citations[1].mode == "NormalCitation" then 
>>> citation = '\\cite' 
>>> end 
>>> end 
>>> for c in el.citations do 
>>> if c.prefix ~= "" then 
>>> citation = citation .. '[' .. c.prefix .. ']' 
>>> end 
>>> if c.suffix ~= "" then 
>>> citation = citation .. '[' .. c.suffix .. ']' 
>>> end 
>>> citation = citation .. '{' .. c.id<http://c.id> .. '}' 
>>> end 
>>> return pandoc.RawInline('latex', citation) 
>>> end 
>>> } 
>>> end 
>>> } 
>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>> end 
>>> ``` 
>>>
>>> Apologies for what must be a very basic question, but what am I missing 
>>> here? 
>>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>> What kind of example do you need? I only know about the examples in the 
>>> documentation. 
>>>
>>> I think this here is a nice one : 
>>>
>>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages 
>>>
>>> Or : the new style writer 
>>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer 
>>>
>>> So, something like this here could be start: 
>>>
>>> ``` 
>>> function Writer(doc, opts) 
>>> local filter = { 
>>> Note = function(el) 
>>> return el:walk { 
>>> Cite = function(el) 
>>> -- processing logic 
>>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}') 
>>> end 
>>> } 
>>> end 
>>> } 
>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>> end 
>>> ``` 
>>>
>>> I don’t think you can get the current writer in Lua. 
>>>
>>>
>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>> Auftrag von Lyndon Drake 
>>> Gesendet: Dienstag, 26. Juli 2022 11:00 
>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>
>>> Thanks for this. I can see how that could work. 
>>>
>>> Can you point me to another example that uses the walk function? 
>>>
>>> Regarding a new-style Lua writer, is there a way to get the current 
>>> LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew 
>>> Haskell but that was rather a long time ago.) 
>>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>> I can't come up with a code example now, bit you can use the walk 
>>> function (https://pandoc.org/lua-filters.html#type-block:walk) to 
>>> modify the citations with a given mode inside notes. You'll need to build 
>>> the citation via Pandoc.RawInline 
>>> Maybe that would be a good example of a new style Lua writer. 
>>> ________________________________________ 
>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>> Gesendet: Montag, 25. Juli 2022 21:46:28 
>>> An: pandoc-discuss 
>>> Betreff: Changing LaTeX output for citations inside footnotes 
>>>
>>> Hi, 
>>>
>>> So this is a slightly odd request, which really comes because of the 
>>> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
>>> that style, \textcite inside a footnote produces an unwanted result. \cite 
>>> produces the expected output. I have generally just gone through and 
>>> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
>>> stage, but that's painful, and I also thought that maybe this is possible 
>>> to do in a Lua filter. 
>>>
>>> But I don't quite know where to start - obviously this is a bit 
>>> different from the internal Pandoc citations. I'm going to begin the filter 
>>> with this: 
>>>
>>> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
>>> function 
>>>
>>> but what would the function be? If it is Footnote, then I don't really 
>>> want the AST, I want the LaTeX that forms the footnote contents, and I 
>>> suppose then I can just replace any occurrences of the string \textcite 
>>> with the string \cite? 
>>>
>>> Any help would be awesome! 
>>>
>>> Best, 
>>> Lyndon 
>>>
>>> -- 
>>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>>> <
>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>>> <
>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>>> <
>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>>> <
>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 29879 bytes --]

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                     ` <0e10379f-d1c0-4024-b98a-5c7ba703f561n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-29 18:04                                                       ` Sukil Etxenike arizaleta
       [not found]                                                         ` <83a04bea-2e09-61d2-de0d-f399beb2ef79-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Sukil Etxenike arizaleta @ 2022-07-29 18:04 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Hi,

For your first problem, when you do pandoc.write, as a minimum a block 
is created, which, I believe, is normally a paragraph. So, don't call 
pandoc.write. I guess you can concatenate the prefix, citation and 
suffix and pass them to the pandoc.RawInline function.


For your second problem, I am guessing you are using --citeproc in your 
defaults file. If that is the case, try: 1) putting the defaults file 
after the filter; or 2) specifying --citeproc manually, also after the 
filter.

Hth,

Sukil


El 29/07/2022 a las 16:58, Lyndon Drake escribió:
> Thanks for all the help - definitely getting somewhere now!
>
> I guess what I want to avoid is replicating in my not-great-Lua code 
> all the work Pandoc already has to take a string of Markdown and 
> convert it to LaTeX. I'm using pandoc.write to attempt that, and it 
> seems to be working to some degree. The code as it is now is below. I 
> have two problems:
>
> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my 
> calling of pandoc.write into:
>
> ```
> \cite[165
>
> n.~9,
>
> 172]{Haran1982}
> ```
>
> and I can't figure out why the blank lines are turning up. I imagine I 
> need to do something more clever with the Inlines?
>
>
> 2. Despite the fact that my output in the terminal shows that I am 
> constructing the citetext variable as I am intending to, and I have 
> this line of code:
>
>                     return pandoc.RawInline('latex', citetext)
>
> The output .tex file still has the normal Pandoc citations. In other 
> words, my writer is constructing a nice LaTeX string with what I want 
> in it, and then discards it in favour of the normal Pandoc code, which 
> is a little bit depressing.
>
> Can anyone spot what I'm missing now?
>
> Best,
> Lyndon
>
> ```
> function Writer(doc, opts)
>     local filter = {
>         Note = function(el)
>             return el:walk {
>                 Cite = function(el)
>                     -- processing logic
>                     local citetext = ""
>                     if #el.citations > 1 then
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\textcites*'
>                         elseif el.citations[1].mode == 
> "SuppressAuthor" then
>                             citetext = '\\cites*'
>                         elseif el.citations[1].mode == 
> "NormalCitation" then
>                             citetext = '\\cites'
>                         end
>                     else
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\textcite*'
>                         elseif el.citations[1].mode == 
> "SuppressAuthor" then
>                             citetext = '\\cite*'
>                         elseif el.citations[1].mode == 
> "NormalCitation" then
>                             citetext = '\\cite'
>                         end
>                     end
>                     for _, c in pairs(el.citations) do
>                         if #c.prefix > 0 then
>                             local doc = pandoc.Pandoc(c.prefix)
>                             local citeprefix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citeprefix 
> .. ']'
>                         end
>                         if #c.suffix > 0 then
>                             local doc = pandoc.Pandoc(c.suffix)
>                             local citesuffix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citesuffix 
> .. ']'
>                         end
>                         citetext = citetext .. '{' .. c.id .. '}'
>                         print(citetext)
>                     end
>                     return pandoc.RawInline('latex', citetext)
>                 end
>             }
>         end
>     }
>     return pandoc.write(doc:walk(filter), 'latex', opts)
> end
> ```
>
> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>     I don't know, but the building blocks you'll need are
>     `pandoc.stringify` which takes any object and converts it into a
>     string, and `pandoc.RawBlock` or `pandoc.RawInline` which convert
>     a string into a raw block or inline, and take the format as first
>     argument and the string as second.
>
>     Hth,
>
>     Sukil
>
>
>     El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>     So I have the citation prefix, which I guess I have to convert to
>>     a valid LaTeX string. How can I take an Inlines and LaTeX-ify it
>>     to a string?
>>
>>     On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>
>>         Ah yep, that works. Next thing is I have to debug my
>>         obviously incorrect code :-)
>>
>>         On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>         wrote:
>>
>>             That's the problem. This is a writer, not a filter. So
>>             you need to call it via
>>             -t latex-footcite.lua
>>             ________________________________________
>>             Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>             <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon Drake
>>             <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>             Gesendet: Freitag, 29. Juli 2022 07:15:08
>>             An: pandoc-discuss
>>             Betreff: Re: Changing LaTeX output for citations inside
>>             footnotes
>>
>>             My command line is:
>>
>>             pandoc -dbookends-latex --template
>>             /Users/lyndon/.local/share/pandoc/templates/book.latex
>>             --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
>>             -s -o thesis_jeremiah_32.tex jer-32-thesis.md
>>
>>             It's definitely picking up the lua file because if I have
>>             a syntax error, pandoc tells me. But I don't get any output.
>>
>>             On Thursday, 28 July 2022 at 21:32:06 UTC+1
>>             denis...-NSENcxR/0n0@public.gmane.org wrote:
>>             How do you run this ?
>>             I’ve tested with a minimal markdown file :
>>
>>             ```markdown
>>             asdf
>>             ```
>>
>>             Run with :
>>             pandoc asdf.md -t mylatex.lua
>>
>>             Result :
>>             got here
>>             asdf
>>
>>             So, it prints the first print statement of the writer.
>>
>>             Denis
>>
>>             Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>             <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
>>             Gesendet: Donnerstag, 28. Juli 2022 19:17
>>             An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>             Betreff: Re: Changing LaTeX output for citations inside
>>             footnotes
>>
>>             Thanks for this - exactly what I needed. I've added my
>>             attempt at the code below, but I must be missing some
>>             basic part of it because it doesn't do anything. I added
>>             a couple of print statements that never get executed:
>>
>>             ```
>>             function Writer(doc, opts)
>>             print "got here"
>>             local filter = {
>>             Note = function(el)
>>             return el:walk {
>>             Cite = function(el)
>>             -- processing logic
>>             print "got further"
>>             local citation = ""
>>             if #el.citations > 1 then
>>             if citations[1].mode == "AuthorInText" then
>>             citation = '\\textcites*'
>>             elseif citations[1].mode == "SuppressAuthor" then
>>             citation = '\\cites*'
>>             elseif citations[1].mode == "NormalCitation" then
>>             citation = '\\cites'
>>             end
>>             else
>>             if citations[1].mode == "AuthorInText" then
>>             citation = '\\textcite*'
>>             elseif citations[1].mode == "SuppressAuthor" then
>>             citation = '\\cite*'
>>             elseif citations[1].mode == "NormalCitation" then
>>             citation = '\\cite'
>>             end
>>             end
>>             for c in el.citations do
>>             if c.prefix ~= "" then
>>             citation = citation .. '[' .. c.prefix .. ']'
>>             end
>>             if c.suffix ~= "" then
>>             citation = citation .. '[' .. c.suffix .. ']'
>>             end
>>             citation = citation .. '{' .. c.id
>>             <http://c.id><http://c.id> .. '}'
>>             end
>>             return pandoc.RawInline('latex', citation)
>>             end
>>             }
>>             end
>>             }
>>             return pandoc.write(doc:walk(filter), 'latex', opts)
>>             end
>>             ```
>>
>>             Apologies for what must be a very basic question, but
>>             what am I missing here?
>>             On Wednesday, 27 July 2022 at 11:27:32 UTC+1
>>             denis...-NSENcxR/0n0@public.gmane.org wrote:
>>             What kind of example do you need? I only know about the
>>             examples in the documentation.
>>
>>             I think this here is a nice one :
>>             https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>>
>>
>>             Or : the new style writer
>>             https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>>
>>
>>             So, something like this here could be start:
>>
>>             ```
>>             function Writer(doc, opts)
>>             local filter = {
>>             Note = function(el)
>>             return el:walk {
>>             Cite = function(el)
>>             -- processing logic
>>             return pandoc.RawInline('latex',
>>             '\\cite[prenote][postnote]{key}')
>>             end
>>             }
>>             end
>>             }
>>             return pandoc.write(doc:walk(filter), 'latex', opts)
>>             end
>>             ```
>>
>>             I don’t think you can get the current writer in Lua.
>>
>>
>>             Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>             <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
>>             Gesendet: Dienstag, 26. Juli 2022 11:00
>>             An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>             Betreff: Re: Changing LaTeX output for citations inside
>>             footnotes
>>
>>             Thanks for this. I can see how that could work.
>>
>>             Can you point me to another example that uses the walk
>>             function?
>>
>>             Regarding a new-style Lua writer, is there a way to get
>>             the current LaTeX writer as Lua code? Or is it just the
>>             Haskell code? (I once knew Haskell but that was rather a
>>             long time ago.)
>>             On Monday, 25 July 2022 at 22:02:38 UTC+1
>>             denis...-NSENcxR/0n0@public.gmane.org wrote:
>>             I can't come up with a code example now, bit you can use
>>             the walk function
>>             (https://pandoc.org/lua-filters.html#type-block:walk) to
>>             modify the citations with a given mode inside notes.
>>             You'll need to build the citation via Pandoc.RawInline
>>             Maybe that would be a good example of a new style Lua
>>             writer.
>>             ________________________________________
>>             Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>             <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon Drake
>>             <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>             Gesendet: Montag, 25. Juli 2022 21:46:28
>>             An: pandoc-discuss
>>             Betreff: Changing LaTeX output for citations inside
>>             footnotes
>>
>>             Hi,
>>
>>             So this is a slightly odd request, which really comes
>>             because of the unusual behaviour of the specific BibLaTeX
>>             bibliography style I'm using. In that style, \textcite
>>             inside a footnote produces an unwanted result. \cite
>>             produces the expected output. I have generally just gone
>>             through and hand-edited my Pandoc-produced LaTeX files
>>             when they get to the final copy stage, but that's
>>             painful, and I also thought that maybe this is possible
>>             to do in a Lua filter.
>>
>>             But I don't quite know where to start - obviously this is
>>             a bit different from the internal Pandoc citations. I'm
>>             going to begin the filter with this:
>>
>>             if FORMAT:match 'latex' then
>>             <https://pandoc.org/lua-filters.html#cb9-3> function
>>
>>             but what would the function be? If it is Footnote, then I
>>             don't really want the AST, I want the LaTeX that forms
>>             the footnote contents, and I suppose then I can just
>>             replace any occurrences of the string \textcite with the
>>             string \cite?
>>
>>             Any help would be awesome!
>>
>>             Best,
>>             Lyndon
>>
>>             -- 
>>             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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
>>
>>             To view this discussion on the web visit
>>             https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com?utm_medium=email&utm_source=footer
>>             <https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>             To view this discussion on the web visit
>>             https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com?utm_medium=email&utm_source=footer
>>             <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>             To view this discussion on the web visit
>>             https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com?utm_medium=email&utm_source=footer
>>             <https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
>>
>>             To view this discussion on the web visit
>>             https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com?utm_medium=email&utm_source=footer
>>             <https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>     To view this discussion on the web visit
>>     https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com
>>     <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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/83a04bea-2e09-61d2-de0d-f399beb2ef79%40gmail.com.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                         ` <83a04bea-2e09-61d2-de0d-f399beb2ef79-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-07-30 12:39                                                           ` Lyndon Drake
       [not found]                                                             ` <76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-30 12:39 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 16988 bytes --]

Hi Sukil,

Thanks, you were quite correct about the second problem. I've amended that 
and it now works, at least in the sense that it is altering the output in 
the general way I want.

On the first problem, I can just pandoc.stringify the prefix and suffix, 
and concatenate. The problem with that is I will then lose any Markdown 
formatting, which is not entirely uncommon in a prefix, and even 
occasionally in a suffix. I can work around it for this document, I guess, 
by just being careful not to use any Markdown formatting in these 
instances, but I'd love to find a way to take a set of Inlines and convert 
it to a format without adding a block.

On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:

> Hi,
>
> For your first problem, when you do pandoc.write, as a minimum a block is 
> created, which, I believe, is normally a paragraph. So, don't call 
> pandoc.write. I guess you can concatenate the prefix, citation and suffix 
> and pass them to the pandoc.RawInline function. 
>
>
> For your second problem, I am guessing you are using --citeproc in your 
> defaults file. If that is the case, try: 1) putting the defaults file after 
> the filter; or 2) specifying --citeproc manually, also after the filter.
>
> Hth,
>
> Sukil
>
>
> El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>
> Thanks for all the help - definitely getting somewhere now!
>
> I guess what I want to avoid is replicating in my not-great-Lua code all 
> the work Pandoc already has to take a string of Markdown and convert it to 
> LaTeX. I'm using pandoc.write to attempt that, and it seems to be working 
> to some degree. The code as it is now is below. I have two problems: 
>
> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my 
> calling of pandoc.write into:
>
> ```
> \cite[165
>
> n.~9,
>
> 172]{Haran1982}
> ```
>
> and I can't figure out why the blank lines are turning up. I imagine I 
> need to do something more clever with the Inlines?
>
>
> 2. Despite the fact that my output in the terminal shows that I am 
> constructing the citetext variable as I am intending to, and I have this 
> line of code:
>
>                     return pandoc.RawInline('latex', citetext)
>
> The output .tex file still has the normal Pandoc citations. In other 
> words, my writer is constructing a nice LaTeX string with what I want in 
> it, and then discards it in favour of the normal Pandoc code, which is a 
> little bit depressing.
>
> Can anyone spot what I'm missing now?
>
> Best,
> Lyndon
>
> ```
> function Writer(doc, opts)
>     local filter = {
>         Note = function(el)
>             return el:walk {
>                 Cite = function(el)
>                     -- processing logic
>                     local citetext = ""
>                     if #el.citations > 1 then
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\textcites*'
>                         elseif el.citations[1].mode == "SuppressAuthor" 
> then
>                             citetext = '\\cites*'
>                         elseif el.citations[1].mode == "NormalCitation" 
> then
>                             citetext = '\\cites'
>                         end
>                     else
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\textcite*'
>                         elseif el.citations[1].mode == "SuppressAuthor" 
> then
>                             citetext = '\\cite*'
>                         elseif el.citations[1].mode == "NormalCitation" 
> then
>                             citetext = '\\cite'
>                         end
>                     end
>                     for _, c in pairs(el.citations) do
>                         if #c.prefix > 0 then
>                             local doc = pandoc.Pandoc(c.prefix)
>                             local citeprefix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citeprefix .. ']'
>                         end
>                         if #c.suffix > 0 then
>                             local doc = pandoc.Pandoc(c.suffix)
>                             local citesuffix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citesuffix .. ']'
>                         end
>                         citetext = citetext .. '{' .. c.id .. '}'
>                         print(citetext)
>                     end
>                     return pandoc.RawInline('latex', citetext)
>                 end
>             }
>         end
>     }
>     return pandoc.write(doc:walk(filter), 'latex', opts)
> end
> ```
>
> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>> I don't know, but the building blocks you'll need are `pandoc.stringify` 
>> which takes any object and converts it into a string, and `pandoc.RawBlock` 
>> or `pandoc.RawInline` which convert a string into a raw block or inline, 
>> and take the format as first argument and the string as second.
>>
>> Hth,
>>
>> Sukil
>>
>>
>> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>
>> So I have the citation prefix, which I guess I have to convert to a valid 
>> LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>>
>> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>
>>> Ah yep, that works. Next thing is I have to debug my obviously incorrect 
>>> code :-)
>>>
>>> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>
>>>> That's the problem. This is a writer, not a filter. So you need to call 
>>>> it via 
>>>> -t latex-footcite.lua 
>>>> ________________________________________ 
>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>> Gesendet: Freitag, 29. Juli 2022 07:15:08 
>>>> An: pandoc-discuss 
>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>
>>>> My command line is: 
>>>>
>>>> pandoc -dbookends-latex --template 
>>>> /Users/lyndon/.local/share/pandoc/templates/book.latex 
>>>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
>>>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md 
>>>>
>>>> It's definitely picking up the lua file because if I have a syntax 
>>>> error, pandoc tells me. But I don't get any output. 
>>>>
>>>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>>> How do you run this ? 
>>>> I’ve tested with a minimal markdown file : 
>>>>
>>>> ```markdown 
>>>> asdf 
>>>> ``` 
>>>>
>>>> Run with : 
>>>> pandoc asdf.md -t mylatex.lua 
>>>>
>>>> Result : 
>>>> got here 
>>>> asdf 
>>>>
>>>> So, it prints the first print statement of the writer. 
>>>>
>>>> Denis 
>>>>
>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>> Auftrag von Lyndon Drake 
>>>> Gesendet: Donnerstag, 28. Juli 2022 19:17 
>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>
>>>> Thanks for this - exactly what I needed. I've added my attempt at the 
>>>> code below, but I must be missing some basic part of it because it doesn't 
>>>> do anything. I added a couple of print statements that never get executed: 
>>>>
>>>> ``` 
>>>> function Writer(doc, opts) 
>>>> print "got here" 
>>>> local filter = { 
>>>> Note = function(el) 
>>>> return el:walk { 
>>>> Cite = function(el) 
>>>> -- processing logic 
>>>> print "got further" 
>>>> local citation = "" 
>>>> if #el.citations > 1 then 
>>>> if citations[1].mode == "AuthorInText" then 
>>>> citation = '\\textcites*' 
>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>> citation = '\\cites*' 
>>>> elseif citations[1].mode == "NormalCitation" then 
>>>> citation = '\\cites' 
>>>> end 
>>>> else 
>>>> if citations[1].mode == "AuthorInText" then 
>>>> citation = '\\textcite*' 
>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>> citation = '\\cite*' 
>>>> elseif citations[1].mode == "NormalCitation" then 
>>>> citation = '\\cite' 
>>>> end 
>>>> end 
>>>> for c in el.citations do 
>>>> if c.prefix ~= "" then 
>>>> citation = citation .. '[' .. c.prefix .. ']' 
>>>> end 
>>>> if c.suffix ~= "" then 
>>>> citation = citation .. '[' .. c.suffix .. ']' 
>>>> end 
>>>> citation = citation .. '{' .. c.id<http://c.id> .. '}' 
>>>> end 
>>>> return pandoc.RawInline('latex', citation) 
>>>> end 
>>>> } 
>>>> end 
>>>> } 
>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>> end 
>>>> ``` 
>>>>
>>>> Apologies for what must be a very basic question, but what am I missing 
>>>> here? 
>>>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>>> What kind of example do you need? I only know about the examples in the 
>>>> documentation. 
>>>>
>>>> I think this here is a nice one : 
>>>>
>>>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages 
>>>>
>>>> Or : the new style writer 
>>>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer 
>>>>
>>>> So, something like this here could be start: 
>>>>
>>>> ``` 
>>>> function Writer(doc, opts) 
>>>> local filter = { 
>>>> Note = function(el) 
>>>> return el:walk { 
>>>> Cite = function(el) 
>>>> -- processing logic 
>>>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}') 
>>>> end 
>>>> } 
>>>> end 
>>>> } 
>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>> end 
>>>> ``` 
>>>>
>>>> I don’t think you can get the current writer in Lua. 
>>>>
>>>>
>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>> Auftrag von Lyndon Drake 
>>>> Gesendet: Dienstag, 26. Juli 2022 11:00 
>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>
>>>> Thanks for this. I can see how that could work. 
>>>>
>>>> Can you point me to another example that uses the walk function? 
>>>>
>>>> Regarding a new-style Lua writer, is there a way to get the current 
>>>> LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew 
>>>> Haskell but that was rather a long time ago.) 
>>>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>>> I can't come up with a code example now, bit you can use the walk 
>>>> function (https://pandoc.org/lua-filters.html#type-block:walk) to 
>>>> modify the citations with a given mode inside notes. You'll need to build 
>>>> the citation via Pandoc.RawInline 
>>>> Maybe that would be a good example of a new style Lua writer. 
>>>> ________________________________________ 
>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>> Gesendet: Montag, 25. Juli 2022 21:46:28 
>>>> An: pandoc-discuss 
>>>> Betreff: Changing LaTeX output for citations inside footnotes 
>>>>
>>>> Hi, 
>>>>
>>>> So this is a slightly odd request, which really comes because of the 
>>>> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
>>>> that style, \textcite inside a footnote produces an unwanted result. \cite 
>>>> produces the expected output. I have generally just gone through and 
>>>> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
>>>> stage, but that's painful, and I also thought that maybe this is possible 
>>>> to do in a Lua filter. 
>>>>
>>>> But I don't quite know where to start - obviously this is a bit 
>>>> different from the internal Pandoc citations. I'm going to begin the filter 
>>>> with this: 
>>>>
>>>> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
>>>> function 
>>>>
>>>> but what would the function be? If it is Footnote, then I don't really 
>>>> want the AST, I want the LaTeX that forms the footnote contents, and I 
>>>> suppose then I can just replace any occurrences of the string \textcite 
>>>> with the string \cite? 
>>>>
>>>> Any help would be awesome! 
>>>>
>>>> Best, 
>>>> Lyndon 
>>>>
>>>> -- 
>>>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>>>> <
>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>>>> <
>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>>>> <
>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>>>> <
>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 33585 bytes --]

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                             ` <76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-07-30 13:06                                                               ` Sukil Etxenike arizaleta
       [not found]                                                                 ` <7ead9a3f-3aa9-fb2e-5ad5-c069d2aee315-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Sukil Etxenike arizaleta @ 2022-07-30 13:06 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

I believe you can't create a pandoc document without any block. Two 
possibilities come to mind:

1. Round tripping: After fixing the citation, read it as LaTeX, and 
maybe, run pandoc.utils.blocks_to_inlines. (Hey, I never said it 
wouldn't be messy). May not work, even.

2. Simply delete all paragraph markers: in your case with: 
citetext:gsub("\n*", " ")

Hth,

Sukil



El 30/07/2022 a las 14:39, Lyndon Drake escribió:

> Hi Sukil,
>
> Thanks, you were quite correct about the second problem. I've amended 
> that and it now works, at least in the sense that it is altering the 
> output in the general way I want.
>
> On the first problem, I can just pandoc.stringify the prefix and 
> suffix, and concatenate. The problem with that is I will then lose any 
> Markdown formatting, which is not entirely uncommon in a prefix, and 
> even occasionally in a suffix. I can work around it for this document, 
> I guess, by just being careful not to use any Markdown formatting in 
> these instances, but I'd love to find a way to take a set of Inlines 
> and convert it to a format without adding a block.
>
> On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>     Hi,
>
>     For your first problem, when you do pandoc.write, as a minimum a
>     block is created, which, I believe, is normally a paragraph. So,
>     don't call pandoc.write. I guess you can concatenate the prefix,
>     citation and suffix and pass them to the pandoc.RawInline function.
>
>
>     For your second problem, I am guessing you are using --citeproc in
>     your defaults file. If that is the case, try: 1) putting the
>     defaults file after the filter; or 2) specifying --citeproc
>     manually, also after the filter.
>
>     Hth,
>
>     Sukil
>
>
>     El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>     Thanks for all the help - definitely getting somewhere now!
>>
>>     I guess what I want to avoid is replicating in my not-great-Lua
>>     code all the work Pandoc already has to take a string of Markdown
>>     and convert it to LaTeX. I'm using pandoc.write to attempt that,
>>     and it seems to be working to some degree. The code as it is now
>>     is below. I have two problems:
>>
>>     1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted
>>     by my calling of pandoc.write into:
>>
>>     ```
>>     \cite[165
>>
>>     n.~9,
>>
>>     172]{Haran1982}
>>     ```
>>
>>     and I can't figure out why the blank lines are turning up. I
>>     imagine I need to do something more clever with the Inlines?
>>
>>
>>     2. Despite the fact that my output in the terminal shows that I
>>     am constructing the citetext variable as I am intending to, and I
>>     have this line of code:
>>
>>                         return pandoc.RawInline('latex', citetext)
>>
>>     The output .tex file still has the normal Pandoc citations. In
>>     other words, my writer is constructing a nice LaTeX string with
>>     what I want in it, and then discards it in favour of the normal
>>     Pandoc code, which is a little bit depressing.
>>
>>     Can anyone spot what I'm missing now?
>>
>>     Best,
>>     Lyndon
>>
>>     ```
>>     function Writer(doc, opts)
>>         local filter = {
>>             Note = function(el)
>>                 return el:walk {
>>                     Cite = function(el)
>>                         -- processing logic
>>                         local citetext = ""
>>                         if #el.citations > 1 then
>>                             if el.citations[1].mode == "AuthorInText"
>>     then
>>                                 citetext = '\\textcites*'
>>                             elseif el.citations[1].mode ==
>>     "SuppressAuthor" then
>>                                 citetext = '\\cites*'
>>                             elseif el.citations[1].mode ==
>>     "NormalCitation" then
>>                                 citetext = '\\cites'
>>                             end
>>                         else
>>                             if el.citations[1].mode == "AuthorInText"
>>     then
>>                                 citetext = '\\textcite*'
>>                             elseif el.citations[1].mode ==
>>     "SuppressAuthor" then
>>                                 citetext = '\\cite*'
>>                             elseif el.citations[1].mode ==
>>     "NormalCitation" then
>>                                 citetext = '\\cite'
>>                             end
>>                         end
>>                         for _, c in pairs(el.citations) do
>>                             if #c.prefix > 0 then
>>                                 local doc = pandoc.Pandoc(c.prefix)
>>                                 local citeprefix = pandoc.write(doc,
>>     'latex')
>>                                 citetext = citetext .. '[' ..
>>     citeprefix .. ']'
>>                             end
>>                             if #c.suffix > 0 then
>>                                 local doc = pandoc.Pandoc(c.suffix)
>>                                 local citesuffix = pandoc.write(doc,
>>     'latex')
>>                                 citetext = citetext .. '[' ..
>>     citesuffix .. ']'
>>                             end
>>                             citetext = citetext .. '{' .. c.id
>>     <http://c.id> .. '}'
>>                             print(citetext)
>>                         end
>>                         return pandoc.RawInline('latex', citetext)
>>                     end
>>                 }
>>             end
>>         }
>>         return pandoc.write(doc:walk(filter), 'latex', opts)
>>     end
>>     ```
>>
>>     On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>
>>         I don't know, but the building blocks you'll need are
>>         `pandoc.stringify` which takes any object and converts it
>>         into a string, and `pandoc.RawBlock` or `pandoc.RawInline`
>>         which convert a string into a raw block or inline, and take
>>         the format as first argument and the string as second.
>>
>>         Hth,
>>
>>         Sukil
>>
>>
>>         El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>>         So I have the citation prefix, which I guess I have to
>>>         convert to a valid LaTeX string. How can I take an Inlines
>>>         and LaTeX-ify it to a string?
>>>
>>>         On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>>
>>>             Ah yep, that works. Next thing is I have to debug my
>>>             obviously incorrect code :-)
>>>
>>>             On Friday, 29 July 2022 at 06:44:22 UTC+1
>>>             denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>
>>>                 That's the problem. This is a writer, not a filter.
>>>                 So you need to call it via
>>>                 -t latex-footcite.lua
>>>                 ________________________________________
>>>                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon
>>>                 Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>                 Gesendet: Freitag, 29. Juli 2022 07:15:08
>>>                 An: pandoc-discuss
>>>                 Betreff: Re: Changing LaTeX output for citations
>>>                 inside footnotes
>>>
>>>                 My command line is:
>>>
>>>                 pandoc -dbookends-latex --template
>>>                 /Users/lyndon/.local/share/pandoc/templates/book.latex
>>>                 --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
>>>                 -s -o thesis_jeremiah_32.tex jer-32-thesis.md
>>>
>>>                 It's definitely picking up the lua file because if I
>>>                 have a syntax error, pandoc tells me. But I don't
>>>                 get any output.
>>>
>>>                 On Thursday, 28 July 2022 at 21:32:06 UTC+1
>>>                 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>                 How do you run this ?
>>>                 I’ve tested with a minimal markdown file :
>>>
>>>                 ```markdown
>>>                 asdf
>>>                 ```
>>>
>>>                 Run with :
>>>                 pandoc asdf.md -t mylatex.lua
>>>
>>>                 Result :
>>>                 got here
>>>                 asdf
>>>
>>>                 So, it prints the first print statement of the writer.
>>>
>>>                 Denis
>>>
>>>                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon
>>>                 Drake
>>>                 Gesendet: Donnerstag, 28. Juli 2022 19:17
>>>                 An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>                 Betreff: Re: Changing LaTeX output for citations
>>>                 inside footnotes
>>>
>>>                 Thanks for this - exactly what I needed. I've added
>>>                 my attempt at the code below, but I must be missing
>>>                 some basic part of it because it doesn't do
>>>                 anything. I added a couple of print statements that
>>>                 never get executed:
>>>
>>>                 ```
>>>                 function Writer(doc, opts)
>>>                 print "got here"
>>>                 local filter = {
>>>                 Note = function(el)
>>>                 return el:walk {
>>>                 Cite = function(el)
>>>                 -- processing logic
>>>                 print "got further"
>>>                 local citation = ""
>>>                 if #el.citations > 1 then
>>>                 if citations[1].mode == "AuthorInText" then
>>>                 citation = '\\textcites*'
>>>                 elseif citations[1].mode == "SuppressAuthor" then
>>>                 citation = '\\cites*'
>>>                 elseif citations[1].mode == "NormalCitation" then
>>>                 citation = '\\cites'
>>>                 end
>>>                 else
>>>                 if citations[1].mode == "AuthorInText" then
>>>                 citation = '\\textcite*'
>>>                 elseif citations[1].mode == "SuppressAuthor" then
>>>                 citation = '\\cite*'
>>>                 elseif citations[1].mode == "NormalCitation" then
>>>                 citation = '\\cite'
>>>                 end
>>>                 end
>>>                 for c in el.citations do
>>>                 if c.prefix ~= "" then
>>>                 citation = citation .. '[' .. c.prefix .. ']'
>>>                 end
>>>                 if c.suffix ~= "" then
>>>                 citation = citation .. '[' .. c.suffix .. ']'
>>>                 end
>>>                 citation = citation .. '{' .. c.id
>>>                 <http://c.id><http://c.id> .. '}'
>>>                 end
>>>                 return pandoc.RawInline('latex', citation)
>>>                 end
>>>                 }
>>>                 end
>>>                 }
>>>                 return pandoc.write(doc:walk(filter), 'latex', opts)
>>>                 end
>>>                 ```
>>>
>>>                 Apologies for what must be a very basic question,
>>>                 but what am I missing here?
>>>                 On Wednesday, 27 July 2022 at 11:27:32 UTC+1
>>>                 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>                 What kind of example do you need? I only know about
>>>                 the examples in the documentation.
>>>
>>>                 I think this here is a nice one :
>>>                 https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>>>
>>>
>>>                 Or : the new style writer
>>>                 https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>>>
>>>
>>>                 So, something like this here could be start:
>>>
>>>                 ```
>>>                 function Writer(doc, opts)
>>>                 local filter = {
>>>                 Note = function(el)
>>>                 return el:walk {
>>>                 Cite = function(el)
>>>                 -- processing logic
>>>                 return pandoc.RawInline('latex',
>>>                 '\\cite[prenote][postnote]{key}')
>>>                 end
>>>                 }
>>>                 end
>>>                 }
>>>                 return pandoc.write(doc:walk(filter), 'latex', opts)
>>>                 end
>>>                 ```
>>>
>>>                 I don’t think you can get the current writer in Lua.
>>>
>>>
>>>                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon
>>>                 Drake
>>>                 Gesendet: Dienstag, 26. Juli 2022 11:00
>>>                 An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>                 Betreff: Re: Changing LaTeX output for citations
>>>                 inside footnotes
>>>
>>>                 Thanks for this. I can see how that could work.
>>>
>>>                 Can you point me to another example that uses the
>>>                 walk function?
>>>
>>>                 Regarding a new-style Lua writer, is there a way to
>>>                 get the current LaTeX writer as Lua code? Or is it
>>>                 just the Haskell code? (I once knew Haskell but that
>>>                 was rather a long time ago.)
>>>                 On Monday, 25 July 2022 at 22:02:38 UTC+1
>>>                 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>                 I can't come up with a code example now, bit you can
>>>                 use the walk function
>>>                 (https://pandoc.org/lua-filters.html#type-block:walk)
>>>                 to modify the citations with a given mode inside
>>>                 notes. You'll need to build the citation via
>>>                 Pandoc.RawInline
>>>                 Maybe that would be a good example of a new style
>>>                 Lua writer.
>>>                 ________________________________________
>>>                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag von Lyndon
>>>                 Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>                 Gesendet: Montag, 25. Juli 2022 21:46:28
>>>                 An: pandoc-discuss
>>>                 Betreff: Changing LaTeX output for citations inside
>>>                 footnotes
>>>
>>>                 Hi,
>>>
>>>                 So this is a slightly odd request, which really
>>>                 comes because of the unusual behaviour of the
>>>                 specific BibLaTeX bibliography style I'm using. In
>>>                 that style, \textcite inside a footnote produces an
>>>                 unwanted result. \cite produces the expected output.
>>>                 I have generally just gone through and hand-edited
>>>                 my Pandoc-produced LaTeX files when they get to the
>>>                 final copy stage, but that's painful, and I also
>>>                 thought that maybe this is possible to do in a Lua
>>>                 filter.
>>>
>>>                 But I don't quite know where to start - obviously
>>>                 this is a bit different from the internal Pandoc
>>>                 citations. I'm going to begin the filter with this:
>>>
>>>                 if FORMAT:match 'latex' then
>>>                 <https://pandoc.org/lua-filters.html#cb9-3> function
>>>
>>>                 but what would the function be? If it is Footnote,
>>>                 then I don't really want the AST, I want the LaTeX
>>>                 that forms the footnote contents, and I suppose then
>>>                 I can just replace any occurrences of the string
>>>                 \textcite with the string \cite?
>>>
>>>                 Any help would be awesome!
>>>
>>>                 Best,
>>>                 Lyndon
>>>
>>>                 -- 
>>>                 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
>>>
>>>                 To view this discussion on the web visit
>>>                 https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com?utm_medium=email&utm_source=footer
>>>                 <https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>                 To view this discussion on the web visit
>>>                 https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com?utm_medium=email&utm_source=footer
>>>                 <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>                 To view this discussion on the web visit
>>>                 https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com?utm_medium=email&utm_source=footer
>>>                 <https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
>>>
>>>                 To view this discussion on the web visit
>>>                 https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com?utm_medium=email&utm_source=footer
>>>                 <https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>         To view this discussion on the web visit
>>>         https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com
>>>         <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>     To view this discussion on the web visit
>>     https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com
>>     <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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/7ead9a3f-3aa9-fb2e-5ad5-c069d2aee315%40gmail.com.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                 ` <7ead9a3f-3aa9-fb2e-5ad5-c069d2aee315-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-07-30 13:53                                                                   ` Lyndon Drake
       [not found]                                                                     ` <5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-07-30 13:53 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 18807 bytes --]

Nice, the :gsub does the trick (once I replaced \n* with \n+).

Thanks again, really appreciate the help with all this. Hopefully I can 
start to build some more Lua filters/writers now. It's a great system 
(thanks John MacFarlane!).

On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:

> I believe you can't create a pandoc document without any block. Two 
> possibilities come to mind:
>
> 1. Round tripping: After fixing the citation, read it as LaTeX, and maybe, 
> run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't be 
> messy). May not work, even.
>
> 2. Simply delete all paragraph markers: in your case with: 
> citetext:gsub("\n*", " ")
>
> Hth,
>
> Sukil
>
>
>
> El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>
> Hi Sukil, 
>
> Thanks, you were quite correct about the second problem. I've amended that 
> and it now works, at least in the sense that it is altering the output in 
> the general way I want.
>
> On the first problem, I can just pandoc.stringify the prefix and suffix, 
> and concatenate. The problem with that is I will then lose any Markdown 
> formatting, which is not entirely uncommon in a prefix, and even 
> occasionally in a suffix. I can work around it for this document, I guess, 
> by just being careful not to use any Markdown formatting in these 
> instances, but I'd love to find a way to take a set of Inlines and convert 
> it to a format without adding a block.
>
> On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>> Hi,
>>
>> For your first problem, when you do pandoc.write, as a minimum a block is 
>> created, which, I believe, is normally a paragraph. So, don't call 
>> pandoc.write. I guess you can concatenate the prefix, citation and suffix 
>> and pass them to the pandoc.RawInline function. 
>>
>>
>> For your second problem, I am guessing you are using --citeproc in your 
>> defaults file. If that is the case, try: 1) putting the defaults file after 
>> the filter; or 2) specifying --citeproc manually, also after the filter.
>>
>> Hth,
>>
>> Sukil
>>
>>
>> El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>
>> Thanks for all the help - definitely getting somewhere now!
>>
>> I guess what I want to avoid is replicating in my not-great-Lua code all 
>> the work Pandoc already has to take a string of Markdown and convert it to 
>> LaTeX. I'm using pandoc.write to attempt that, and it seems to be working 
>> to some degree. The code as it is now is below. I have two problems: 
>>
>> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my 
>> calling of pandoc.write into:
>>
>> ```
>> \cite[165
>>
>> n.~9,
>>
>> 172]{Haran1982}
>> ```
>>
>> and I can't figure out why the blank lines are turning up. I imagine I 
>> need to do something more clever with the Inlines?
>>
>>
>> 2. Despite the fact that my output in the terminal shows that I am 
>> constructing the citetext variable as I am intending to, and I have this 
>> line of code:
>>
>>                     return pandoc.RawInline('latex', citetext)
>>
>> The output .tex file still has the normal Pandoc citations. In other 
>> words, my writer is constructing a nice LaTeX string with what I want in 
>> it, and then discards it in favour of the normal Pandoc code, which is a 
>> little bit depressing.
>>
>> Can anyone spot what I'm missing now?
>>
>> Best,
>> Lyndon
>>
>> ```
>> function Writer(doc, opts)
>>     local filter = {
>>         Note = function(el)
>>             return el:walk {
>>                 Cite = function(el)
>>                     -- processing logic
>>                     local citetext = ""
>>                     if #el.citations > 1 then
>>                         if el.citations[1].mode == "AuthorInText" then
>>                             citetext = '\\textcites*'
>>                         elseif el.citations[1].mode == "SuppressAuthor" 
>> then
>>                             citetext = '\\cites*'
>>                         elseif el.citations[1].mode == "NormalCitation" 
>> then
>>                             citetext = '\\cites'
>>                         end
>>                     else
>>                         if el.citations[1].mode == "AuthorInText" then
>>                             citetext = '\\textcite*'
>>                         elseif el.citations[1].mode == "SuppressAuthor" 
>> then
>>                             citetext = '\\cite*'
>>                         elseif el.citations[1].mode == "NormalCitation" 
>> then
>>                             citetext = '\\cite'
>>                         end
>>                     end
>>                     for _, c in pairs(el.citations) do
>>                         if #c.prefix > 0 then
>>                             local doc = pandoc.Pandoc(c.prefix)
>>                             local citeprefix = pandoc.write(doc, 'latex')
>>                             citetext = citetext .. '[' .. citeprefix .. 
>> ']'
>>                         end
>>                         if #c.suffix > 0 then
>>                             local doc = pandoc.Pandoc(c.suffix)
>>                             local citesuffix = pandoc.write(doc, 'latex')
>>                             citetext = citetext .. '[' .. citesuffix .. 
>> ']'
>>                         end
>>                         citetext = citetext .. '{' .. c.id .. '}'
>>                         print(citetext)
>>                     end
>>                     return pandoc.RawInline('latex', citetext)
>>                 end
>>             }
>>         end
>>     }
>>     return pandoc.write(doc:walk(filter), 'latex', opts)
>> end
>> ```
>>
>> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>
>>> I don't know, but the building blocks you'll need are `pandoc.stringify` 
>>> which takes any object and converts it into a string, and `pandoc.RawBlock` 
>>> or `pandoc.RawInline` which convert a string into a raw block or inline, 
>>> and take the format as first argument and the string as second.
>>>
>>> Hth,
>>>
>>> Sukil
>>>
>>>
>>> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>>
>>> So I have the citation prefix, which I guess I have to convert to a 
>>> valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>>>
>>> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>>
>>>> Ah yep, that works. Next thing is I have to debug my obviously 
>>>> incorrect code :-)
>>>>
>>>> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>
>>>>> That's the problem. This is a writer, not a filter. So you need to 
>>>>> call it via 
>>>>> -t latex-footcite.lua 
>>>>> ________________________________________ 
>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>>> Gesendet: Freitag, 29. Juli 2022 07:15:08 
>>>>> An: pandoc-discuss 
>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>
>>>>> My command line is: 
>>>>>
>>>>> pandoc -dbookends-latex --template 
>>>>> /Users/lyndon/.local/share/pandoc/templates/book.latex 
>>>>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
>>>>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md 
>>>>>
>>>>> It's definitely picking up the lua file because if I have a syntax 
>>>>> error, pandoc tells me. But I don't get any output. 
>>>>>
>>>>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>>>> How do you run this ? 
>>>>> I’ve tested with a minimal markdown file : 
>>>>>
>>>>> ```markdown 
>>>>> asdf 
>>>>> ``` 
>>>>>
>>>>> Run with : 
>>>>> pandoc asdf.md -t mylatex.lua 
>>>>>
>>>>> Result : 
>>>>> got here 
>>>>> asdf 
>>>>>
>>>>> So, it prints the first print statement of the writer. 
>>>>>
>>>>> Denis 
>>>>>
>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>>> Auftrag von Lyndon Drake 
>>>>> Gesendet: Donnerstag, 28. Juli 2022 19:17 
>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>
>>>>> Thanks for this - exactly what I needed. I've added my attempt at the 
>>>>> code below, but I must be missing some basic part of it because it doesn't 
>>>>> do anything. I added a couple of print statements that never get executed: 
>>>>>
>>>>> ``` 
>>>>> function Writer(doc, opts) 
>>>>> print "got here" 
>>>>> local filter = { 
>>>>> Note = function(el) 
>>>>> return el:walk { 
>>>>> Cite = function(el) 
>>>>> -- processing logic 
>>>>> print "got further" 
>>>>> local citation = "" 
>>>>> if #el.citations > 1 then 
>>>>> if citations[1].mode == "AuthorInText" then 
>>>>> citation = '\\textcites*' 
>>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>>> citation = '\\cites*' 
>>>>> elseif citations[1].mode == "NormalCitation" then 
>>>>> citation = '\\cites' 
>>>>> end 
>>>>> else 
>>>>> if citations[1].mode == "AuthorInText" then 
>>>>> citation = '\\textcite*' 
>>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>>> citation = '\\cite*' 
>>>>> elseif citations[1].mode == "NormalCitation" then 
>>>>> citation = '\\cite' 
>>>>> end 
>>>>> end 
>>>>> for c in el.citations do 
>>>>> if c.prefix ~= "" then 
>>>>> citation = citation .. '[' .. c.prefix .. ']' 
>>>>> end 
>>>>> if c.suffix ~= "" then 
>>>>> citation = citation .. '[' .. c.suffix .. ']' 
>>>>> end 
>>>>> citation = citation .. '{' .. c.id<http://c.id> .. '}' 
>>>>> end 
>>>>> return pandoc.RawInline('latex', citation) 
>>>>> end 
>>>>> } 
>>>>> end 
>>>>> } 
>>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>>> end 
>>>>> ``` 
>>>>>
>>>>> Apologies for what must be a very basic question, but what am I 
>>>>> missing here? 
>>>>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>>>> What kind of example do you need? I only know about the examples in 
>>>>> the documentation. 
>>>>>
>>>>> I think this here is a nice one : 
>>>>>
>>>>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages 
>>>>>
>>>>> Or : the new style writer 
>>>>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer 
>>>>>
>>>>> So, something like this here could be start: 
>>>>>
>>>>> ``` 
>>>>> function Writer(doc, opts) 
>>>>> local filter = { 
>>>>> Note = function(el) 
>>>>> return el:walk { 
>>>>> Cite = function(el) 
>>>>> -- processing logic 
>>>>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}') 
>>>>> end 
>>>>> } 
>>>>> end 
>>>>> } 
>>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>>> end 
>>>>> ``` 
>>>>>
>>>>> I don’t think you can get the current writer in Lua. 
>>>>>
>>>>>
>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>>> Auftrag von Lyndon Drake 
>>>>> Gesendet: Dienstag, 26. Juli 2022 11:00 
>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>
>>>>> Thanks for this. I can see how that could work. 
>>>>>
>>>>> Can you point me to another example that uses the walk function? 
>>>>>
>>>>> Regarding a new-style Lua writer, is there a way to get the current 
>>>>> LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew 
>>>>> Haskell but that was rather a long time ago.) 
>>>>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>>>> I can't come up with a code example now, bit you can use the walk 
>>>>> function (https://pandoc.org/lua-filters.html#type-block:walk) to 
>>>>> modify the citations with a given mode inside notes. You'll need to build 
>>>>> the citation via Pandoc.RawInline 
>>>>> Maybe that would be a good example of a new style Lua writer. 
>>>>> ________________________________________ 
>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>>> Gesendet: Montag, 25. Juli 2022 21:46:28 
>>>>> An: pandoc-discuss 
>>>>> Betreff: Changing LaTeX output for citations inside footnotes 
>>>>>
>>>>> Hi, 
>>>>>
>>>>> So this is a slightly odd request, which really comes because of the 
>>>>> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
>>>>> that style, \textcite inside a footnote produces an unwanted result. \cite 
>>>>> produces the expected output. I have generally just gone through and 
>>>>> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
>>>>> stage, but that's painful, and I also thought that maybe this is possible 
>>>>> to do in a Lua filter. 
>>>>>
>>>>> But I don't quite know where to start - obviously this is a bit 
>>>>> different from the internal Pandoc citations. I'm going to begin the filter 
>>>>> with this: 
>>>>>
>>>>> if FORMAT:match 'latex' then <
>>>>> https://pandoc.org/lua-filters.html#cb9-3> function 
>>>>>
>>>>> but what would the function be? If it is Footnote, then I don't really 
>>>>> want the AST, I want the LaTeX that forms the footnote contents, and I 
>>>>> suppose then I can just replace any occurrences of the string \textcite 
>>>>> with the string \cite? 
>>>>>
>>>>> Any help would be awesome! 
>>>>>
>>>>> Best, 
>>>>> Lyndon 
>>>>>
>>>>> -- 
>>>>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>>>>> <
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>>>>> <
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>>>>> <
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>>>>> <
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com 
>>> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 40631 bytes --]

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                     ` <5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-08-01 13:48                                                                       ` BPJ
       [not found]                                                                         ` <CADAJKhCZYd1B8244+ZUN_DpRqEFG43zx_DQU3+OzCKHhFdYdnQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: BPJ @ 2022-08-01 13:48 UTC (permalink / raw)
  To: pandoc-discuss

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

Can you convert the blocks to inlines with blocks_to_inlines?

https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines

Den lör 30 juli 2022 15:54Lyndon Drake <isenguard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> Nice, the :gsub does the trick (once I replaced \n* with \n+).
>
> Thanks again, really appreciate the help with all this. Hopefully I can
> start to build some more Lua filters/writers now. It's a great system
> (thanks John MacFarlane!).
>
> On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>> I believe you can't create a pandoc document without any block. Two
>> possibilities come to mind:
>>
>> 1. Round tripping: After fixing the citation, read it as LaTeX, and
>> maybe, run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't
>> be messy). May not work, even.
>>
>> 2. Simply delete all paragraph markers: in your case with:
>> citetext:gsub("\n*", " ")
>>
>> Hth,
>>
>> Sukil
>>
>>
>>
>> El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>>
>> Hi Sukil,
>>
>> Thanks, you were quite correct about the second problem. I've amended
>> that and it now works, at least in the sense that it is altering the output
>> in the general way I want.
>>
>> On the first problem, I can just pandoc.stringify the prefix and suffix,
>> and concatenate. The problem with that is I will then lose any Markdown
>> formatting, which is not entirely uncommon in a prefix, and even
>> occasionally in a suffix. I can work around it for this document, I guess,
>> by just being careful not to use any Markdown formatting in these
>> instances, but I'd love to find a way to take a set of Inlines and convert
>> it to a format without adding a block.
>>
>> On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>
>>> Hi,
>>>
>>> For your first problem, when you do pandoc.write, as a minimum a block
>>> is created, which, I believe, is normally a paragraph. So, don't call
>>> pandoc.write. I guess you can concatenate the prefix, citation and suffix
>>> and pass them to the pandoc.RawInline function.
>>>
>>>
>>> For your second problem, I am guessing you are using --citeproc in your
>>> defaults file. If that is the case, try: 1) putting the defaults file after
>>> the filter; or 2) specifying --citeproc manually, also after the filter.
>>>
>>> Hth,
>>>
>>> Sukil
>>>
>>>
>>> El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>>
>>> Thanks for all the help - definitely getting somewhere now!
>>>
>>> I guess what I want to avoid is replicating in my not-great-Lua code all
>>> the work Pandoc already has to take a string of Markdown and convert it to
>>> LaTeX. I'm using pandoc.write to attempt that, and it seems to be working
>>> to some degree. The code as it is now is below. I have two problems:
>>>
>>> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my
>>> calling of pandoc.write into:
>>>
>>> ```
>>> \cite[165
>>>
>>> n.~9,
>>>
>>> 172]{Haran1982}
>>> ```
>>>
>>> and I can't figure out why the blank lines are turning up. I imagine I
>>> need to do something more clever with the Inlines?
>>>
>>>
>>> 2. Despite the fact that my output in the terminal shows that I am
>>> constructing the citetext variable as I am intending to, and I have this
>>> line of code:
>>>
>>>                     return pandoc.RawInline('latex', citetext)
>>>
>>> The output .tex file still has the normal Pandoc citations. In other
>>> words, my writer is constructing a nice LaTeX string with what I want in
>>> it, and then discards it in favour of the normal Pandoc code, which is a
>>> little bit depressing.
>>>
>>> Can anyone spot what I'm missing now?
>>>
>>> Best,
>>> Lyndon
>>>
>>> ```
>>> function Writer(doc, opts)
>>>     local filter = {
>>>         Note = function(el)
>>>             return el:walk {
>>>                 Cite = function(el)
>>>                     -- processing logic
>>>                     local citetext = ""
>>>                     if #el.citations > 1 then
>>>                         if el.citations[1].mode == "AuthorInText" then
>>>                             citetext = '\\textcites*'
>>>                         elseif el.citations[1].mode == "SuppressAuthor"
>>> then
>>>                             citetext = '\\cites*'
>>>                         elseif el.citations[1].mode == "NormalCitation"
>>> then
>>>                             citetext = '\\cites'
>>>                         end
>>>                     else
>>>                         if el.citations[1].mode == "AuthorInText" then
>>>                             citetext = '\\textcite*'
>>>                         elseif el.citations[1].mode == "SuppressAuthor"
>>> then
>>>                             citetext = '\\cite*'
>>>                         elseif el.citations[1].mode == "NormalCitation"
>>> then
>>>                             citetext = '\\cite'
>>>                         end
>>>                     end
>>>                     for _, c in pairs(el.citations) do
>>>                         if #c.prefix > 0 then
>>>                             local doc = pandoc.Pandoc(c.prefix)
>>>                             local citeprefix = pandoc.write(doc, 'latex')
>>>                             citetext = citetext .. '[' .. citeprefix ..
>>> ']'
>>>                         end
>>>                         if #c.suffix > 0 then
>>>                             local doc = pandoc.Pandoc(c.suffix)
>>>                             local citesuffix = pandoc.write(doc, 'latex')
>>>                             citetext = citetext .. '[' .. citesuffix ..
>>> ']'
>>>                         end
>>>                         citetext = citetext .. '{' .. c.id .. '}'
>>>                         print(citetext)
>>>                     end
>>>                     return pandoc.RawInline('latex', citetext)
>>>                 end
>>>             }
>>>         end
>>>     }
>>>     return pandoc.write(doc:walk(filter), 'latex', opts)
>>> end
>>> ```
>>>
>>> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>
>>>> I don't know, but the building blocks you'll need are
>>>> `pandoc.stringify` which takes any object and converts it into a string,
>>>> and `pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a
>>>> raw block or inline, and take the format as first argument and the string
>>>> as second.
>>>>
>>>> Hth,
>>>>
>>>> Sukil
>>>>
>>>>
>>>> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>>>
>>>> So I have the citation prefix, which I guess I have to convert to a
>>>> valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>>>>
>>>> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>>>
>>>>> Ah yep, that works. Next thing is I have to debug my obviously
>>>>> incorrect code :-)
>>>>>
>>>>> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>
>>>>>> That's the problem. This is a writer, not a filter. So you need to
>>>>>> call it via
>>>>>> -t latex-footcite.lua
>>>>>> ________________________________________
>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>>> Gesendet: Freitag, 29. Juli 2022 07:15:08
>>>>>> An: pandoc-discuss
>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes
>>>>>>
>>>>>> My command line is:
>>>>>>
>>>>>> pandoc -dbookends-latex --template
>>>>>> /Users/lyndon/.local/share/pandoc/templates/book.latex
>>>>>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
>>>>>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md
>>>>>>
>>>>>> It's definitely picking up the lua file because if I have a syntax
>>>>>> error, pandoc tells me. But I don't get any output.
>>>>>>
>>>>>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>> How do you run this ?
>>>>>> I’ve tested with a minimal markdown file :
>>>>>>
>>>>>> ```markdown
>>>>>> asdf
>>>>>> ```
>>>>>>
>>>>>> Run with :
>>>>>> pandoc asdf.md -t mylatex.lua
>>>>>>
>>>>>> Result :
>>>>>> got here
>>>>>> asdf
>>>>>>
>>>>>> So, it prints the first print statement of the writer.
>>>>>>
>>>>>> Denis
>>>>>>
>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>>> Auftrag von Lyndon Drake
>>>>>> Gesendet: Donnerstag, 28. Juli 2022 19:17
>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes
>>>>>>
>>>>>> Thanks for this - exactly what I needed. I've added my attempt at the
>>>>>> code below, but I must be missing some basic part of it because it doesn't
>>>>>> do anything. I added a couple of print statements that never get executed:
>>>>>>
>>>>>> ```
>>>>>> function Writer(doc, opts)
>>>>>> print "got here"
>>>>>> local filter = {
>>>>>> Note = function(el)
>>>>>> return el:walk {
>>>>>> Cite = function(el)
>>>>>> -- processing logic
>>>>>> print "got further"
>>>>>> local citation = ""
>>>>>> if #el.citations > 1 then
>>>>>> if citations[1].mode == "AuthorInText" then
>>>>>> citation = '\\textcites*'
>>>>>> elseif citations[1].mode == "SuppressAuthor" then
>>>>>> citation = '\\cites*'
>>>>>> elseif citations[1].mode == "NormalCitation" then
>>>>>> citation = '\\cites'
>>>>>> end
>>>>>> else
>>>>>> if citations[1].mode == "AuthorInText" then
>>>>>> citation = '\\textcite*'
>>>>>> elseif citations[1].mode == "SuppressAuthor" then
>>>>>> citation = '\\cite*'
>>>>>> elseif citations[1].mode == "NormalCitation" then
>>>>>> citation = '\\cite'
>>>>>> end
>>>>>> end
>>>>>> for c in el.citations do
>>>>>> if c.prefix ~= "" then
>>>>>> citation = citation .. '[' .. c.prefix .. ']'
>>>>>> end
>>>>>> if c.suffix ~= "" then
>>>>>> citation = citation .. '[' .. c.suffix .. ']'
>>>>>> end
>>>>>> citation = citation .. '{' .. c.id<http://c.id> .. '}'
>>>>>> end
>>>>>> return pandoc.RawInline('latex', citation)
>>>>>> end
>>>>>> }
>>>>>> end
>>>>>> }
>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts)
>>>>>> end
>>>>>> ```
>>>>>>
>>>>>> Apologies for what must be a very basic question, but what am I
>>>>>> missing here?
>>>>>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>>> wrote:
>>>>>> What kind of example do you need? I only know about the examples in
>>>>>> the documentation.
>>>>>>
>>>>>> I think this here is a nice one :
>>>>>>
>>>>>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>>>>>>
>>>>>> Or : the new style writer
>>>>>>
>>>>>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>>>>>>
>>>>>> So, something like this here could be start:
>>>>>>
>>>>>> ```
>>>>>> function Writer(doc, opts)
>>>>>> local filter = {
>>>>>> Note = function(el)
>>>>>> return el:walk {
>>>>>> Cite = function(el)
>>>>>> -- processing logic
>>>>>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}')
>>>>>> end
>>>>>> }
>>>>>> end
>>>>>> }
>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts)
>>>>>> end
>>>>>> ```
>>>>>>
>>>>>> I don’t think you can get the current writer in Lua.
>>>>>>
>>>>>>
>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>>> Auftrag von Lyndon Drake
>>>>>> Gesendet: Dienstag, 26. Juli 2022 11:00
>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes
>>>>>>
>>>>>> Thanks for this. I can see how that could work.
>>>>>>
>>>>>> Can you point me to another example that uses the walk function?
>>>>>>
>>>>>> Regarding a new-style Lua writer, is there a way to get the current
>>>>>> LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew
>>>>>> Haskell but that was rather a long time ago.)
>>>>>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>> I can't come up with a code example now, bit you can use the walk
>>>>>> function (https://pandoc.org/lua-filters.html#type-block:walk) to
>>>>>> modify the citations with a given mode inside notes. You'll need to build
>>>>>> the citation via Pandoc.RawInline
>>>>>> Maybe that would be a good example of a new style Lua writer.
>>>>>> ________________________________________
>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>>> Gesendet: Montag, 25. Juli 2022 21:46:28
>>>>>> An: pandoc-discuss
>>>>>> Betreff: Changing LaTeX output for citations inside footnotes
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> So this is a slightly odd request, which really comes because of the
>>>>>> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In
>>>>>> that style, \textcite inside a footnote produces an unwanted result. \cite
>>>>>> produces the expected output. I have generally just gone through and
>>>>>> hand-edited my Pandoc-produced LaTeX files when they get to the final copy
>>>>>> stage, but that's painful, and I also thought that maybe this is possible
>>>>>> to do in a Lua filter.
>>>>>>
>>>>>> But I don't quite know where to start - obviously this is a bit
>>>>>> different from the internal Pandoc citations. I'm going to begin the filter
>>>>>> with this:
>>>>>>
>>>>>> if FORMAT:match 'latex' then <
>>>>>> https://pandoc.org/lua-filters.html#cb9-3> function
>>>>>>
>>>>>> but what would the function be? If it is Footnote, then I don't
>>>>>> really want the AST, I want the LaTeX that forms the footnote contents, and
>>>>>> I suppose then I can just replace any occurrences of the string \textcite
>>>>>> with the string \cite?
>>>>>>
>>>>>> Any help would be awesome!
>>>>>>
>>>>>> Best,
>>>>>> Lyndon
>>>>>>
>>>>>> --
>>>>>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>>>>>> <
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>>>>>> <
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>>>>>> <
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>>>>>> <
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com
>> <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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/CADAJKhCZYd1B8244%2BZUN_DpRqEFG43zx_DQU3%2BOzCKHhFdYdnQ%40mail.gmail.com.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                         ` <CADAJKhCZYd1B8244+ZUN_DpRqEFG43zx_DQU3+OzCKHhFdYdnQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-08-05 11:08                                                                           ` Lyndon Drake
       [not found]                                                                             ` <28ac6c29-817d-41b6-891e-915ea28bdf3bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-08-05 11:08 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 20849 bytes --]

Not really, because the issue is that Pandoc returns a doc, not a list of 
blocks. So blocks_to_inlines doesn't actually work. But the gsub trick 
works well enough to get around the issue, thankfully.

On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:

> Can you convert the blocks to inlines with blocks_to_inlines?
>
> https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines
>
> Den lör 30 juli 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>
>> Nice, the :gsub does the trick (once I replaced \n* with \n+).
>>
>> Thanks again, really appreciate the help with all this. Hopefully I can 
>> start to build some more Lua filters/writers now. It's a great system 
>> (thanks John MacFarlane!).
>>
>> On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>
>>> I believe you can't create a pandoc document without any block. Two 
>>> possibilities come to mind:
>>>
>>> 1. Round tripping: After fixing the citation, read it as LaTeX, and 
>>> maybe, run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't 
>>> be messy). May not work, even.
>>>
>>> 2. Simply delete all paragraph markers: in your case with: 
>>> citetext:gsub("\n*", " ")
>>>
>>> Hth,
>>>
>>> Sukil
>>>
>>>
>>>
>>> El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>>>
>>> Hi Sukil, 
>>>
>>> Thanks, you were quite correct about the second problem. I've amended 
>>> that and it now works, at least in the sense that it is altering the output 
>>> in the general way I want.
>>>
>>> On the first problem, I can just pandoc.stringify the prefix and suffix, 
>>> and concatenate. The problem with that is I will then lose any Markdown 
>>> formatting, which is not entirely uncommon in a prefix, and even 
>>> occasionally in a suffix. I can work around it for this document, I guess, 
>>> by just being careful not to use any Markdown formatting in these 
>>> instances, but I'd love to find a way to take a set of Inlines and convert 
>>> it to a format without adding a block.
>>>
>>> On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>
>>>> Hi,
>>>>
>>>> For your first problem, when you do pandoc.write, as a minimum a block 
>>>> is created, which, I believe, is normally a paragraph. So, don't call 
>>>> pandoc.write. I guess you can concatenate the prefix, citation and suffix 
>>>> and pass them to the pandoc.RawInline function. 
>>>>
>>>>
>>>> For your second problem, I am guessing you are using --citeproc in your 
>>>> defaults file. If that is the case, try: 1) putting the defaults file after 
>>>> the filter; or 2) specifying --citeproc manually, also after the filter.
>>>>
>>>> Hth,
>>>>
>>>> Sukil
>>>>
>>>>
>>>> El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>>>
>>>> Thanks for all the help - definitely getting somewhere now!
>>>>
>>>> I guess what I want to avoid is replicating in my not-great-Lua code 
>>>> all the work Pandoc already has to take a string of Markdown and convert it 
>>>> to LaTeX. I'm using pandoc.write to attempt that, and it seems to be 
>>>> working to some degree. The code as it is now is below. I have two 
>>>> problems: 
>>>>
>>>> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my 
>>>> calling of pandoc.write into:
>>>>
>>>> ```
>>>> \cite[165
>>>>
>>>> n.~9,
>>>>
>>>> 172]{Haran1982}
>>>> ```
>>>>
>>>> and I can't figure out why the blank lines are turning up. I imagine I 
>>>> need to do something more clever with the Inlines?
>>>>
>>>>
>>>> 2. Despite the fact that my output in the terminal shows that I am 
>>>> constructing the citetext variable as I am intending to, and I have this 
>>>> line of code:
>>>>
>>>>                     return pandoc.RawInline('latex', citetext)
>>>>
>>>> The output .tex file still has the normal Pandoc citations. In other 
>>>> words, my writer is constructing a nice LaTeX string with what I want in 
>>>> it, and then discards it in favour of the normal Pandoc code, which is a 
>>>> little bit depressing.
>>>>
>>>> Can anyone spot what I'm missing now?
>>>>
>>>> Best,
>>>> Lyndon
>>>>
>>>> ```
>>>> function Writer(doc, opts)
>>>>     local filter = {
>>>>         Note = function(el)
>>>>             return el:walk {
>>>>                 Cite = function(el)
>>>>                     -- processing logic
>>>>                     local citetext = ""
>>>>                     if #el.citations > 1 then
>>>>                         if el.citations[1].mode == "AuthorInText" then
>>>>                             citetext = '\\textcites*'
>>>>                         elseif el.citations[1].mode == "SuppressAuthor" 
>>>> then
>>>>                             citetext = '\\cites*'
>>>>                         elseif el.citations[1].mode == "NormalCitation" 
>>>> then
>>>>                             citetext = '\\cites'
>>>>                         end
>>>>                     else
>>>>                         if el.citations[1].mode == "AuthorInText" then
>>>>                             citetext = '\\textcite*'
>>>>                         elseif el.citations[1].mode == "SuppressAuthor" 
>>>> then
>>>>                             citetext = '\\cite*'
>>>>                         elseif el.citations[1].mode == "NormalCitation" 
>>>> then
>>>>                             citetext = '\\cite'
>>>>                         end
>>>>                     end
>>>>                     for _, c in pairs(el.citations) do
>>>>                         if #c.prefix > 0 then
>>>>                             local doc = pandoc.Pandoc(c.prefix)
>>>>                             local citeprefix = pandoc.write(doc, 
>>>> 'latex')
>>>>                             citetext = citetext .. '[' .. citeprefix .. 
>>>> ']'
>>>>                         end
>>>>                         if #c.suffix > 0 then
>>>>                             local doc = pandoc.Pandoc(c.suffix)
>>>>                             local citesuffix = pandoc.write(doc, 
>>>> 'latex')
>>>>                             citetext = citetext .. '[' .. citesuffix .. 
>>>> ']'
>>>>                         end
>>>>                         citetext = citetext .. '{' .. c.id .. '}'
>>>>                         print(citetext)
>>>>                     end
>>>>                     return pandoc.RawInline('latex', citetext)
>>>>                 end
>>>>             }
>>>>         end
>>>>     }
>>>>     return pandoc.write(doc:walk(filter), 'latex', opts)
>>>> end
>>>> ```
>>>>
>>>> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>>
>>>>> I don't know, but the building blocks you'll need are 
>>>>> `pandoc.stringify` which takes any object and converts it into a string, 
>>>>> and `pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a 
>>>>> raw block or inline, and take the format as first argument and the string 
>>>>> as second.
>>>>>
>>>>> Hth,
>>>>>
>>>>> Sukil
>>>>>
>>>>>
>>>>> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>>>>
>>>>> So I have the citation prefix, which I guess I have to convert to a 
>>>>> valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>>>>>
>>>>> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>>>>
>>>>>> Ah yep, that works. Next thing is I have to debug my obviously 
>>>>>> incorrect code :-)
>>>>>>
>>>>>> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>>
>>>>>>> That's the problem. This is a writer, not a filter. So you need to 
>>>>>>> call it via 
>>>>>>> -t latex-footcite.lua 
>>>>>>> ________________________________________ 
>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>>>>> Gesendet: Freitag, 29. Juli 2022 07:15:08 
>>>>>>> An: pandoc-discuss 
>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>>>
>>>>>>> My command line is: 
>>>>>>>
>>>>>>> pandoc -dbookends-latex --template 
>>>>>>> /Users/lyndon/.local/share/pandoc/templates/book.latex 
>>>>>>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
>>>>>>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md 
>>>>>>>
>>>>>>> It's definitely picking up the lua file because if I have a syntax 
>>>>>>> error, pandoc tells me. But I don't get any output. 
>>>>>>>
>>>>>>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org 
>>>>>>> wrote: 
>>>>>>> How do you run this ? 
>>>>>>> I’ve tested with a minimal markdown file : 
>>>>>>>
>>>>>>> ```markdown 
>>>>>>> asdf 
>>>>>>> ``` 
>>>>>>>
>>>>>>> Run with : 
>>>>>>> pandoc asdf.md -t mylatex.lua 
>>>>>>>
>>>>>>> Result : 
>>>>>>> got here 
>>>>>>> asdf 
>>>>>>>
>>>>>>> So, it prints the first print statement of the writer. 
>>>>>>>
>>>>>>> Denis 
>>>>>>>
>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>>>>> Auftrag von Lyndon Drake 
>>>>>>> Gesendet: Donnerstag, 28. Juli 2022 19:17 
>>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>>>
>>>>>>> Thanks for this - exactly what I needed. I've added my attempt at 
>>>>>>> the code below, but I must be missing some basic part of it because it 
>>>>>>> doesn't do anything. I added a couple of print statements that never get 
>>>>>>> executed: 
>>>>>>>
>>>>>>> ``` 
>>>>>>> function Writer(doc, opts) 
>>>>>>> print "got here" 
>>>>>>> local filter = { 
>>>>>>> Note = function(el) 
>>>>>>> return el:walk { 
>>>>>>> Cite = function(el) 
>>>>>>> -- processing logic 
>>>>>>> print "got further" 
>>>>>>> local citation = "" 
>>>>>>> if #el.citations > 1 then 
>>>>>>> if citations[1].mode == "AuthorInText" then 
>>>>>>> citation = '\\textcites*' 
>>>>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>>>>> citation = '\\cites*' 
>>>>>>> elseif citations[1].mode == "NormalCitation" then 
>>>>>>> citation = '\\cites' 
>>>>>>> end 
>>>>>>> else 
>>>>>>> if citations[1].mode == "AuthorInText" then 
>>>>>>> citation = '\\textcite*' 
>>>>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>>>>> citation = '\\cite*' 
>>>>>>> elseif citations[1].mode == "NormalCitation" then 
>>>>>>> citation = '\\cite' 
>>>>>>> end 
>>>>>>> end 
>>>>>>> for c in el.citations do 
>>>>>>> if c.prefix ~= "" then 
>>>>>>> citation = citation .. '[' .. c.prefix .. ']' 
>>>>>>> end 
>>>>>>> if c.suffix ~= "" then 
>>>>>>> citation = citation .. '[' .. c.suffix .. ']' 
>>>>>>> end 
>>>>>>> citation = citation .. '{' .. c.id<http://c.id> .. '}' 
>>>>>>> end 
>>>>>>> return pandoc.RawInline('latex', citation) 
>>>>>>> end 
>>>>>>> } 
>>>>>>> end 
>>>>>>> } 
>>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>>>>> end 
>>>>>>> ``` 
>>>>>>>
>>>>>>> Apologies for what must be a very basic question, but what am I 
>>>>>>> missing here? 
>>>>>>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org 
>>>>>>> wrote: 
>>>>>>> What kind of example do you need? I only know about the examples in 
>>>>>>> the documentation. 
>>>>>>>
>>>>>>> I think this here is a nice one : 
>>>>>>>
>>>>>>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages 
>>>>>>>
>>>>>>> Or : the new style writer 
>>>>>>>
>>>>>>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer 
>>>>>>>
>>>>>>> So, something like this here could be start: 
>>>>>>>
>>>>>>> ``` 
>>>>>>> function Writer(doc, opts) 
>>>>>>> local filter = { 
>>>>>>> Note = function(el) 
>>>>>>> return el:walk { 
>>>>>>> Cite = function(el) 
>>>>>>> -- processing logic 
>>>>>>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}') 
>>>>>>> end 
>>>>>>> } 
>>>>>>> end 
>>>>>>> } 
>>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>>>>> end 
>>>>>>> ``` 
>>>>>>>
>>>>>>> I don’t think you can get the current writer in Lua. 
>>>>>>>
>>>>>>>
>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>>>>> Auftrag von Lyndon Drake 
>>>>>>> Gesendet: Dienstag, 26. Juli 2022 11:00 
>>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>>>
>>>>>>> Thanks for this. I can see how that could work. 
>>>>>>>
>>>>>>> Can you point me to another example that uses the walk function? 
>>>>>>>
>>>>>>> Regarding a new-style Lua writer, is there a way to get the current 
>>>>>>> LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew 
>>>>>>> Haskell but that was rather a long time ago.) 
>>>>>>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
>>>>>>> I can't come up with a code example now, bit you can use the walk 
>>>>>>> function (https://pandoc.org/lua-filters.html#type-block:walk) to 
>>>>>>> modify the citations with a given mode inside notes. You'll need to build 
>>>>>>> the citation via Pandoc.RawInline 
>>>>>>> Maybe that would be a good example of a new style Lua writer. 
>>>>>>> ________________________________________ 
>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>>>>> Gesendet: Montag, 25. Juli 2022 21:46:28 
>>>>>>> An: pandoc-discuss 
>>>>>>> Betreff: Changing LaTeX output for citations inside footnotes 
>>>>>>>
>>>>>>> Hi, 
>>>>>>>
>>>>>>> So this is a slightly odd request, which really comes because of the 
>>>>>>> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
>>>>>>> that style, \textcite inside a footnote produces an unwanted result. \cite 
>>>>>>> produces the expected output. I have generally just gone through and 
>>>>>>> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
>>>>>>> stage, but that's painful, and I also thought that maybe this is possible 
>>>>>>> to do in a Lua filter. 
>>>>>>>
>>>>>>> But I don't quite know where to start - obviously this is a bit 
>>>>>>> different from the internal Pandoc citations. I'm going to begin the filter 
>>>>>>> with this: 
>>>>>>>
>>>>>>> if FORMAT:match 'latex' then <
>>>>>>> https://pandoc.org/lua-filters.html#cb9-3> function 
>>>>>>>
>>>>>>> but what would the function be? If it is Footnote, then I don't 
>>>>>>> really want the AST, I want the LaTeX that forms the footnote contents, and 
>>>>>>> I suppose then I can just replace any occurrences of the string \textcite 
>>>>>>> with the string \cite? 
>>>>>>>
>>>>>>> Any help would be awesome! 
>>>>>>>
>>>>>>> Best, 
>>>>>>> Lyndon 
>>>>>>>
>>>>>>> -- 
>>>>>>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>>>>>>> <
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>>>>>>> <
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>>>>>>> <
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>>>>>>> <
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com 
>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com 
>>>> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com 
>>> <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 43641 bytes --]

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                             ` <28ac6c29-817d-41b6-891e-915ea28bdf3bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-08-05 14:36                                                                               ` BPJ
       [not found]                                                                                 ` <CADAJKhBDo-Ya3Wabo27CQd=t6JGtkzmYOoqbcCW2tkK=GKd7FA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: BPJ @ 2022-08-05 14:36 UTC (permalink / raw)
  To: pandoc-discuss

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

But doc.blocks, which is the actual content of the doc, is a list of
blocks, which you can pass to blocks_to_inlines. Don't forget to pass
`{pandoc.Space()}` as the second argument!

Den fre 5 aug. 2022 13:08Lyndon Drake <isenguard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> Not really, because the issue is that Pandoc returns a doc, not a list of
> blocks. So blocks_to_inlines doesn't actually work. But the gsub trick
> works well enough to get around the issue, thankfully.
>
> On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:
>
>> Can you convert the blocks to inlines with blocks_to_inlines?
>>
>> https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines
>>
>> Den lör 30 juli 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>> Nice, the :gsub does the trick (once I replaced \n* with \n+).
>>>
>>> Thanks again, really appreciate the help with all this. Hopefully I can
>>> start to build some more Lua filters/writers now. It's a great system
>>> (thanks John MacFarlane!).
>>>
>>> On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>
>>>> I believe you can't create a pandoc document without any block. Two
>>>> possibilities come to mind:
>>>>
>>>> 1. Round tripping: After fixing the citation, read it as LaTeX, and
>>>> maybe, run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't
>>>> be messy). May not work, even.
>>>>
>>>> 2. Simply delete all paragraph markers: in your case with:
>>>> citetext:gsub("\n*", " ")
>>>>
>>>> Hth,
>>>>
>>>> Sukil
>>>>
>>>>
>>>>
>>>> El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>>>>
>>>> Hi Sukil,
>>>>
>>>> Thanks, you were quite correct about the second problem. I've amended
>>>> that and it now works, at least in the sense that it is altering the output
>>>> in the general way I want.
>>>>
>>>> On the first problem, I can just pandoc.stringify the prefix and
>>>> suffix, and concatenate. The problem with that is I will then lose any
>>>> Markdown formatting, which is not entirely uncommon in a prefix, and even
>>>> occasionally in a suffix. I can work around it for this document, I guess,
>>>> by just being careful not to use any Markdown formatting in these
>>>> instances, but I'd love to find a way to take a set of Inlines and convert
>>>> it to a format without adding a block.
>>>>
>>>> On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> For your first problem, when you do pandoc.write, as a minimum a block
>>>>> is created, which, I believe, is normally a paragraph. So, don't call
>>>>> pandoc.write. I guess you can concatenate the prefix, citation and suffix
>>>>> and pass them to the pandoc.RawInline function.
>>>>>
>>>>>
>>>>> For your second problem, I am guessing you are using --citeproc in
>>>>> your defaults file. If that is the case, try: 1) putting the defaults file
>>>>> after the filter; or 2) specifying --citeproc manually, also after the
>>>>> filter.
>>>>>
>>>>> Hth,
>>>>>
>>>>> Sukil
>>>>>
>>>>>
>>>>> El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>>>>
>>>>> Thanks for all the help - definitely getting somewhere now!
>>>>>
>>>>> I guess what I want to avoid is replicating in my not-great-Lua code
>>>>> all the work Pandoc already has to take a string of Markdown and convert it
>>>>> to LaTeX. I'm using pandoc.write to attempt that, and it seems to be
>>>>> working to some degree. The code as it is now is below. I have two
>>>>> problems:
>>>>>
>>>>> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my
>>>>> calling of pandoc.write into:
>>>>>
>>>>> ```
>>>>> \cite[165
>>>>>
>>>>> n.~9,
>>>>>
>>>>> 172]{Haran1982}
>>>>> ```
>>>>>
>>>>> and I can't figure out why the blank lines are turning up. I imagine I
>>>>> need to do something more clever with the Inlines?
>>>>>
>>>>>
>>>>> 2. Despite the fact that my output in the terminal shows that I am
>>>>> constructing the citetext variable as I am intending to, and I have this
>>>>> line of code:
>>>>>
>>>>>                     return pandoc.RawInline('latex', citetext)
>>>>>
>>>>> The output .tex file still has the normal Pandoc citations. In other
>>>>> words, my writer is constructing a nice LaTeX string with what I want in
>>>>> it, and then discards it in favour of the normal Pandoc code, which is a
>>>>> little bit depressing.
>>>>>
>>>>> Can anyone spot what I'm missing now?
>>>>>
>>>>> Best,
>>>>> Lyndon
>>>>>
>>>>> ```
>>>>> function Writer(doc, opts)
>>>>>     local filter = {
>>>>>         Note = function(el)
>>>>>             return el:walk {
>>>>>                 Cite = function(el)
>>>>>                     -- processing logic
>>>>>                     local citetext = ""
>>>>>                     if #el.citations > 1 then
>>>>>                         if el.citations[1].mode == "AuthorInText" then
>>>>>                             citetext = '\\textcites*'
>>>>>                         elseif el.citations[1].mode ==
>>>>> "SuppressAuthor" then
>>>>>                             citetext = '\\cites*'
>>>>>                         elseif el.citations[1].mode ==
>>>>> "NormalCitation" then
>>>>>                             citetext = '\\cites'
>>>>>                         end
>>>>>                     else
>>>>>                         if el.citations[1].mode == "AuthorInText" then
>>>>>                             citetext = '\\textcite*'
>>>>>                         elseif el.citations[1].mode ==
>>>>> "SuppressAuthor" then
>>>>>                             citetext = '\\cite*'
>>>>>                         elseif el.citations[1].mode ==
>>>>> "NormalCitation" then
>>>>>                             citetext = '\\cite'
>>>>>                         end
>>>>>                     end
>>>>>                     for _, c in pairs(el.citations) do
>>>>>                         if #c.prefix > 0 then
>>>>>                             local doc = pandoc.Pandoc(c.prefix)
>>>>>                             local citeprefix = pandoc.write(doc,
>>>>> 'latex')
>>>>>                             citetext = citetext .. '[' .. citeprefix
>>>>> .. ']'
>>>>>                         end
>>>>>                         if #c.suffix > 0 then
>>>>>                             local doc = pandoc.Pandoc(c.suffix)
>>>>>                             local citesuffix = pandoc.write(doc,
>>>>> 'latex')
>>>>>                             citetext = citetext .. '[' .. citesuffix
>>>>> .. ']'
>>>>>                         end
>>>>>                         citetext = citetext .. '{' .. c.id .. '}'
>>>>>                         print(citetext)
>>>>>                     end
>>>>>                     return pandoc.RawInline('latex', citetext)
>>>>>                 end
>>>>>             }
>>>>>         end
>>>>>     }
>>>>>     return pandoc.write(doc:walk(filter), 'latex', opts)
>>>>> end
>>>>> ```
>>>>>
>>>>> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>>>
>>>>>> I don't know, but the building blocks you'll need are
>>>>>> `pandoc.stringify` which takes any object and converts it into a string,
>>>>>> and `pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a
>>>>>> raw block or inline, and take the format as first argument and the string
>>>>>> as second.
>>>>>>
>>>>>> Hth,
>>>>>>
>>>>>> Sukil
>>>>>>
>>>>>>
>>>>>> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>>>>>
>>>>>> So I have the citation prefix, which I guess I have to convert to a
>>>>>> valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>>>>>>
>>>>>> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>>>>>
>>>>>>> Ah yep, that works. Next thing is I have to debug my obviously
>>>>>>> incorrect code :-)
>>>>>>>
>>>>>>> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>>>
>>>>>>>> That's the problem. This is a writer, not a filter. So you need to
>>>>>>>> call it via
>>>>>>>> -t latex-footcite.lua
>>>>>>>> ________________________________________
>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>>>>> Gesendet: Freitag, 29. Juli 2022 07:15:08
>>>>>>>> An: pandoc-discuss
>>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes
>>>>>>>>
>>>>>>>> My command line is:
>>>>>>>>
>>>>>>>> pandoc -dbookends-latex --template
>>>>>>>> /Users/lyndon/.local/share/pandoc/templates/book.latex
>>>>>>>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
>>>>>>>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md
>>>>>>>>
>>>>>>>> It's definitely picking up the lua file because if I have a syntax
>>>>>>>> error, pandoc tells me. But I don't get any output.
>>>>>>>>
>>>>>>>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>>>>> wrote:
>>>>>>>> How do you run this ?
>>>>>>>> I’ve tested with a minimal markdown file :
>>>>>>>>
>>>>>>>> ```markdown
>>>>>>>> asdf
>>>>>>>> ```
>>>>>>>>
>>>>>>>> Run with :
>>>>>>>> pandoc asdf.md -t mylatex.lua
>>>>>>>>
>>>>>>>> Result :
>>>>>>>> got here
>>>>>>>> asdf
>>>>>>>>
>>>>>>>> So, it prints the first print statement of the writer.
>>>>>>>>
>>>>>>>> Denis
>>>>>>>>
>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>>>>> Auftrag von Lyndon Drake
>>>>>>>> Gesendet: Donnerstag, 28. Juli 2022 19:17
>>>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes
>>>>>>>>
>>>>>>>> Thanks for this - exactly what I needed. I've added my attempt at
>>>>>>>> the code below, but I must be missing some basic part of it because it
>>>>>>>> doesn't do anything. I added a couple of print statements that never get
>>>>>>>> executed:
>>>>>>>>
>>>>>>>> ```
>>>>>>>> function Writer(doc, opts)
>>>>>>>> print "got here"
>>>>>>>> local filter = {
>>>>>>>> Note = function(el)
>>>>>>>> return el:walk {
>>>>>>>> Cite = function(el)
>>>>>>>> -- processing logic
>>>>>>>> print "got further"
>>>>>>>> local citation = ""
>>>>>>>> if #el.citations > 1 then
>>>>>>>> if citations[1].mode == "AuthorInText" then
>>>>>>>> citation = '\\textcites*'
>>>>>>>> elseif citations[1].mode == "SuppressAuthor" then
>>>>>>>> citation = '\\cites*'
>>>>>>>> elseif citations[1].mode == "NormalCitation" then
>>>>>>>> citation = '\\cites'
>>>>>>>> end
>>>>>>>> else
>>>>>>>> if citations[1].mode == "AuthorInText" then
>>>>>>>> citation = '\\textcite*'
>>>>>>>> elseif citations[1].mode == "SuppressAuthor" then
>>>>>>>> citation = '\\cite*'
>>>>>>>> elseif citations[1].mode == "NormalCitation" then
>>>>>>>> citation = '\\cite'
>>>>>>>> end
>>>>>>>> end
>>>>>>>> for c in el.citations do
>>>>>>>> if c.prefix ~= "" then
>>>>>>>> citation = citation .. '[' .. c.prefix .. ']'
>>>>>>>> end
>>>>>>>> if c.suffix ~= "" then
>>>>>>>> citation = citation .. '[' .. c.suffix .. ']'
>>>>>>>> end
>>>>>>>> citation = citation .. '{' .. c.id<http://c.id> .. '}'
>>>>>>>> end
>>>>>>>> return pandoc.RawInline('latex', citation)
>>>>>>>> end
>>>>>>>> }
>>>>>>>> end
>>>>>>>> }
>>>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts)
>>>>>>>> end
>>>>>>>> ```
>>>>>>>>
>>>>>>>> Apologies for what must be a very basic question, but what am I
>>>>>>>> missing here?
>>>>>>>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>>>>> wrote:
>>>>>>>> What kind of example do you need? I only know about the examples in
>>>>>>>> the documentation.
>>>>>>>>
>>>>>>>> I think this here is a nice one :
>>>>>>>>
>>>>>>>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>>>>>>>>
>>>>>>>> Or : the new style writer
>>>>>>>>
>>>>>>>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>>>>>>>>
>>>>>>>> So, something like this here could be start:
>>>>>>>>
>>>>>>>> ```
>>>>>>>> function Writer(doc, opts)
>>>>>>>> local filter = {
>>>>>>>> Note = function(el)
>>>>>>>> return el:walk {
>>>>>>>> Cite = function(el)
>>>>>>>> -- processing logic
>>>>>>>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}')
>>>>>>>> end
>>>>>>>> }
>>>>>>>> end
>>>>>>>> }
>>>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts)
>>>>>>>> end
>>>>>>>> ```
>>>>>>>>
>>>>>>>> I don’t think you can get the current writer in Lua.
>>>>>>>>
>>>>>>>>
>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>>>>> Auftrag von Lyndon Drake
>>>>>>>> Gesendet: Dienstag, 26. Juli 2022 11:00
>>>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes
>>>>>>>>
>>>>>>>> Thanks for this. I can see how that could work.
>>>>>>>>
>>>>>>>> Can you point me to another example that uses the walk function?
>>>>>>>>
>>>>>>>> Regarding a new-style Lua writer, is there a way to get the current
>>>>>>>> LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew
>>>>>>>> Haskell but that was rather a long time ago.)
>>>>>>>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>>>> I can't come up with a code example now, bit you can use the walk
>>>>>>>> function (https://pandoc.org/lua-filters.html#type-block:walk) to
>>>>>>>> modify the citations with a given mode inside notes. You'll need to build
>>>>>>>> the citation via Pandoc.RawInline
>>>>>>>> Maybe that would be a good example of a new style Lua writer.
>>>>>>>> ________________________________________
>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>>>>> Gesendet: Montag, 25. Juli 2022 21:46:28
>>>>>>>> An: pandoc-discuss
>>>>>>>> Betreff: Changing LaTeX output for citations inside footnotes
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> So this is a slightly odd request, which really comes because of
>>>>>>>> the unusual behaviour of the specific BibLaTeX bibliography style I'm
>>>>>>>> using. In that style, \textcite inside a footnote produces an unwanted
>>>>>>>> result. \cite produces the expected output. I have generally just gone
>>>>>>>> through and hand-edited my Pandoc-produced LaTeX files when they get to the
>>>>>>>> final copy stage, but that's painful, and I also thought that maybe this is
>>>>>>>> possible to do in a Lua filter.
>>>>>>>>
>>>>>>>> But I don't quite know where to start - obviously this is a bit
>>>>>>>> different from the internal Pandoc citations. I'm going to begin the filter
>>>>>>>> with this:
>>>>>>>>
>>>>>>>> if FORMAT:match 'latex' then <
>>>>>>>> https://pandoc.org/lua-filters.html#cb9-3> function
>>>>>>>>
>>>>>>>> but what would the function be? If it is Footnote, then I don't
>>>>>>>> really want the AST, I want the LaTeX that forms the footnote contents, and
>>>>>>>> I suppose then I can just replace any occurrences of the string \textcite
>>>>>>>> with the string \cite?
>>>>>>>>
>>>>>>>> Any help would be awesome!
>>>>>>>>
>>>>>>>> Best,
>>>>>>>> Lyndon
>>>>>>>>
>>>>>>>> --
>>>>>>>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>>>>>>>> <
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>>>>>>>> <
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>>>>>>>> <
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>>>>>>>> <
>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>>
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.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/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail.com.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                                 ` <CADAJKhBDo-Ya3Wabo27CQd=t6JGtkzmYOoqbcCW2tkK=GKd7FA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-08-05 20:43                                                                                   ` Sukil Etxenike arizaleta
       [not found]                                                                                     ` <1485f3b9-f893-c00d-6546-904732bf64ae-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Sukil Etxenike arizaleta @ 2022-08-05 20:43 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

I think `doc`'s fields and methods aren't documented, that's why I 
didn't think of that. Good call!


El 05/08/2022 a las 16:36, BPJ escribió:
> But doc.blocks, which is the actual content of the doc, is a list of 
> blocks, which you can pass to blocks_to_inlines. Don't forget to pass 
> `{pandoc.Space()}` as the second argument!
>
> Den fre 5 aug. 2022 13:08Lyndon Drake <isenguard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>
>     Not really, because the issue is that Pandoc returns a doc, not a
>     list of blocks. So blocks_to_inlines doesn't actually work. But
>     the gsub trick works well enough to get around the issue, thankfully.
>
>     On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:
>
>         Can you convert the blocks to inlines with blocks_to_inlines?
>
>         https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines
>
>         Den lör 30 juli 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>
>             Nice, the :gsub does the trick (once I replaced \n* with
>             \n+).
>
>             Thanks again, really appreciate the help with all this.
>             Hopefully I can start to build some more Lua
>             filters/writers now. It's a great system (thanks John
>             MacFarlane!).
>
>             On Saturday, 30 July 2022 at 14:06:10 UTC+1
>             suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>                 I believe you can't create a pandoc document without
>                 any block. Two possibilities come to mind:
>
>                 1. Round tripping: After fixing the citation, read it
>                 as LaTeX, and maybe, run
>                 pandoc.utils.blocks_to_inlines. (Hey, I never said it
>                 wouldn't be messy). May not work, even.
>
>                 2. Simply delete all paragraph markers: in your case
>                 with: citetext:gsub("\n*", " ")
>
>                 Hth,
>
>                 Sukil
>
>
>
>                 El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>
>>                 Hi Sukil,
>>
>>                 Thanks, you were quite correct about the second
>>                 problem. I've amended that and it now works, at least
>>                 in the sense that it is altering the output in the
>>                 general way I want.
>>
>>                 On the first problem, I can just pandoc.stringify the
>>                 prefix and suffix, and concatenate. The problem with
>>                 that is I will then lose any Markdown formatting,
>>                 which is not entirely uncommon in a prefix, and even
>>                 occasionally in a suffix. I can work around it for
>>                 this document, I guess, by just being careful not to
>>                 use any Markdown formatting in these instances, but
>>                 I'd love to find a way to take a set of Inlines and
>>                 convert it to a format without adding a block.
>>
>>                 On Friday, 29 July 2022 at 19:04:51 UTC+1
>>                 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>
>>                     Hi,
>>
>>                     For your first problem, when you do pandoc.write,
>>                     as a minimum a block is created, which, I
>>                     believe, is normally a paragraph. So, don't call
>>                     pandoc.write. I guess you can concatenate the
>>                     prefix, citation and suffix and pass them to the
>>                     pandoc.RawInline function.
>>
>>
>>                     For your second problem, I am guessing you are
>>                     using --citeproc in your defaults file. If that
>>                     is the case, try: 1) putting the defaults file
>>                     after the filter; or 2) specifying --citeproc
>>                     manually, also after the filter.
>>
>>                     Hth,
>>
>>                     Sukil
>>
>>
>>                     El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>>                     Thanks for all the help - definitely getting
>>>                     somewhere now!
>>>
>>>                     I guess what I want to avoid is replicating in
>>>                     my not-great-Lua code all the work Pandoc
>>>                     already has to take a string of Markdown and
>>>                     convert it to LaTeX. I'm using pandoc.write to
>>>                     attempt that, and it seems to be working to some
>>>                     degree. The code as it is now is below. I have
>>>                     two problems:
>>>
>>>                     1. This Markdown input [@Haran1982 165 n. 9,
>>>                     172] gets converted by my calling of
>>>                     pandoc.write into:
>>>
>>>                     ```
>>>                     \cite[165
>>>
>>>                     n.~9,
>>>
>>>                     172]{Haran1982}
>>>                     ```
>>>
>>>                     and I can't figure out why the blank lines are
>>>                     turning up. I imagine I need to do something
>>>                     more clever with the Inlines?
>>>
>>>
>>>                     2. Despite the fact that my output in the
>>>                     terminal shows that I am constructing the
>>>                     citetext variable as I am intending to, and I
>>>                     have this line of code:
>>>
>>>                                         return
>>>                     pandoc.RawInline('latex', citetext)
>>>
>>>                     The output .tex file still has the normal Pandoc
>>>                     citations. In other words, my writer is
>>>                     constructing a nice LaTeX string with what I
>>>                     want in it, and then discards it in favour of
>>>                     the normal Pandoc code, which is a little bit
>>>                     depressing.
>>>
>>>                     Can anyone spot what I'm missing now?
>>>
>>>                     Best,
>>>                     Lyndon
>>>
>>>                     ```
>>>                     function Writer(doc, opts)
>>>                         local filter = {
>>>                             Note = function(el)
>>>                                 return el:walk {
>>>                                     Cite = function(el)
>>>                                         -- processing logic
>>>                                         local citetext = ""
>>>                                         if #el.citations > 1 then
>>>                                             if el.citations[1].mode
>>>                     == "AuthorInText" then
>>>                     citetext = '\\textcites*'
>>>                                             elseif
>>>                     el.citations[1].mode == "SuppressAuthor" then
>>>                     citetext = '\\cites*'
>>>                                             elseif
>>>                     el.citations[1].mode == "NormalCitation" then
>>>                     citetext = '\\cites'
>>>                                             end
>>>                                         else
>>>                                             if el.citations[1].mode
>>>                     == "AuthorInText" then
>>>                     citetext = '\\textcite*'
>>>                                             elseif
>>>                     el.citations[1].mode == "SuppressAuthor" then
>>>                     citetext = '\\cite*'
>>>                                             elseif
>>>                     el.citations[1].mode == "NormalCitation" then
>>>                     citetext = '\\cite'
>>>                                             end
>>>                                         end
>>>                                         for _, c in
>>>                     pairs(el.citations) do
>>>                                             if #c.prefix > 0 then
>>>                                                 local doc =
>>>                     pandoc.Pandoc(c.prefix)
>>>                                                 local citeprefix =
>>>                     pandoc.write(doc, 'latex')
>>>                     citetext = citetext .. '[' .. citeprefix .. ']'
>>>                                             end
>>>                                             if #c.suffix > 0 then
>>>                                                 local doc =
>>>                     pandoc.Pandoc(c.suffix)
>>>                                                 local citesuffix =
>>>                     pandoc.write(doc, 'latex')
>>>                     citetext = citetext .. '[' .. citesuffix .. ']'
>>>                                             end
>>>                                             citetext = citetext ..
>>>                     '{' .. c.id <http://c.id> .. '}'
>>>                     print(citetext)
>>>                                         end
>>>                                         return
>>>                     pandoc.RawInline('latex', citetext)
>>>                                     end
>>>                                 }
>>>                             end
>>>                         }
>>>                         return pandoc.write(doc:walk(filter),
>>>                     'latex', opts)
>>>                     end
>>>                     ```
>>>
>>>                     On Friday, 29 July 2022 at 10:49:18 UTC+1
>>>                     suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>
>>>                         I don't know, but the building blocks you'll
>>>                         need are `pandoc.stringify` which takes any
>>>                         object and converts it into a string, and
>>>                         `pandoc.RawBlock` or `pandoc.RawInline`
>>>                         which convert a string into a raw block or
>>>                         inline, and take the format as first
>>>                         argument and the string as second.
>>>
>>>                         Hth,
>>>
>>>                         Sukil
>>>
>>>
>>>                         El 29/07/2022 a las 10:58, Lyndon Drake
>>>                         escribió:
>>>>                         So I have the citation prefix, which I
>>>>                         guess I have to convert to a valid LaTeX
>>>>                         string. How can I take an Inlines and
>>>>                         LaTeX-ify it to a string?
>>>>
>>>>                         On Friday, 29 July 2022 at 09:51:35 UTC+1
>>>>                         Lyndon Drake wrote:
>>>>
>>>>                             Ah yep, that works. Next thing is I
>>>>                             have to debug my obviously incorrect
>>>>                             code :-)
>>>>
>>>>                             On Friday, 29 July 2022 at 06:44:22
>>>>                             UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>
>>>>                                 That's the problem. This is a
>>>>                                 writer, not a filter. So you need
>>>>                                 to call it via
>>>>                                 -t latex-footcite.lua
>>>>                                 ________________________________________
>>>>
>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>                                 Auftrag von Lyndon Drake
>>>>                                 <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>                                 Gesendet: Freitag, 29. Juli 2022
>>>>                                 07:15:08
>>>>                                 An: pandoc-discuss
>>>>                                 Betreff: Re: Changing LaTeX output
>>>>                                 for citations inside footnotes
>>>>
>>>>                                 My command line is:
>>>>
>>>>                                 pandoc -dbookends-latex --template
>>>>                                 /Users/lyndon/.local/share/pandoc/templates/book.latex
>>>>                                 --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
>>>>                                 -s -o thesis_jeremiah_32.tex
>>>>                                 jer-32-thesis.md
>>>>
>>>>                                 It's definitely picking up the lua
>>>>                                 file because if I have a syntax
>>>>                                 error, pandoc tells me. But I don't
>>>>                                 get any output.
>>>>
>>>>                                 On Thursday, 28 July 2022 at
>>>>                                 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>                                 wrote:
>>>>                                 How do you run this ?
>>>>                                 I’ve tested with a minimal markdown
>>>>                                 file :
>>>>
>>>>                                 ```markdown
>>>>                                 asdf
>>>>                                 ```
>>>>
>>>>                                 Run with :
>>>>                                 pandoc asdf.md -t mylatex.lua
>>>>
>>>>                                 Result :
>>>>                                 got here
>>>>                                 asdf
>>>>
>>>>                                 So, it prints the first print
>>>>                                 statement of the writer.
>>>>
>>>>                                 Denis
>>>>
>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>                                 Auftrag von Lyndon Drake
>>>>                                 Gesendet: Donnerstag, 28. Juli 2022
>>>>                                 19:17
>>>>                                 An: pandoc-discuss
>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>                                 Betreff: Re: Changing LaTeX output
>>>>                                 for citations inside footnotes
>>>>
>>>>                                 Thanks for this - exactly what I
>>>>                                 needed. I've added my attempt at
>>>>                                 the code below, but I must be
>>>>                                 missing some basic part of it
>>>>                                 because it doesn't do anything. I
>>>>                                 added a couple of print statements
>>>>                                 that never get executed:
>>>>
>>>>                                 ```
>>>>                                 function Writer(doc, opts)
>>>>                                 print "got here"
>>>>                                 local filter = {
>>>>                                 Note = function(el)
>>>>                                 return el:walk {
>>>>                                 Cite = function(el)
>>>>                                 -- processing logic
>>>>                                 print "got further"
>>>>                                 local citation = ""
>>>>                                 if #el.citations > 1 then
>>>>                                 if citations[1].mode ==
>>>>                                 "AuthorInText" then
>>>>                                 citation = '\\textcites*'
>>>>                                 elseif citations[1].mode ==
>>>>                                 "SuppressAuthor" then
>>>>                                 citation = '\\cites*'
>>>>                                 elseif citations[1].mode ==
>>>>                                 "NormalCitation" then
>>>>                                 citation = '\\cites'
>>>>                                 end
>>>>                                 else
>>>>                                 if citations[1].mode ==
>>>>                                 "AuthorInText" then
>>>>                                 citation = '\\textcite*'
>>>>                                 elseif citations[1].mode ==
>>>>                                 "SuppressAuthor" then
>>>>                                 citation = '\\cite*'
>>>>                                 elseif citations[1].mode ==
>>>>                                 "NormalCitation" then
>>>>                                 citation = '\\cite'
>>>>                                 end
>>>>                                 end
>>>>                                 for c in el.citations do
>>>>                                 if c.prefix ~= "" then
>>>>                                 citation = citation .. '[' ..
>>>>                                 c.prefix .. ']'
>>>>                                 end
>>>>                                 if c.suffix ~= "" then
>>>>                                 citation = citation .. '[' ..
>>>>                                 c.suffix .. ']'
>>>>                                 end
>>>>                                 citation = citation .. '{' .. c.id
>>>>                                 <http://c.id><http://c.id> .. '}'
>>>>                                 end
>>>>                                 return pandoc.RawInline('latex',
>>>>                                 citation)
>>>>                                 end
>>>>                                 }
>>>>                                 end
>>>>                                 }
>>>>                                 return
>>>>                                 pandoc.write(doc:walk(filter),
>>>>                                 'latex', opts)
>>>>                                 end
>>>>                                 ```
>>>>
>>>>                                 Apologies for what must be a very
>>>>                                 basic question, but what am I
>>>>                                 missing here?
>>>>                                 On Wednesday, 27 July 2022 at
>>>>                                 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>                                 wrote:
>>>>                                 What kind of example do you need? I
>>>>                                 only know about the examples in the
>>>>                                 documentation.
>>>>
>>>>                                 I think this here is a nice one :
>>>>                                 https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>>>>
>>>>
>>>>                                 Or : the new style writer
>>>>                                 https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>>>>
>>>>
>>>>                                 So, something like this here could
>>>>                                 be start:
>>>>
>>>>                                 ```
>>>>                                 function Writer(doc, opts)
>>>>                                 local filter = {
>>>>                                 Note = function(el)
>>>>                                 return el:walk {
>>>>                                 Cite = function(el)
>>>>                                 -- processing logic
>>>>                                 return pandoc.RawInline('latex',
>>>>                                 '\\cite[prenote][postnote]{key}')
>>>>                                 end
>>>>                                 }
>>>>                                 end
>>>>                                 }
>>>>                                 return
>>>>                                 pandoc.write(doc:walk(filter),
>>>>                                 'latex', opts)
>>>>                                 end
>>>>                                 ```
>>>>
>>>>                                 I don’t think you can get the
>>>>                                 current writer in Lua.
>>>>
>>>>
>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>                                 Auftrag von Lyndon Drake
>>>>                                 Gesendet: Dienstag, 26. Juli 2022
>>>>                                 11:00
>>>>                                 An: pandoc-discuss
>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>                                 Betreff: Re: Changing LaTeX output
>>>>                                 for citations inside footnotes
>>>>
>>>>                                 Thanks for this. I can see how that
>>>>                                 could work.
>>>>
>>>>                                 Can you point me to another example
>>>>                                 that uses the walk function?
>>>>
>>>>                                 Regarding a new-style Lua writer,
>>>>                                 is there a way to get the current
>>>>                                 LaTeX writer as Lua code? Or is it
>>>>                                 just the Haskell code? (I once knew
>>>>                                 Haskell but that was rather a long
>>>>                                 time ago.)
>>>>                                 On Monday, 25 July 2022 at 22:02:38
>>>>                                 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>                                 I can't come up with a code example
>>>>                                 now, bit you can use the walk
>>>>                                 function
>>>>                                 (https://pandoc.org/lua-filters.html#type-block:walk)
>>>>                                 to modify the citations with a
>>>>                                 given mode inside notes. You'll
>>>>                                 need to build the citation via
>>>>                                 Pandoc.RawInline
>>>>                                 Maybe that would be a good example
>>>>                                 of a new style Lua writer.
>>>>                                 ________________________________________
>>>>
>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>                                 Auftrag von Lyndon Drake
>>>>                                 <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>                                 Gesendet: Montag, 25. Juli 2022
>>>>                                 21:46:28
>>>>                                 An: pandoc-discuss
>>>>                                 Betreff: Changing LaTeX output for
>>>>                                 citations inside footnotes
>>>>
>>>>                                 Hi,
>>>>
>>>>                                 So this is a slightly odd request,
>>>>                                 which really comes because of the
>>>>                                 unusual behaviour of the specific
>>>>                                 BibLaTeX bibliography style I'm
>>>>                                 using. In that style, \textcite
>>>>                                 inside a footnote produces an
>>>>                                 unwanted result. \cite produces the
>>>>                                 expected output. I have generally
>>>>                                 just gone through and hand-edited
>>>>                                 my Pandoc-produced LaTeX files when
>>>>                                 they get to the final copy stage,
>>>>                                 but that's painful, and I also
>>>>                                 thought that maybe this is possible
>>>>                                 to do in a Lua filter.
>>>>
>>>>                                 But I don't quite know where to
>>>>                                 start - obviously this is a bit
>>>>                                 different from the internal Pandoc
>>>>                                 citations. I'm going to begin the
>>>>                                 filter with this:
>>>>
>>>>                                 if FORMAT:match 'latex' then
>>>>                                 <https://pandoc.org/lua-filters.html#cb9-3>
>>>>                                 function
>>>>
>>>>                                 but what would the function be? If
>>>>                                 it is Footnote, then I don't really
>>>>                                 want the AST, I want the LaTeX that
>>>>                                 forms the footnote contents, and I
>>>>                                 suppose then I can just replace any
>>>>                                 occurrences of the string \textcite
>>>>                                 with the string \cite?
>>>>
>>>>                                 Any help would be awesome!
>>>>
>>>>                                 Best,
>>>>                                 Lyndon
>>>>
>>>>                                 -- 
>>>>                                 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>
>>>>                                 To view this discussion on the web
>>>>                                 visit
>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>                                 To view this discussion on the web
>>>>                                 visit
>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>                                 To view this discussion on the web
>>>>                                 visit
>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>
>>>>                                 To view this discussion on the web
>>>>                                 visit
>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>                         To view this discussion on the web visit
>>>>                         https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com
>>>>                         <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>                     To view this discussion on the web visit
>>>                     https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com
>>>                     <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>                 To view this discussion on the web visit
>>                 https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com
>>                 <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
>             To view this discussion on the web visit
>             https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com
>             <https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.com
>     <https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.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/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%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/1485f3b9-f893-c00d-6546-904732bf64ae%40gmail.com.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                                     ` <1485f3b9-f893-c00d-6546-904732bf64ae-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-08-05 20:47                                                                                       ` Sukil Etxenike arizaleta
       [not found]                                                                                         ` <67cbd620-a60e-2518-24fd-e618ece65d5c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Sukil Etxenike arizaleta @ 2022-08-05 20:47 UTC (permalink / raw)
  To: pandoc-discuss

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

Woops, please ignore, I misunderstood doc as referring to the `doc` and 
not a document.


El 05/08/2022 a las 22:43, Sukil Etxenike arizaleta escribió:
>
> I think `doc`'s fields and methods aren't documented, that's why I 
> didn't think of that. Good call!
>
>
> El 05/08/2022 a las 16:36, BPJ escribió:
>> But doc.blocks, which is the actual content of the doc, is a list of 
>> blocks, which you can pass to blocks_to_inlines. Don't forget to pass 
>> `{pandoc.Space()}` as the second argument!
>>
>> Den fre 5 aug. 2022 13:08Lyndon Drake <isenguard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>     Not really, because the issue is that Pandoc returns a doc, not a
>>     list of blocks. So blocks_to_inlines doesn't actually work. But
>>     the gsub trick works well enough to get around the issue, thankfully.
>>
>>     On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:
>>
>>         Can you convert the blocks to inlines with blocks_to_inlines?
>>
>>         https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines
>>
>>         Den lör 30 juli 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>             Nice, the :gsub does the trick (once I replaced \n* with
>>             \n+).
>>
>>             Thanks again, really appreciate the help with all this.
>>             Hopefully I can start to build some more Lua
>>             filters/writers now. It's a great system (thanks John
>>             MacFarlane!).
>>
>>             On Saturday, 30 July 2022 at 14:06:10 UTC+1
>>             suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>
>>                 I believe you can't create a pandoc document without
>>                 any block. Two possibilities come to mind:
>>
>>                 1. Round tripping: After fixing the citation, read it
>>                 as LaTeX, and maybe, run
>>                 pandoc.utils.blocks_to_inlines. (Hey, I never said it
>>                 wouldn't be messy). May not work, even.
>>
>>                 2. Simply delete all paragraph markers: in your case
>>                 with: citetext:gsub("\n*", " ")
>>
>>                 Hth,
>>
>>                 Sukil
>>
>>
>>
>>                 El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>>
>>>                 Hi Sukil,
>>>
>>>                 Thanks, you were quite correct about the second
>>>                 problem. I've amended that and it now works, at
>>>                 least in the sense that it is altering the output in
>>>                 the general way I want.
>>>
>>>                 On the first problem, I can just pandoc.stringify
>>>                 the prefix and suffix, and concatenate. The problem
>>>                 with that is I will then lose any Markdown
>>>                 formatting, which is not entirely uncommon in a
>>>                 prefix, and even occasionally in a suffix. I can
>>>                 work around it for this document, I guess, by just
>>>                 being careful not to use any Markdown formatting in
>>>                 these instances, but I'd love to find a way to take
>>>                 a set of Inlines and convert it to a format without
>>>                 adding a block.
>>>
>>>                 On Friday, 29 July 2022 at 19:04:51 UTC+1
>>>                 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>
>>>                     Hi,
>>>
>>>                     For your first problem, when you do
>>>                     pandoc.write, as a minimum a block is created,
>>>                     which, I believe, is normally a paragraph. So,
>>>                     don't call pandoc.write. I guess you can
>>>                     concatenate the prefix, citation and suffix and
>>>                     pass them to the pandoc.RawInline function.
>>>
>>>
>>>                     For your second problem, I am guessing you are
>>>                     using --citeproc in your defaults file. If that
>>>                     is the case, try: 1) putting the defaults file
>>>                     after the filter; or 2) specifying --citeproc
>>>                     manually, also after the filter.
>>>
>>>                     Hth,
>>>
>>>                     Sukil
>>>
>>>
>>>                     El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>>>                     Thanks for all the help - definitely getting
>>>>                     somewhere now!
>>>>
>>>>                     I guess what I want to avoid is replicating in
>>>>                     my not-great-Lua code all the work Pandoc
>>>>                     already has to take a string of Markdown and
>>>>                     convert it to LaTeX. I'm using pandoc.write to
>>>>                     attempt that, and it seems to be working to
>>>>                     some degree. The code as it is now is below. I
>>>>                     have two problems:
>>>>
>>>>                     1. This Markdown input [@Haran1982 165 n. 9,
>>>>                     172] gets converted by my calling of
>>>>                     pandoc.write into:
>>>>
>>>>                     ```
>>>>                     \cite[165
>>>>
>>>>                     n.~9,
>>>>
>>>>                     172]{Haran1982}
>>>>                     ```
>>>>
>>>>                     and I can't figure out why the blank lines are
>>>>                     turning up. I imagine I need to do something
>>>>                     more clever with the Inlines?
>>>>
>>>>
>>>>                     2. Despite the fact that my output in the
>>>>                     terminal shows that I am constructing the
>>>>                     citetext variable as I am intending to, and I
>>>>                     have this line of code:
>>>>
>>>>                                         return
>>>>                     pandoc.RawInline('latex', citetext)
>>>>
>>>>                     The output .tex file still has the normal
>>>>                     Pandoc citations. In other words, my writer is
>>>>                     constructing a nice LaTeX string with what I
>>>>                     want in it, and then discards it in favour of
>>>>                     the normal Pandoc code, which is a little bit
>>>>                     depressing.
>>>>
>>>>                     Can anyone spot what I'm missing now?
>>>>
>>>>                     Best,
>>>>                     Lyndon
>>>>
>>>>                     ```
>>>>                     function Writer(doc, opts)
>>>>                         local filter = {
>>>>                             Note = function(el)
>>>>                                 return el:walk {
>>>>                                     Cite = function(el)
>>>>                                         -- processing logic
>>>>                                         local citetext = ""
>>>>                                         if #el.citations > 1 then
>>>>                                             if el.citations[1].mode
>>>>                     == "AuthorInText" then
>>>>                     citetext = '\\textcites*'
>>>>                                             elseif
>>>>                     el.citations[1].mode == "SuppressAuthor" then
>>>>                     citetext = '\\cites*'
>>>>                                             elseif
>>>>                     el.citations[1].mode == "NormalCitation" then
>>>>                     citetext = '\\cites'
>>>>                                             end
>>>>                                         else
>>>>                                             if el.citations[1].mode
>>>>                     == "AuthorInText" then
>>>>                     citetext = '\\textcite*'
>>>>                                             elseif
>>>>                     el.citations[1].mode == "SuppressAuthor" then
>>>>                     citetext = '\\cite*'
>>>>                                             elseif
>>>>                     el.citations[1].mode == "NormalCitation" then
>>>>                     citetext = '\\cite'
>>>>                                             end
>>>>                                         end
>>>>                                         for _, c in
>>>>                     pairs(el.citations) do
>>>>                                             if #c.prefix > 0 then
>>>>                     local doc = pandoc.Pandoc(c.prefix)
>>>>                     local citeprefix = pandoc.write(doc, 'latex')
>>>>                     citetext = citetext .. '[' .. citeprefix .. ']'
>>>>                                             end
>>>>                                             if #c.suffix > 0 then
>>>>                     local doc = pandoc.Pandoc(c.suffix)
>>>>                     local citesuffix = pandoc.write(doc, 'latex')
>>>>                     citetext = citetext .. '[' .. citesuffix .. ']'
>>>>                                             end
>>>>                                             citetext = citetext ..
>>>>                     '{' .. c.id <http://c.id> .. '}'
>>>>                     print(citetext)
>>>>                                         end
>>>>                                         return
>>>>                     pandoc.RawInline('latex', citetext)
>>>>                                     end
>>>>                                 }
>>>>                             end
>>>>                         }
>>>>                         return pandoc.write(doc:walk(filter),
>>>>                     'latex', opts)
>>>>                     end
>>>>                     ```
>>>>
>>>>                     On Friday, 29 July 2022 at 10:49:18 UTC+1
>>>>                     suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>>
>>>>                         I don't know, but the building blocks
>>>>                         you'll need are `pandoc.stringify` which
>>>>                         takes any object and converts it into a
>>>>                         string, and `pandoc.RawBlock` or
>>>>                         `pandoc.RawInline` which convert a string
>>>>                         into a raw block or inline, and take the
>>>>                         format as first argument and the string as
>>>>                         second.
>>>>
>>>>                         Hth,
>>>>
>>>>                         Sukil
>>>>
>>>>
>>>>                         El 29/07/2022 a las 10:58, Lyndon Drake
>>>>                         escribió:
>>>>>                         So I have the citation prefix, which I
>>>>>                         guess I have to convert to a valid LaTeX
>>>>>                         string. How can I take an Inlines and
>>>>>                         LaTeX-ify it to a string?
>>>>>
>>>>>                         On Friday, 29 July 2022 at 09:51:35 UTC+1
>>>>>                         Lyndon Drake wrote:
>>>>>
>>>>>                             Ah yep, that works. Next thing is I
>>>>>                             have to debug my obviously incorrect
>>>>>                             code :-)
>>>>>
>>>>>                             On Friday, 29 July 2022 at 06:44:22
>>>>>                             UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>
>>>>>                                 That's the problem. This is a
>>>>>                                 writer, not a filter. So you need
>>>>>                                 to call it via
>>>>>                                 -t latex-footcite.lua
>>>>>                                 ________________________________________
>>>>>
>>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>>                                 Auftrag von Lyndon Drake
>>>>>                                 <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>>                                 Gesendet: Freitag, 29. Juli 2022
>>>>>                                 07:15:08
>>>>>                                 An: pandoc-discuss
>>>>>                                 Betreff: Re: Changing LaTeX output
>>>>>                                 for citations inside footnotes
>>>>>
>>>>>                                 My command line is:
>>>>>
>>>>>                                 pandoc -dbookends-latex --template
>>>>>                                 /Users/lyndon/.local/share/pandoc/templates/book.latex
>>>>>                                 --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua
>>>>>                                 -s -o thesis_jeremiah_32.tex
>>>>>                                 jer-32-thesis.md
>>>>>
>>>>>                                 It's definitely picking up the lua
>>>>>                                 file because if I have a syntax
>>>>>                                 error, pandoc tells me. But I
>>>>>                                 don't get any output.
>>>>>
>>>>>                                 On Thursday, 28 July 2022 at
>>>>>                                 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>>                                 wrote:
>>>>>                                 How do you run this ?
>>>>>                                 I’ve tested with a minimal
>>>>>                                 markdown file :
>>>>>
>>>>>                                 ```markdown
>>>>>                                 asdf
>>>>>                                 ```
>>>>>
>>>>>                                 Run with :
>>>>>                                 pandoc asdf.md -t mylatex.lua
>>>>>
>>>>>                                 Result :
>>>>>                                 got here
>>>>>                                 asdf
>>>>>
>>>>>                                 So, it prints the first print
>>>>>                                 statement of the writer.
>>>>>
>>>>>                                 Denis
>>>>>
>>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>>                                 Auftrag von Lyndon Drake
>>>>>                                 Gesendet: Donnerstag, 28. Juli
>>>>>                                 2022 19:17
>>>>>                                 An: pandoc-discuss
>>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>>                                 Betreff: Re: Changing LaTeX output
>>>>>                                 for citations inside footnotes
>>>>>
>>>>>                                 Thanks for this - exactly what I
>>>>>                                 needed. I've added my attempt at
>>>>>                                 the code below, but I must be
>>>>>                                 missing some basic part of it
>>>>>                                 because it doesn't do anything. I
>>>>>                                 added a couple of print statements
>>>>>                                 that never get executed:
>>>>>
>>>>>                                 ```
>>>>>                                 function Writer(doc, opts)
>>>>>                                 print "got here"
>>>>>                                 local filter = {
>>>>>                                 Note = function(el)
>>>>>                                 return el:walk {
>>>>>                                 Cite = function(el)
>>>>>                                 -- processing logic
>>>>>                                 print "got further"
>>>>>                                 local citation = ""
>>>>>                                 if #el.citations > 1 then
>>>>>                                 if citations[1].mode ==
>>>>>                                 "AuthorInText" then
>>>>>                                 citation = '\\textcites*'
>>>>>                                 elseif citations[1].mode ==
>>>>>                                 "SuppressAuthor" then
>>>>>                                 citation = '\\cites*'
>>>>>                                 elseif citations[1].mode ==
>>>>>                                 "NormalCitation" then
>>>>>                                 citation = '\\cites'
>>>>>                                 end
>>>>>                                 else
>>>>>                                 if citations[1].mode ==
>>>>>                                 "AuthorInText" then
>>>>>                                 citation = '\\textcite*'
>>>>>                                 elseif citations[1].mode ==
>>>>>                                 "SuppressAuthor" then
>>>>>                                 citation = '\\cite*'
>>>>>                                 elseif citations[1].mode ==
>>>>>                                 "NormalCitation" then
>>>>>                                 citation = '\\cite'
>>>>>                                 end
>>>>>                                 end
>>>>>                                 for c in el.citations do
>>>>>                                 if c.prefix ~= "" then
>>>>>                                 citation = citation .. '[' ..
>>>>>                                 c.prefix .. ']'
>>>>>                                 end
>>>>>                                 if c.suffix ~= "" then
>>>>>                                 citation = citation .. '[' ..
>>>>>                                 c.suffix .. ']'
>>>>>                                 end
>>>>>                                 citation = citation .. '{' .. c.id
>>>>>                                 <http://c.id><http://c.id> .. '}'
>>>>>                                 end
>>>>>                                 return pandoc.RawInline('latex',
>>>>>                                 citation)
>>>>>                                 end
>>>>>                                 }
>>>>>                                 end
>>>>>                                 }
>>>>>                                 return
>>>>>                                 pandoc.write(doc:walk(filter),
>>>>>                                 'latex', opts)
>>>>>                                 end
>>>>>                                 ```
>>>>>
>>>>>                                 Apologies for what must be a very
>>>>>                                 basic question, but what am I
>>>>>                                 missing here?
>>>>>                                 On Wednesday, 27 July 2022 at
>>>>>                                 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>>                                 wrote:
>>>>>                                 What kind of example do you need?
>>>>>                                 I only know about the examples in
>>>>>                                 the documentation.
>>>>>
>>>>>                                 I think this here is a nice one :
>>>>>                                 https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages
>>>>>
>>>>>
>>>>>                                 Or : the new style writer
>>>>>                                 https://pandoc.org/custom-writers.html#example-modified-markdown-writer
>>>>>
>>>>>
>>>>>                                 So, something like this here could
>>>>>                                 be start:
>>>>>
>>>>>                                 ```
>>>>>                                 function Writer(doc, opts)
>>>>>                                 local filter = {
>>>>>                                 Note = function(el)
>>>>>                                 return el:walk {
>>>>>                                 Cite = function(el)
>>>>>                                 -- processing logic
>>>>>                                 return pandoc.RawInline('latex',
>>>>>                                 '\\cite[prenote][postnote]{key}')
>>>>>                                 end
>>>>>                                 }
>>>>>                                 end
>>>>>                                 }
>>>>>                                 return
>>>>>                                 pandoc.write(doc:walk(filter),
>>>>>                                 'latex', opts)
>>>>>                                 end
>>>>>                                 ```
>>>>>
>>>>>                                 I don’t think you can get the
>>>>>                                 current writer in Lua.
>>>>>
>>>>>
>>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im
>>>>>                                 Auftrag von Lyndon Drake
>>>>>                                 Gesendet: Dienstag, 26. Juli 2022
>>>>>                                 11:00
>>>>>                                 An: pandoc-discuss
>>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>>>>>                                 Betreff: Re: Changing LaTeX output
>>>>>                                 for citations inside footnotes
>>>>>
>>>>>                                 Thanks for this. I can see how
>>>>>                                 that could work.
>>>>>
>>>>>                                 Can you point me to another
>>>>>                                 example that uses the walk function?
>>>>>
>>>>>                                 Regarding a new-style Lua writer,
>>>>>                                 is there a way to get the current
>>>>>                                 LaTeX writer as Lua code? Or is it
>>>>>                                 just the Haskell code? (I once
>>>>>                                 knew Haskell but that was rather a
>>>>>                                 long time ago.)
>>>>>                                 On Monday, 25 July 2022 at
>>>>>                                 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org
>>>>>                                 wrote:
>>>>>                                 I can't come up with a code
>>>>>                                 example now, bit you can use the
>>>>>                                 walk function
>>>>>                                 (https://pandoc.org/lua-filters.html#type-block:walk)
>>>>>                                 to modify the citations with a
>>>>>                                 given mode inside notes. You'll
>>>>>                                 need to build the citation via
>>>>>                                 Pandoc.RawInline
>>>>>                                 Maybe that would be a good example
>>>>>                                 of a new style Lua writer.
>>>>>                                 ________________________________________
>>>>>
>>>>>                                 Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>>>>>                                 <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im
>>>>>                                 Auftrag von Lyndon Drake
>>>>>                                 <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>>>                                 Gesendet: Montag, 25. Juli 2022
>>>>>                                 21:46:28
>>>>>                                 An: pandoc-discuss
>>>>>                                 Betreff: Changing LaTeX output for
>>>>>                                 citations inside footnotes
>>>>>
>>>>>                                 Hi,
>>>>>
>>>>>                                 So this is a slightly odd request,
>>>>>                                 which really comes because of the
>>>>>                                 unusual behaviour of the specific
>>>>>                                 BibLaTeX bibliography style I'm
>>>>>                                 using. In that style, \textcite
>>>>>                                 inside a footnote produces an
>>>>>                                 unwanted result. \cite produces
>>>>>                                 the expected output. I have
>>>>>                                 generally just gone through and
>>>>>                                 hand-edited my Pandoc-produced
>>>>>                                 LaTeX files when they get to the
>>>>>                                 final copy stage, but that's
>>>>>                                 painful, and I also thought that
>>>>>                                 maybe this is possible to do in a
>>>>>                                 Lua filter.
>>>>>
>>>>>                                 But I don't quite know where to
>>>>>                                 start - obviously this is a bit
>>>>>                                 different from the internal Pandoc
>>>>>                                 citations. I'm going to begin the
>>>>>                                 filter with this:
>>>>>
>>>>>                                 if FORMAT:match 'latex' then
>>>>>                                 <https://pandoc.org/lua-filters.html#cb9-3>
>>>>>                                 function
>>>>>
>>>>>                                 but what would the function be? If
>>>>>                                 it is Footnote, then I don't
>>>>>                                 really want the AST, I want the
>>>>>                                 LaTeX that forms the footnote
>>>>>                                 contents, and I suppose then I can
>>>>>                                 just replace any occurrences of
>>>>>                                 the string \textcite with the
>>>>>                                 string \cite?
>>>>>
>>>>>                                 Any help would be awesome!
>>>>>
>>>>>                                 Best,
>>>>>                                 Lyndon
>>>>>
>>>>>                                 -- 
>>>>>                                 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>>
>>>>>                                 To view this discussion on the web
>>>>>                                 visit
>>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>                                 To view this discussion on the web
>>>>>                                 visit
>>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>                                 To view this discussion on the web
>>>>>                                 visit
>>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
>>>>>
>>>>>                                 To view this discussion on the web
>>>>>                                 visit
>>>>>                                 https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com?utm_medium=email&utm_source=footer
>>>>>                                 <https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>                         To view this discussion on the web visit
>>>>>                         https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com
>>>>>                         <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>                     To view this discussion on the web visit
>>>>                     https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com
>>>>                     <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>                 To view this discussion on the web visit
>>>                 https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com
>>>                 <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>
>>             To view this discussion on the web visit
>>             https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com
>>             <https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.com
>>     <https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.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/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%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/67cbd620-a60e-2518-24fd-e618ece65d5c%40gmail.com.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                                         ` <67cbd620-a60e-2518-24fd-e618ece65d5c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-08-06 10:56                                                                                           ` Lyndon Drake
       [not found]                                                                                             ` <7404c6ef-789f-4fec-bf16-be469839b935n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: Lyndon Drake @ 2022-08-06 10:56 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 26149 bytes --]

Well, below is the code as it is at the moment… I still need a Pandoc 
object to pass to pandoc.write, so even if I use blocks_to_inlines, I'm not 
sure what I'd then do to produce the output I'm after?

```
function Writer(doc, opts)
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    local citetext = ""
                    if #el.citations > 1 then
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\cites'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\parencites*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\parencites'
                        end
                    else
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\cite'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\parencite*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\parencite'
                        end
                    end
                    for _, c in pairs(el.citations) do
                        if #c.prefix > 0 then
                            local doc = pandoc.Pandoc(c.prefix)
                            local citeprefix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citeprefix .. ']'
                        end
                        if #c.suffix > 0 then
                            local doc = pandoc.Pandoc(c.suffix)
                            local citesuffix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citesuffix .. ']'
                        end
                        citetext = citetext .. '{' .. c.id .. '}'
                    end
                    citetext = citetext:gsub("\n+", " ")                    
                    print(citetext)
                    return pandoc.RawInline('latex', citetext)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

On Friday, 5 August 2022 at 21:47:46 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:

> Woops, please ignore, I misunderstood doc as referring to the `doc` and 
> not a document.
>
>
> El 05/08/2022 a las 22:43, Sukil Etxenike arizaleta escribió:
>
> I think `doc`'s fields and methods aren't documented, that's why I didn't 
> think of that. Good call!
>
>
> El 05/08/2022 a las 16:36, BPJ escribió:
>
> But doc.blocks, which is the actual content of the doc, is a list of 
> blocks, which you can pass to blocks_to_inlines. Don't forget to pass 
> `{pandoc.Space()}` as the second argument!
>
> Den fre 5 aug. 2022 13:08Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>
>> Not really, because the issue is that Pandoc returns a doc, not a list of 
>> blocks. So blocks_to_inlines doesn't actually work. But the gsub trick 
>> works well enough to get around the issue, thankfully.
>>
>> On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:
>>
>>> Can you convert the blocks to inlines with blocks_to_inlines? 
>>>
>>> https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines
>>>
>>> Den lör 30 juli 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>>
>>>> Nice, the :gsub does the trick (once I replaced \n* with \n+). 
>>>>
>>>> Thanks again, really appreciate the help with all this. Hopefully I can 
>>>> start to build some more Lua filters/writers now. It's a great system 
>>>> (thanks John MacFarlane!).
>>>>
>>>> On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>>
>>>>> I believe you can't create a pandoc document without any block. Two 
>>>>> possibilities come to mind:
>>>>>
>>>>> 1. Round tripping: After fixing the citation, read it as LaTeX, and 
>>>>> maybe, run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't 
>>>>> be messy). May not work, even.
>>>>>
>>>>> 2. Simply delete all paragraph markers: in your case with: 
>>>>> citetext:gsub("\n*", " ")
>>>>>
>>>>> Hth,
>>>>>
>>>>> Sukil
>>>>>
>>>>>
>>>>>
>>>>> El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>>>>>
>>>>> Hi Sukil, 
>>>>>
>>>>> Thanks, you were quite correct about the second problem. I've amended 
>>>>> that and it now works, at least in the sense that it is altering the output 
>>>>> in the general way I want.
>>>>>
>>>>> On the first problem, I can just pandoc.stringify the prefix and 
>>>>> suffix, and concatenate. The problem with that is I will then lose any 
>>>>> Markdown formatting, which is not entirely uncommon in a prefix, and even 
>>>>> occasionally in a suffix. I can work around it for this document, I guess, 
>>>>> by just being careful not to use any Markdown formatting in these 
>>>>> instances, but I'd love to find a way to take a set of Inlines and convert 
>>>>> it to a format without adding a block.
>>>>>
>>>>> On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> For your first problem, when you do pandoc.write, as a minimum a 
>>>>>> block is created, which, I believe, is normally a paragraph. So, don't call 
>>>>>> pandoc.write. I guess you can concatenate the prefix, citation and suffix 
>>>>>> and pass them to the pandoc.RawInline function. 
>>>>>>
>>>>>>
>>>>>> For your second problem, I am guessing you are using --citeproc in 
>>>>>> your defaults file. If that is the case, try: 1) putting the defaults file 
>>>>>> after the filter; or 2) specifying --citeproc manually, also after the 
>>>>>> filter.
>>>>>>
>>>>>> Hth,
>>>>>>
>>>>>> Sukil
>>>>>>
>>>>>>
>>>>>> El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>>>>>>
>>>>>> Thanks for all the help - definitely getting somewhere now!
>>>>>>
>>>>>> I guess what I want to avoid is replicating in my not-great-Lua code 
>>>>>> all the work Pandoc already has to take a string of Markdown and convert it 
>>>>>> to LaTeX. I'm using pandoc.write to attempt that, and it seems to be 
>>>>>> working to some degree. The code as it is now is below. I have two 
>>>>>> problems: 
>>>>>>
>>>>>> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by 
>>>>>> my calling of pandoc.write into:
>>>>>>
>>>>>> ```
>>>>>> \cite[165
>>>>>>
>>>>>> n.~9,
>>>>>>
>>>>>> 172]{Haran1982}
>>>>>> ```
>>>>>>
>>>>>> and I can't figure out why the blank lines are turning up. I imagine 
>>>>>> I need to do something more clever with the Inlines?
>>>>>>
>>>>>>
>>>>>> 2. Despite the fact that my output in the terminal shows that I am 
>>>>>> constructing the citetext variable as I am intending to, and I have this 
>>>>>> line of code:
>>>>>>
>>>>>>                     return pandoc.RawInline('latex', citetext)
>>>>>>
>>>>>> The output .tex file still has the normal Pandoc citations. In other 
>>>>>> words, my writer is constructing a nice LaTeX string with what I want in 
>>>>>> it, and then discards it in favour of the normal Pandoc code, which is a 
>>>>>> little bit depressing.
>>>>>>
>>>>>> Can anyone spot what I'm missing now?
>>>>>>
>>>>>> Best,
>>>>>> Lyndon
>>>>>>
>>>>>> ```
>>>>>> function Writer(doc, opts)
>>>>>>     local filter = {
>>>>>>         Note = function(el)
>>>>>>             return el:walk {
>>>>>>                 Cite = function(el)
>>>>>>                     -- processing logic
>>>>>>                     local citetext = ""
>>>>>>                     if #el.citations > 1 then
>>>>>>                         if el.citations[1].mode == "AuthorInText" then
>>>>>>                             citetext = '\\textcites*'
>>>>>>                         elseif el.citations[1].mode == 
>>>>>> "SuppressAuthor" then
>>>>>>                             citetext = '\\cites*'
>>>>>>                         elseif el.citations[1].mode == 
>>>>>> "NormalCitation" then
>>>>>>                             citetext = '\\cites'
>>>>>>                         end
>>>>>>                     else
>>>>>>                         if el.citations[1].mode == "AuthorInText" then
>>>>>>                             citetext = '\\textcite*'
>>>>>>                         elseif el.citations[1].mode == 
>>>>>> "SuppressAuthor" then
>>>>>>                             citetext = '\\cite*'
>>>>>>                         elseif el.citations[1].mode == 
>>>>>> "NormalCitation" then
>>>>>>                             citetext = '\\cite'
>>>>>>                         end
>>>>>>                     end
>>>>>>                     for _, c in pairs(el.citations) do
>>>>>>                         if #c.prefix > 0 then
>>>>>>                             local doc = pandoc.Pandoc(c.prefix)
>>>>>>                             local citeprefix = pandoc.write(doc, 
>>>>>> 'latex')
>>>>>>                             citetext = citetext .. '[' .. citeprefix 
>>>>>> .. ']'
>>>>>>                         end
>>>>>>                         if #c.suffix > 0 then
>>>>>>                             local doc = pandoc.Pandoc(c.suffix)
>>>>>>                             local citesuffix = pandoc.write(doc, 
>>>>>> 'latex')
>>>>>>                             citetext = citetext .. '[' .. citesuffix 
>>>>>> .. ']'
>>>>>>                         end
>>>>>>                         citetext = citetext .. '{' .. c.id .. '}'
>>>>>>                         print(citetext)
>>>>>>                     end
>>>>>>                     return pandoc.RawInline('latex', citetext)
>>>>>>                 end
>>>>>>             }
>>>>>>         end
>>>>>>     }
>>>>>>     return pandoc.write(doc:walk(filter), 'latex', opts)
>>>>>> end
>>>>>> ```
>>>>>>
>>>>>> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>>>>>>
>>>>>>> I don't know, but the building blocks you'll need are 
>>>>>>> `pandoc.stringify` which takes any object and converts it into a string, 
>>>>>>> and `pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a 
>>>>>>> raw block or inline, and take the format as first argument and the string 
>>>>>>> as second.
>>>>>>>
>>>>>>> Hth,
>>>>>>>
>>>>>>> Sukil
>>>>>>>
>>>>>>>
>>>>>>> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>>>>>>>
>>>>>>> So I have the citation prefix, which I guess I have to convert to a 
>>>>>>> valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>>>>>>>
>>>>>>> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>>>>>>>
>>>>>>>> Ah yep, that works. Next thing is I have to debug my obviously 
>>>>>>>> incorrect code :-)
>>>>>>>>
>>>>>>>> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>>>>>>>>
>>>>>>>>> That's the problem. This is a writer, not a filter. So you need to 
>>>>>>>>> call it via 
>>>>>>>>> -t latex-footcite.lua 
>>>>>>>>> ________________________________________ 
>>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>>>>>>> Gesendet: Freitag, 29. Juli 2022 07:15:08 
>>>>>>>>> An: pandoc-discuss 
>>>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>>>>>
>>>>>>>>> My command line is: 
>>>>>>>>>
>>>>>>>>> pandoc -dbookends-latex --template 
>>>>>>>>> /Users/lyndon/.local/share/pandoc/templates/book.latex 
>>>>>>>>> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
>>>>>>>>> -s -o thesis_jeremiah_32.tex jer-32-thesis.md 
>>>>>>>>>
>>>>>>>>> It's definitely picking up the lua file because if I have a syntax 
>>>>>>>>> error, pandoc tells me. But I don't get any output. 
>>>>>>>>>
>>>>>>>>> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org 
>>>>>>>>> wrote: 
>>>>>>>>> How do you run this ? 
>>>>>>>>> I’ve tested with a minimal markdown file : 
>>>>>>>>>
>>>>>>>>> ```markdown 
>>>>>>>>> asdf 
>>>>>>>>> ``` 
>>>>>>>>>
>>>>>>>>> Run with : 
>>>>>>>>> pandoc asdf.md -t mylatex.lua 
>>>>>>>>>
>>>>>>>>> Result : 
>>>>>>>>> got here 
>>>>>>>>> asdf 
>>>>>>>>>
>>>>>>>>> So, it prints the first print statement of the writer. 
>>>>>>>>>
>>>>>>>>> Denis 
>>>>>>>>>
>>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>>>>>>> Auftrag von Lyndon Drake 
>>>>>>>>> Gesendet: Donnerstag, 28. Juli 2022 19:17 
>>>>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>>>>>
>>>>>>>>> Thanks for this - exactly what I needed. I've added my attempt at 
>>>>>>>>> the code below, but I must be missing some basic part of it because it 
>>>>>>>>> doesn't do anything. I added a couple of print statements that never get 
>>>>>>>>> executed: 
>>>>>>>>>
>>>>>>>>> ``` 
>>>>>>>>> function Writer(doc, opts) 
>>>>>>>>> print "got here" 
>>>>>>>>> local filter = { 
>>>>>>>>> Note = function(el) 
>>>>>>>>> return el:walk { 
>>>>>>>>> Cite = function(el) 
>>>>>>>>> -- processing logic 
>>>>>>>>> print "got further" 
>>>>>>>>> local citation = "" 
>>>>>>>>> if #el.citations > 1 then 
>>>>>>>>> if citations[1].mode == "AuthorInText" then 
>>>>>>>>> citation = '\\textcites*' 
>>>>>>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>>>>>>> citation = '\\cites*' 
>>>>>>>>> elseif citations[1].mode == "NormalCitation" then 
>>>>>>>>> citation = '\\cites' 
>>>>>>>>> end 
>>>>>>>>> else 
>>>>>>>>> if citations[1].mode == "AuthorInText" then 
>>>>>>>>> citation = '\\textcite*' 
>>>>>>>>> elseif citations[1].mode == "SuppressAuthor" then 
>>>>>>>>> citation = '\\cite*' 
>>>>>>>>> elseif citations[1].mode == "NormalCitation" then 
>>>>>>>>> citation = '\\cite' 
>>>>>>>>> end 
>>>>>>>>> end 
>>>>>>>>> for c in el.citations do 
>>>>>>>>> if c.prefix ~= "" then 
>>>>>>>>> citation = citation .. '[' .. c.prefix .. ']' 
>>>>>>>>> end 
>>>>>>>>> if c.suffix ~= "" then 
>>>>>>>>> citation = citation .. '[' .. c.suffix .. ']' 
>>>>>>>>> end 
>>>>>>>>> citation = citation .. '{' .. c.id<http://c.id> .. '}' 
>>>>>>>>> end 
>>>>>>>>> return pandoc.RawInline('latex', citation) 
>>>>>>>>> end 
>>>>>>>>> } 
>>>>>>>>> end 
>>>>>>>>> } 
>>>>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>>>>>>> end 
>>>>>>>>> ``` 
>>>>>>>>>
>>>>>>>>> Apologies for what must be a very basic question, but what am I 
>>>>>>>>> missing here? 
>>>>>>>>> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org 
>>>>>>>>> wrote: 
>>>>>>>>> What kind of example do you need? I only know about the examples 
>>>>>>>>> in the documentation. 
>>>>>>>>>
>>>>>>>>> I think this here is a nice one : 
>>>>>>>>>
>>>>>>>>> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages 
>>>>>>>>>
>>>>>>>>> Or : the new style writer 
>>>>>>>>>
>>>>>>>>> https://pandoc.org/custom-writers.html#example-modified-markdown-writer 
>>>>>>>>>
>>>>>>>>> So, something like this here could be start: 
>>>>>>>>>
>>>>>>>>> ``` 
>>>>>>>>> function Writer(doc, opts) 
>>>>>>>>> local filter = { 
>>>>>>>>> Note = function(el) 
>>>>>>>>> return el:walk { 
>>>>>>>>> Cite = function(el) 
>>>>>>>>> -- processing logic 
>>>>>>>>> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}') 
>>>>>>>>> end 
>>>>>>>>> } 
>>>>>>>>> end 
>>>>>>>>> } 
>>>>>>>>> return pandoc.write(doc:walk(filter), 'latex', opts) 
>>>>>>>>> end 
>>>>>>>>> ``` 
>>>>>>>>>
>>>>>>>>> I don’t think you can get the current writer in Lua. 
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im 
>>>>>>>>> Auftrag von Lyndon Drake 
>>>>>>>>> Gesendet: Dienstag, 26. Juli 2022 11:00 
>>>>>>>>> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
>>>>>>>>> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>>>>>>>>>
>>>>>>>>> Thanks for this. I can see how that could work. 
>>>>>>>>>
>>>>>>>>> Can you point me to another example that uses the walk function? 
>>>>>>>>>
>>>>>>>>> Regarding a new-style Lua writer, is there a way to get the 
>>>>>>>>> current LaTeX writer as Lua code? Or is it just the Haskell code? (I once 
>>>>>>>>> knew Haskell but that was rather a long time ago.) 
>>>>>>>>> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org 
>>>>>>>>> wrote: 
>>>>>>>>> I can't come up with a code example now, bit you can use the walk 
>>>>>>>>> function (https://pandoc.org/lua-filters.html#type-block:walk) to 
>>>>>>>>> modify the citations with a given mode inside notes. You'll need to build 
>>>>>>>>> the citation via Pandoc.RawInline 
>>>>>>>>> Maybe that would be a good example of a new style Lua writer. 
>>>>>>>>> ________________________________________ 
>>>>>>>>> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im 
>>>>>>>>> Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
>>>>>>>>> Gesendet: Montag, 25. Juli 2022 21:46:28 
>>>>>>>>> An: pandoc-discuss 
>>>>>>>>> Betreff: Changing LaTeX output for citations inside footnotes 
>>>>>>>>>
>>>>>>>>> Hi, 
>>>>>>>>>
>>>>>>>>> So this is a slightly odd request, which really comes because of 
>>>>>>>>> the unusual behaviour of the specific BibLaTeX bibliography style I'm 
>>>>>>>>> using. In that style, \textcite inside a footnote produces an unwanted 
>>>>>>>>> result. \cite produces the expected output. I have generally just gone 
>>>>>>>>> through and hand-edited my Pandoc-produced LaTeX files when they get to the 
>>>>>>>>> final copy stage, but that's painful, and I also thought that maybe this is 
>>>>>>>>> possible to do in a Lua filter. 
>>>>>>>>>
>>>>>>>>> But I don't quite know where to start - obviously this is a bit 
>>>>>>>>> different from the internal Pandoc citations. I'm going to begin the filter 
>>>>>>>>> with this: 
>>>>>>>>>
>>>>>>>>> if FORMAT:match 'latex' then <
>>>>>>>>> https://pandoc.org/lua-filters.html#cb9-3> function 
>>>>>>>>>
>>>>>>>>> but what would the function be? If it is Footnote, then I don't 
>>>>>>>>> really want the AST, I want the LaTeX that forms the footnote contents, and 
>>>>>>>>> I suppose then I can just replace any occurrences of the string \textcite 
>>>>>>>>> with the string \cite? 
>>>>>>>>>
>>>>>>>>> Any help would be awesome! 
>>>>>>>>>
>>>>>>>>> Best, 
>>>>>>>>> Lyndon 
>>>>>>>>>
>>>>>>>>> -- 
>>>>>>>>> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
>>>>>>>>> <
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
>>>>>>>>> <
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
>>>>>>>>> <
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:
>>>>>>>>> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>. 
>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
>>>>>>>>> <
>>>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>>>
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com 
>>>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>>
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com 
>>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>>
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com 
>>>>> <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>>>
>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com 
>>>> <https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%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/7404c6ef-789f-4fec-bf16-be469839b935n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 82061 bytes --]

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

* AW: Changing LaTeX output for citations inside footnotes
       [not found]                                                                                             ` <7404c6ef-789f-4fec-bf16-be469839b935n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-09-14 20:14                                                                                               ` denis.maier-NSENcxR/0n0
       [not found]                                                                                                 ` <c72e9e361aa946dd83f2fc8cc9cb1f85-NSENcxR/0n0@public.gmane.org>
  0 siblings, 1 reply; 24+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-09-14 20:14 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Just out of curiosity: have you been able to make any progress here?
Best,
Denis

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Lyndon Drake
Gesendet: Samstag, 6. August 2022 12:56
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Well, below is the code as it is at the moment… I still need a Pandoc object to pass to pandoc.write, so even if I use blocks_to_inlines, I'm not sure what I'd then do to produce the output I'm after?

```
function Writer(doc, opts)
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    local citetext = ""
                    if #el.citations > 1 then
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\cites'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\parencites*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\parencites'
                        end
                    else
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\cite'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\parencite*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\parencite'
                        end
                    end
                    for _, c in pairs(el.citations) do
                        if #c.prefix > 0 then
                            local doc = pandoc.Pandoc(c.prefix)
                            local citeprefix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citeprefix .. ']'
                        end
                        if #c.suffix > 0 then
                            local doc = pandoc.Pandoc(c.suffix)
                            local citesuffix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citesuffix .. ']'
                        end
                        citetext = citetext .. '{' .. c.id .. '}'
                    end
                    citetext = citetext:gsub("\n+", " ")
                    print(citetext)
                    return pandoc.RawInline('latex', citetext)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```
On Friday, 5 August 2022 at 21:47:46 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:suki...@gmail.com> wrote:

Woops, please ignore, I misunderstood doc as referring to the `doc` and not a document.


El 05/08/2022 a las 22:43, Sukil Etxenike arizaleta escribió:

I think `doc`'s fields and methods aren't documented, that's why I didn't think of that. Good call!


El 05/08/2022 a las 16:36, BPJ escribió:
But doc.blocks, which is the actual content of the doc, is a list of blocks, which you can pass to blocks_to_inlines. Don't forget to pass `{pandoc.Space()}` as the second argument!

Den fre 5 aug. 2022 13:08Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
Not really, because the issue is that Pandoc returns a doc, not a list of blocks. So blocks_to_inlines doesn't actually work. But the gsub trick works well enough to get around the issue, thankfully.
On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:
Can you convert the blocks to inlines with blocks_to_inlines?

https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines

Den lör 30 juli 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:isen...@gmail.com>> skrev:
Nice, the :gsub does the trick (once I replaced \n* with \n+).

Thanks again, really appreciate the help with all this. Hopefully I can start to build some more Lua filters/writers now. It's a great system (thanks John MacFarlane!).
On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:suki...@gmail.com> wrote:

I believe you can't create a pandoc document without any block. Two possibilities come to mind:

1. Round tripping: After fixing the citation, read it as LaTeX, and maybe, run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't be messy). May not work, even.

2. Simply delete all paragraph markers: in your case with: citetext:gsub("\n*", " ")

Hth,

Sukil





El 30/07/2022 a las 14:39, Lyndon Drake escribió:
Hi Sukil,

Thanks, you were quite correct about the second problem. I've amended that and it now works, at least in the sense that it is altering the output in the general way I want.

On the first problem, I can just pandoc.stringify the prefix and suffix, and concatenate. The problem with that is I will then lose any Markdown formatting, which is not entirely uncommon in a prefix, and even occasionally in a suffix. I can work around it for this document, I guess, by just being careful not to use any Markdown formatting in these instances, but I'd love to find a way to take a set of Inlines and convert it to a format without adding a block.
On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:suki...@gmail.com> wrote:

Hi,

For your first problem, when you do pandoc.write, as a minimum a block is created, which, I believe, is normally a paragraph. So, don't call pandoc.write. I guess you can concatenate the prefix, citation and suffix and pass them to the pandoc.RawInline function.



For your second problem, I am guessing you are using --citeproc in your defaults file. If that is the case, try: 1) putting the defaults file after the filter; or 2) specifying --citeproc manually, also after the filter.

Hth,

Sukil


El 29/07/2022 a las 16:58, Lyndon Drake escribió:
Thanks for all the help - definitely getting somewhere now!

I guess what I want to avoid is replicating in my not-great-Lua code all the work Pandoc already has to take a string of Markdown and convert it to LaTeX. I'm using pandoc.write to attempt that, and it seems to be working to some degree. The code as it is now is below. I have two problems:

1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my calling of pandoc.write into:

```
\cite[165

n.~9,

172]{Haran1982}
```

and I can't figure out why the blank lines are turning up. I imagine I need to do something more clever with the Inlines?


2. Despite the fact that my output in the terminal shows that I am constructing the citetext variable as I am intending to, and I have this line of code:

                    return pandoc.RawInline('latex', citetext)

The output .tex file still has the normal Pandoc citations. In other words, my writer is constructing a nice LaTeX string with what I want in it, and then discards it in favour of the normal Pandoc code, which is a little bit depressing.

Can anyone spot what I'm missing now?

Best,
Lyndon

```
function Writer(doc, opts)
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    local citetext = ""
                    if #el.citations > 1 then
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\textcites*'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\cites*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\cites'
                        end
                    else
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\textcite*'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\cite*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\cite'
                        end
                    end
                    for _, c in pairs(el.citations) do
                        if #c.prefix > 0 then
                            local doc = pandoc.Pandoc(c.prefix)
                            local citeprefix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citeprefix .. ']'
                        end
                        if #c.suffix > 0 then
                            local doc = pandoc.Pandoc(c.suffix)
                            local citesuffix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citesuffix .. ']'
                        end
                        citetext = citetext .. '{' .. c.id<http://c.id> .. '}'
                        print(citetext)
                    end
                    return pandoc.RawInline('latex', citetext)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```
On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:suki...@gmail.com> wrote:

I don't know, but the building blocks you'll need are `pandoc.stringify` which takes any object and converts it into a string, and `pandoc.RawBlock` or `pandoc.RawInline` which convert a string into a raw block or inline, and take the format as first argument and the string as second.

Hth,

Sukil


El 29/07/2022 a las 10:58, Lyndon Drake escribió:
So I have the citation prefix, which I guess I have to convert to a valid LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
Ah yep, that works. Next thing is I have to debug my obviously incorrect code :-)
On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org<mailto:denis...@unibe.ch> wrote:
That's the problem. This is a writer, not a filter. So you need to call it via
-t latex-footcite.lua
________________________________________
Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>> im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>>
Gesendet: Freitag, 29. Juli 2022 07:15:08
An: pandoc-discuss
Betreff: Re: Changing LaTeX output for citations inside footnotes

My command line is:

pandoc -dbookends-latex --template /Users/lyndon/.local/share/pandoc/templates/book.latex --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua -s -o thesis_jeremiah_32.tex jer-32-thesis.md

It's definitely picking up the lua file because if I have a syntax error, pandoc tells me. But I don't get any output.

On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org<mailto:denis...@unibe.ch> wrote:
How do you run this ?
I’ve tested with a minimal markdown file :

```markdown
asdf
```

Run with :
pandoc asdf.md -t mylatex.lua

Result :
got here
asdf

So, it prints the first print statement of the writer.

Denis

Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>> Im Auftrag von Lyndon Drake
Gesendet: Donnerstag, 28. Juli 2022 19:17
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...@googlegroups.com>>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Thanks for this - exactly what I needed. I've added my attempt at the code below, but I must be missing some basic part of it because it doesn't do anything. I added a couple of print statements that never get executed:

```
function Writer(doc, opts)
print "got here"
local filter = {
Note = function(el)
return el:walk {
Cite = function(el)
-- processing logic
print "got further"
local citation = ""
if #el.citations > 1 then
if citations[1].mode == "AuthorInText" then
citation = '\\textcites*'
elseif citations[1].mode == "SuppressAuthor" then
citation = '\\cites*'
elseif citations[1].mode == "NormalCitation" then
citation = '\\cites'
end
else
if citations[1].mode == "AuthorInText" then
citation = '\\textcite*'
elseif citations[1].mode == "SuppressAuthor" then
citation = '\\cite*'
elseif citations[1].mode == "NormalCitation" then
citation = '\\cite'
end
end
for c in el.citations do
if c.prefix ~= "" then
citation = citation .. '[' .. c.prefix .. ']'
end
if c.suffix ~= "" then
citation = citation .. '[' .. c.suffix .. ']'
end
citation = citation .. '{' .. c.id<http://c.id><http://c.id> .. '}'
end
return pandoc.RawInline('latex', citation)
end
}
end
}
return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

Apologies for what must be a very basic question, but what am I missing here?
On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org<mailto:denis...@unibe.ch> wrote:
What kind of example do you need? I only know about the examples in the documentation.

I think this here is a nice one :
https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages

Or : the new style writer
https://pandoc.org/custom-writers.html#example-modified-markdown-writer

So, something like this here could be start:

```
function Writer(doc, opts)
local filter = {
Note = function(el)
return el:walk {
Cite = function(el)
-- processing logic
return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}')
end
}
end
}
return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

I don’t think you can get the current writer in Lua.


Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>> Im Auftrag von Lyndon Drake
Gesendet: Dienstag, 26. Juli 2022 11:00
An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...@googlegroups.com>>
Betreff: Re: Changing LaTeX output for citations inside footnotes

Thanks for this. I can see how that could work.

Can you point me to another example that uses the walk function?

Regarding a new-style Lua writer, is there a way to get the current LaTeX writer as Lua code? Or is it just the Haskell code? (I once knew Haskell but that was rather a long time ago.)
On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org<mailto:denis...@unibe.ch> wrote:
I can't come up with a code example now, bit you can use the walk function (https://pandoc.org/lua-filters.html#type-block:walk) to modify the citations with a given mode inside notes. You'll need to build the citation via Pandoc.RawInline
Maybe that would be a good example of a new style Lua writer.
________________________________________
Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>> im Auftrag von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org<mailto:isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>>
Gesendet: Montag, 25. Juli 2022 21:46:28
An: pandoc-discuss
Betreff: Changing LaTeX output for citations inside footnotes

Hi,

So this is a slightly odd request, which really comes because of the unusual behaviour of the specific BibLaTeX bibliography style I'm using. In that style, \textcite inside a footnote produces an unwanted result. \cite produces the expected output. I have generally just gone through and hand-edited my Pandoc-produced LaTeX files when they get to the final copy stage, but that's painful, and I also thought that maybe this is possible to do in a Lua filter.

But I don't quite know where to start - obviously this is a bit different from the internal Pandoc citations. I'm going to begin the filter with this:

if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> function

but what would the function be? If it is Footnote, then I don't really want the AST, I want the LaTeX that forms the footnote contents, and I suppose then I can just replace any occurrences of the string \textcite with the string \cite?

Any help would be awesome!

Best,
Lyndon

--
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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com<mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org%3cmailto:pandoc-discus...@googlegroups.com>>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com<mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org%3cmailto:pandoc-discus...@googlegroups.com>>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail.com<https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/7404c6ef-789f-4fec-bf16-be469839b935n%40googlegroups.com<https://groups.google.com/d/msgid/pandoc-discuss/7404c6ef-789f-4fec-bf16-be469839b935n%40googlegroups.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/c72e9e361aa946dd83f2fc8cc9cb1f85%40unibe.ch.

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

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

* Re: Changing LaTeX output for citations inside footnotes
       [not found]                                                                                                 ` <c72e9e361aa946dd83f2fc8cc9cb1f85-NSENcxR/0n0@public.gmane.org>
@ 2022-09-15 18:53                                                                                                   ` Lyndon Drake
  0 siblings, 0 replies; 24+ messages in thread
From: Lyndon Drake @ 2022-09-15 18:53 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 27063 bytes --]

Yes, and I have been using it successfully now for a little while. Thank 
you for all the help getting it up and running! The code is still the same 
(using the gsub trick) as below. I should probably take all the `print` 
statements out now.

```
function Writer(doc, opts)
    local filter = {
        Note = function(el)
            return el:walk {
                Cite = function(el)
                    -- processing logic
                    local citetext = ""
                    if #el.citations > 1 then
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\cites'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\parencites*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\parencites'
                        end
                    else
                        if el.citations[1].mode == "AuthorInText" then
                            citetext = '\\cite'
                        elseif el.citations[1].mode == "SuppressAuthor" then
                            citetext = '\\parencite*'
                        elseif el.citations[1].mode == "NormalCitation" then
                            citetext = '\\parencite'
                        end
                    end
                    for _, c in pairs(el.citations) do
                        if #c.prefix > 0 then
                            local doc = pandoc.Pandoc(c.prefix)
                            local citeprefix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citeprefix .. ']'
                        end
                        if #c.suffix > 0 then
                            local doc = pandoc.Pandoc(c.suffix)
                            local citesuffix = pandoc.write(doc, 'latex')
                            citetext = citetext .. '[' .. citesuffix .. ']'
                        end
                        citetext = citetext .. '{' .. c.id .. '}'
                    end
                    citetext = citetext:gsub("\n+", " ")                    
                    print(citetext)
                    return pandoc.RawInline('latex', citetext)
                end
            }
        end
    }
    return pandoc.write(doc:walk(filter), 'latex', opts)
end
```

On Thursday, 15 September 2022 at 08:14:43 UTC+12 denis...-NSENcxR/0n0@public.gmane.org wrote:

> Just out of curiosity: have you been able to make any progress here?
>
> Best,
>
> Denis
>
>  
>
> *Von:* pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> *Im 
> Auftrag von *Lyndon Drake
> *Gesendet:* Samstag, 6. August 2022 12:56
> *An:* pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> *Betreff:* Re: Changing LaTeX output for citations inside footnotes
>
>  
>
> Well, below is the code as it is at the moment… I still need a Pandoc 
> object to pass to pandoc.write, so even if I use blocks_to_inlines, I'm not 
> sure what I'd then do to produce the output I'm after?
>
>  
>
> ```
>
> function Writer(doc, opts)
>     local filter = {
>         Note = function(el)
>             return el:walk {
>                 Cite = function(el)
>                     -- processing logic
>                     local citetext = ""
>                     if #el.citations > 1 then
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\cites'
>                         elseif el.citations[1].mode == "SuppressAuthor" 
> then
>                             citetext = '\\parencites*'
>                         elseif el.citations[1].mode == "NormalCitation" 
> then
>                             citetext = '\\parencites'
>                         end
>                     else
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\cite'
>                         elseif el.citations[1].mode == "SuppressAuthor" 
> then
>                             citetext = '\\parencite*'
>                         elseif el.citations[1].mode == "NormalCitation" 
> then
>                             citetext = '\\parencite'
>                         end
>                     end
>                     for _, c in pairs(el.citations) do
>                         if #c.prefix > 0 then
>                             local doc = pandoc.Pandoc(c.prefix)
>                             local citeprefix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citeprefix .. ']'
>                         end
>                         if #c.suffix > 0 then
>                             local doc = pandoc.Pandoc(c.suffix)
>                             local citesuffix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citesuffix .. ']'
>                         end
>                         citetext = citetext .. '{' .. c.id .. '}'
>                     end
>                     citetext = citetext:gsub("\n+", " ")                   
>  
>                     print(citetext)
>                     return pandoc.RawInline('latex', citetext)
>                 end
>             }
>         end
>     }
>     return pandoc.write(doc:walk(filter), 'latex', opts)
> end
>
> ```
>
> On Friday, 5 August 2022 at 21:47:46 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
> Woops, please ignore, I misunderstood doc as referring to the `doc` and 
> not a document.
>
>  
>
> El 05/08/2022 a las 22:43, Sukil Etxenike arizaleta escribió:
>
> I think `doc`'s fields and methods aren't documented, that's why I didn't 
> think of that. Good call!
>
>  
>
> El 05/08/2022 a las 16:36, BPJ escribió:
>
> But doc.blocks, which is the actual content of the doc, is a list of 
> blocks, which you can pass to blocks_to_inlines. Don't forget to pass 
> `{pandoc.Space()}` as the second argument!
>
>  
>
> Den fre 5 aug. 2022 13:08Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>
> Not really, because the issue is that Pandoc returns a doc, not a list of 
> blocks. So blocks_to_inlines doesn't actually work. But the gsub trick 
> works well enough to get around the issue, thankfully.
>
> On Monday, 1 August 2022 at 14:48:59 UTC+1 BP wrote:
>
> Can you convert the blocks to inlines with blocks_to_inlines? 
>
>  
>
> https://pandoc.org/lua-filters.html#pandoc.utils.blocks_to_inlines
>
>  
>
> Den lör 30 juli 2022 15:54Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>
> Nice, the :gsub does the trick (once I replaced \n* with \n+). 
>
>  
>
> Thanks again, really appreciate the help with all this. Hopefully I can 
> start to build some more Lua filters/writers now. It's a great system 
> (thanks John MacFarlane!).
>
> On Saturday, 30 July 2022 at 14:06:10 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
> I believe you can't create a pandoc document without any block. Two 
> possibilities come to mind:
>
> 1. Round tripping: After fixing the citation, read it as LaTeX, and maybe, 
> run pandoc.utils.blocks_to_inlines. (Hey, I never said it wouldn't be 
> messy). May not work, even.
>
> 2. Simply delete all paragraph markers: in your case with: 
> citetext:gsub("\n*", " ")
>
> Hth,
>
> Sukil
>
>  
>
>  
>
> El 30/07/2022 a las 14:39, Lyndon Drake escribió:
>
> Hi Sukil, 
>
>  
>
> Thanks, you were quite correct about the second problem. I've amended that 
> and it now works, at least in the sense that it is altering the output in 
> the general way I want.
>
>  
>
> On the first problem, I can just pandoc.stringify the prefix and suffix, 
> and concatenate. The problem with that is I will then lose any Markdown 
> formatting, which is not entirely uncommon in a prefix, and even 
> occasionally in a suffix. I can work around it for this document, I guess, 
> by just being careful not to use any Markdown formatting in these 
> instances, but I'd love to find a way to take a set of Inlines and convert 
> it to a format without adding a block.
>
> On Friday, 29 July 2022 at 19:04:51 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
> Hi,
>
> For your first problem, when you do pandoc.write, as a minimum a block is 
> created, which, I believe, is normally a paragraph. So, don't call 
> pandoc.write. I guess you can concatenate the prefix, citation and suffix 
> and pass them to the pandoc.RawInline function. 
>
>  
>
> For your second problem, I am guessing you are using --citeproc in your 
> defaults file. If that is the case, try: 1) putting the defaults file after 
> the filter; or 2) specifying --citeproc manually, also after the filter.
>
> Hth,
>
> Sukil
>
>  
>
> El 29/07/2022 a las 16:58, Lyndon Drake escribió:
>
> Thanks for all the help - definitely getting somewhere now!
>
>  
>
> I guess what I want to avoid is replicating in my not-great-Lua code all 
> the work Pandoc already has to take a string of Markdown and convert it to 
> LaTeX. I'm using pandoc.write to attempt that, and it seems to be working 
> to some degree. The code as it is now is below. I have two problems: 
>
>  
>
> 1. This Markdown input [@Haran1982 165 n. 9, 172] gets converted by my 
> calling of pandoc.write into:
>
>  
>
> ```
>
> \cite[165
>
> n.~9,
>
> 172]{Haran1982}
>
> ```
>
>  
>
> and I can't figure out why the blank lines are turning up. I imagine I 
> need to do something more clever with the Inlines?
>
>  
>
>  
>
> 2. Despite the fact that my output in the terminal shows that I am 
> constructing the citetext variable as I am intending to, and I have this 
> line of code:
>
>  
>
>                     return pandoc.RawInline('latex', citetext)
>
>  
>
> The output .tex file still has the normal Pandoc citations. In other 
> words, my writer is constructing a nice LaTeX string with what I want in 
> it, and then discards it in favour of the normal Pandoc code, which is a 
> little bit depressing.
>
>  
>
> Can anyone spot what I'm missing now?
>
>  
>
> Best,
>
> Lyndon
>
>  
>
> ```
>
> function Writer(doc, opts)
>     local filter = {
>         Note = function(el)
>             return el:walk {
>                 Cite = function(el)
>                     -- processing logic
>                     local citetext = ""
>                     if #el.citations > 1 then
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\textcites*'
>                         elseif el.citations[1].mode == "SuppressAuthor" 
> then
>                             citetext = '\\cites*'
>                         elseif el.citations[1].mode == "NormalCitation" 
> then
>                             citetext = '\\cites'
>                         end
>                     else
>                         if el.citations[1].mode == "AuthorInText" then
>                             citetext = '\\textcite*'
>                         elseif el.citations[1].mode == "SuppressAuthor" 
> then
>                             citetext = '\\cite*'
>                         elseif el.citations[1].mode == "NormalCitation" 
> then
>                             citetext = '\\cite'
>                         end
>                     end
>                     for _, c in pairs(el.citations) do
>                         if #c.prefix > 0 then
>                             local doc = pandoc.Pandoc(c.prefix)
>                             local citeprefix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citeprefix .. ']'
>                         end
>                         if #c.suffix > 0 then
>                             local doc = pandoc.Pandoc(c.suffix)
>                             local citesuffix = pandoc.write(doc, 'latex')
>                             citetext = citetext .. '[' .. citesuffix .. ']'
>                         end
>                         citetext = citetext .. '{' .. c.id .. '}'
>                         print(citetext)
>                     end
>                     return pandoc.RawInline('latex', citetext)
>                 end
>             }
>         end
>     }
>     return pandoc.write(doc:walk(filter), 'latex', opts)
> end
>
> ```
>
> On Friday, 29 July 2022 at 10:49:18 UTC+1 suki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
> I don't know, but the building blocks you'll need are `pandoc.stringify` 
> which takes any object and converts it into a string, and `pandoc.RawBlock` 
> or `pandoc.RawInline` which convert a string into a raw block or inline, 
> and take the format as first argument and the string as second.
>
> Hth,
>
> Sukil
>
>  
>
> El 29/07/2022 a las 10:58, Lyndon Drake escribió:
>
> So I have the citation prefix, which I guess I have to convert to a valid 
> LaTeX string. How can I take an Inlines and LaTeX-ify it to a string?
>
> On Friday, 29 July 2022 at 09:51:35 UTC+1 Lyndon Drake wrote:
>
> Ah yep, that works. Next thing is I have to debug my obviously incorrect 
> code :-)
>
> On Friday, 29 July 2022 at 06:44:22 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote:
>
> That's the problem. This is a writer, not a filter. So you need to call it 
> via 
> -t latex-footcite.lua 
> ________________________________________ 
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag 
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
> Gesendet: Freitag, 29. Juli 2022 07:15:08 
> An: pandoc-discuss 
> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>
> My command line is: 
>
> pandoc -dbookends-latex --template 
> /Users/lyndon/.local/share/pandoc/templates/book.latex 
> --lua-filter=/Users/lyndon/.local/share/pandoc/filters/latex-footcite.lua 
> -s -o thesis_jeremiah_32.tex jer-32-thesis.md 
>
> It's definitely picking up the lua file because if I have a syntax error, 
> pandoc tells me. But I don't get any output. 
>
> On Thursday, 28 July 2022 at 21:32:06 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
> How do you run this ? 
> I’ve tested with a minimal markdown file : 
>
> ```markdown 
> asdf 
> ``` 
>
> Run with : 
> pandoc asdf.md -t mylatex.lua 
>
> Result : 
> got here 
> asdf 
>
> So, it prints the first print statement of the writer. 
>
> Denis 
>
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag 
> von Lyndon Drake 
> Gesendet: Donnerstag, 28. Juli 2022 19:17 
> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>
> Thanks for this - exactly what I needed. I've added my attempt at the code 
> below, but I must be missing some basic part of it because it doesn't do 
> anything. I added a couple of print statements that never get executed: 
>
> ``` 
> function Writer(doc, opts) 
> print "got here" 
> local filter = { 
> Note = function(el) 
> return el:walk { 
> Cite = function(el) 
> -- processing logic 
> print "got further" 
> local citation = "" 
> if #el.citations > 1 then 
> if citations[1].mode == "AuthorInText" then 
> citation = '\\textcites*' 
> elseif citations[1].mode == "SuppressAuthor" then 
> citation = '\\cites*' 
> elseif citations[1].mode == "NormalCitation" then 
> citation = '\\cites' 
> end 
> else 
> if citations[1].mode == "AuthorInText" then 
> citation = '\\textcite*' 
> elseif citations[1].mode == "SuppressAuthor" then 
> citation = '\\cite*' 
> elseif citations[1].mode == "NormalCitation" then 
> citation = '\\cite' 
> end 
> end 
> for c in el.citations do 
> if c.prefix ~= "" then 
> citation = citation .. '[' .. c.prefix .. ']' 
> end 
> if c.suffix ~= "" then 
> citation = citation .. '[' .. c.suffix .. ']' 
> end 
> citation = citation .. '{' .. c.id<http://c.id> .. '}' 
> end 
> return pandoc.RawInline('latex', citation) 
> end 
> } 
> end 
> } 
> return pandoc.write(doc:walk(filter), 'latex', opts) 
> end 
> ``` 
>
> Apologies for what must be a very basic question, but what am I missing 
> here? 
> On Wednesday, 27 July 2022 at 11:27:32 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
> What kind of example do you need? I only know about the examples in the 
> documentation. 
>
> I think this here is a nice one : 
>
> https://pandoc.org/lua-filters.html#modifying-pandocs-manual.txt-for-man-pages 
>
> Or : the new style writer 
> https://pandoc.org/custom-writers.html#example-modified-markdown-writer 
>
> So, something like this here could be start: 
>
> ``` 
> function Writer(doc, opts) 
> local filter = { 
> Note = function(el) 
> return el:walk { 
> Cite = function(el) 
> -- processing logic 
> return pandoc.RawInline('latex', '\\cite[prenote][postnote]{key}') 
> end 
> } 
> end 
> } 
> return pandoc.write(doc:walk(filter), 'latex', opts) 
> end 
> ``` 
>
> I don’t think you can get the current writer in Lua. 
>
>
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag 
> von Lyndon Drake 
> Gesendet: Dienstag, 26. Juli 2022 11:00 
> An: pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 
> Betreff: Re: Changing LaTeX output for citations inside footnotes 
>
> Thanks for this. I can see how that could work. 
>
> Can you point me to another example that uses the walk function? 
>
> Regarding a new-style Lua writer, is there a way to get the current LaTeX 
> writer as Lua code? Or is it just the Haskell code? (I once knew Haskell 
> but that was rather a long time ago.) 
> On Monday, 25 July 2022 at 22:02:38 UTC+1 denis...-NSENcxR/0n0@public.gmane.org wrote: 
> I can't come up with a code example now, bit you can use the walk function 
> (https://pandoc.org/lua-filters.html#type-block:walk) to modify the 
> citations with a given mode inside notes. You'll need to build the citation 
> via Pandoc.RawInline 
> Maybe that would be a good example of a new style Lua writer. 
> ________________________________________ 
> Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> im Auftrag 
> von Lyndon Drake <isen...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 
> Gesendet: Montag, 25. Juli 2022 21:46:28 
> An: pandoc-discuss 
> Betreff: Changing LaTeX output for citations inside footnotes 
>
> Hi, 
>
> So this is a slightly odd request, which really comes because of the 
> unusual behaviour of the specific BibLaTeX bibliography style I'm using. In 
> that style, \textcite inside a footnote produces an unwanted result. \cite 
> produces the expected output. I have generally just gone through and 
> hand-edited my Pandoc-produced LaTeX files when they get to the final copy 
> stage, but that's painful, and I also thought that maybe this is possible 
> to do in a Lua filter. 
>
> But I don't quite know where to start - obviously this is a bit different 
> from the internal Pandoc citations. I'm going to begin the filter with 
> this: 
>
> if FORMAT:match 'latex' then <https://pandoc.org/lua-filters.html#cb9-3> 
> function 
>
> but what would the function be? If it is Footnote, then I don't really 
> want the AST, I want the LaTeX that forms the footnote contents, and I 
> suppose then I can just replace any occurrences of the string \textcite 
> with the string \cite? 
>
> Any help would be awesome! 
>
> Best, 
> Lyndon 
>
> -- 
> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm>. 
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/d25cee8b-7cb2-4fe9-b44d-f288a8fef728n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/90c69f14-e16a-44d6-91ec-a6f6dca3ca45n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<mailto:pandoc-discus...-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm>. 
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.com
> <
> https://groups.google.com/d/msgid/pandoc-discuss/c4609f20-77f3-4427-83ae-6c79ba48ed5bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/a1e38719-d239-44af-84b0-67a1764dbb70n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/0e10379f-d1c0-4024-b98a-5c7ba703f561n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/28ac6c29-817d-41b6-891e-915ea28bdf3bn%40googlegroups.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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%40mail.gmail.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhBDo-Ya3Wabo27CQd%3Dt6JGtkzmYOoqbcCW2tkK%3DGKd7FA%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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/7404c6ef-789f-4fec-bf16-be469839b935n%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/7404c6ef-789f-4fec-bf16-be469839b935n%40googlegroups.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/5f62543f-48e0-410c-a3e0-0751186028c3n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 49460 bytes --]

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

end of thread, other threads:[~2022-09-15 18:53 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarPgACoPYCAAacucIACCGuAgABXaOCAAHEpAIAAKRxZ>
     [not found] ` <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarPgACoPYCAAacucIACCGuAgABXaOA=>
     [not found]   ` <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarPgACoPYCAAacucA==>
     [not found]     ` <AQHYoF9B2NW7S0SeqEyMpv5fXcG4hq2PkarP>
2022-07-25 19:46       ` Changing LaTeX output for citations inside footnotes Lyndon Drake
     [not found]         ` <bc06a6d8-9a34-4ca9-a05d-2526b23c6f6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-25 21:02           ` AW: " denis.maier-NSENcxR/0n0
     [not found]             ` <ea8df9c4b2d1418882909bb8a789d95f-NSENcxR/0n0@public.gmane.org>
2022-07-26  9:00               ` Lyndon Drake
     [not found]                 ` <d25cee8b-7cb2-4fe9-b44d-f288a8fef728n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-27 10:27                   ` AW: " denis.maier-NSENcxR/0n0
     [not found]                     ` <97765931b0a740ed8a84ba4337bed661-NSENcxR/0n0@public.gmane.org>
2022-07-28 17:17                       ` Lyndon Drake
     [not found]                         ` <90c69f14-e16a-44d6-91ec-a6f6dca3ca45n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-28 20:31                           ` AW: " denis.maier-NSENcxR/0n0
     [not found]                             ` <b1e75d01e60647dc89b599683996c6b1-NSENcxR/0n0@public.gmane.org>
2022-07-29  5:15                               ` Lyndon Drake
     [not found]                                 ` <c4609f20-77f3-4427-83ae-6c79ba48ed5bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29  5:44                                   ` AW: " denis.maier-NSENcxR/0n0
     [not found]                                     ` <ae44d2fa18454bbf80aa666040dee1f7-NSENcxR/0n0@public.gmane.org>
2022-07-29  8:51                                       ` Lyndon Drake
     [not found]                                         ` <e578ff2f-aab9-45da-93ef-d8b5705b14f8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29  8:58                                           ` Lyndon Drake
     [not found]                                             ` <a1e38719-d239-44af-84b0-67a1764dbb70n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29  9:49                                               ` Sukil Etxenike arizaleta
     [not found]                                                 ` <8976ce00-3fbe-bf27-898f-0470cba1fec1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-07-29 14:58                                                   ` Lyndon Drake
     [not found]                                                     ` <0e10379f-d1c0-4024-b98a-5c7ba703f561n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-29 18:04                                                       ` Sukil Etxenike arizaleta
     [not found]                                                         ` <83a04bea-2e09-61d2-de0d-f399beb2ef79-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-07-30 12:39                                                           ` Lyndon Drake
     [not found]                                                             ` <76a7fa0b-752b-496e-98a3-cc6ee8ef68b0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-07-30 13:06                                                               ` Sukil Etxenike arizaleta
     [not found]                                                                 ` <7ead9a3f-3aa9-fb2e-5ad5-c069d2aee315-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-07-30 13:53                                                                   ` Lyndon Drake
     [not found]                                                                     ` <5d1a1315-d0df-4e28-b13b-8eb8e8d7f9c7n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-08-01 13:48                                                                       ` BPJ
     [not found]                                                                         ` <CADAJKhCZYd1B8244+ZUN_DpRqEFG43zx_DQU3+OzCKHhFdYdnQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-05 11:08                                                                           ` Lyndon Drake
     [not found]                                                                             ` <28ac6c29-817d-41b6-891e-915ea28bdf3bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-08-05 14:36                                                                               ` BPJ
     [not found]                                                                                 ` <CADAJKhBDo-Ya3Wabo27CQd=t6JGtkzmYOoqbcCW2tkK=GKd7FA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-05 20:43                                                                                   ` Sukil Etxenike arizaleta
     [not found]                                                                                     ` <1485f3b9-f893-c00d-6546-904732bf64ae-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-08-05 20:47                                                                                       ` Sukil Etxenike arizaleta
     [not found]                                                                                         ` <67cbd620-a60e-2518-24fd-e618ece65d5c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-08-06 10:56                                                                                           ` Lyndon Drake
     [not found]                                                                                             ` <7404c6ef-789f-4fec-bf16-be469839b935n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-09-14 20:14                                                                                               ` AW: " denis.maier-NSENcxR/0n0
     [not found]                                                                                                 ` <c72e9e361aa946dd83f2fc8cc9cb1f85-NSENcxR/0n0@public.gmane.org>
2022-09-15 18:53                                                                                                   ` Lyndon Drake

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