public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Custom pandoc writer in lua: attempt to call nil value
@ 2022-04-20 14:38 A A
       [not found] ` <06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: A A @ 2022-04-20 14:38 UTC (permalink / raw)
  To: pandoc-discuss


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



Warning, I am crossposting from 
StackOverflow: https://stackoverflow.com/questions/71940439/custom-pandoc-writer-in-lua-attempt-to-call-nil-value

I’m trying to set up a simple custom writer going from pandoc‘s markdown to 
latex. Here’s what I have so far:
test.md 

# A section

## A subsection

Heres a paragraph.

Heres another

custom_writer.lua 


function Header(lev, s, attr)
    level_sequences = {
        "section",
        "subsection",
        "subsubsection",
        "subsubsubsection"
    }
    return string.format("\\%s{%s}", level_sequences[lev], s)
end

function Para(s)
    return s.."\\parskip"
end

function Str(s)
    return s
end

function Space()
    return " "
end

Question 

As far as I understand from the docs 
<https://pandoc.org/custom-writers.html>

A writer using the classic style defines rendering functions for each 
element of the pandoc AST

I checked the resulting JSON from my markdown file and the only the 
following elements occur:

   - Header 
   - Para 
   - Str 
   - Space 

It seems to my that I’ve covered all the necessary elements in the AST, so 
I’m not sure why pandoc complains with Error running lua: attempt to call a 
nil value when I do the following:

pandoc test.md -t custom_writer.lua

Does anyone know what I’m missing in custom_writer.lua?
​

-- 
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/06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n%40googlegroups.com.

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

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

* Re: Custom pandoc writer in lua: attempt to call nil value
       [not found] ` <06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-04-20 15:09   ` Bastien DUMONT
  2022-04-20 15:15   ` A A
  1 sibling, 0 replies; 3+ messages in thread
From: Bastien DUMONT @ 2022-04-20 15:09 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Search for "local meta = {}" here: https://pandoc.org/custom-writers.html
You will find a chunk of code that will let you know that you miss a Doc and a Blocksep function.

Le Wednesday 20 April 2022 à 07:38:39AM, A A a écrit :
> Warning, I am crossposting from StackOverflow: https://stackoverflow.com/
> questions/71940439/custom-pandoc-writer-in-lua-attempt-to-call-nil-value
> 
> I’m trying to set up a simple custom writer going from pandoc‘s markdown to
> latex. Here’s what I have so far:
> 
> test.md
> 
> # A section
> 
> ## A subsection
> 
> Heres a paragraph.
> 
> Heres another
> 
> custom_writer.lua
> 
> function Header(lev, s, attr)
>     level_sequences = {
>         "section",
>         "subsection",
>         "subsubsection",
>         "subsubsubsection"
>     }
>     return string.format("\\%s{%s}", level_sequences[lev], s)
> end
> 
> function Para(s)
>     return s.."\\parskip"
> end
> 
> function Str(s)
>     return s
> end
> 
> function Space()
>     return " "
> end
> 
> Question
> 
> As far as I understand from the [1]docs
> 
>     A writer using the classic style defines rendering functions for each
>     element of the pandoc AST
> 
> I checked the resulting JSON from my markdown file and the only the following
> elements occur:
> 
>   • Header
>   • Para
>   • Str
>   • Space
> 
> It seems to my that I’ve covered all the necessary elements in the AST, so I’m
> not sure why pandoc complains with Error running lua: attempt to call a nil
> value when I do the following:
> 
> pandoc test.md -t custom_writer.lua
> 
> Does anyone know what I’m missing in custom_writer.lua?
> 
> ​
> 
> --
> 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 [2]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit [3]https://groups.google.com/d/msgid/
> pandoc-discuss/06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n%40googlegroups.com.
> 
> References:
> 
> [1] https://pandoc.org/custom-writers.html
> [2] mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [3] https://groups.google.com/d/msgid/pandoc-discuss/06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n%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/YmAiL1WPhyhS6wuO%40localhost.


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

* Re: Custom pandoc writer in lua: attempt to call nil value
       [not found] ` <06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2022-04-20 15:09   ` Bastien DUMONT
@ 2022-04-20 15:15   ` A A
  1 sibling, 0 replies; 3+ messages in thread
From: A A @ 2022-04-20 15:15 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Nevermind, found the solution

On Wed, 20 Apr 2022 at 16:38, A A <amine.aboufirass-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Warning, I am crossposting from StackOverflow:
> https://stackoverflow.com/questions/71940439/custom-pandoc-writer-in-lua-attempt-to-call-nil-value
>
> I’m trying to set up a simple custom writer going from pandoc‘s markdown
> to latex. Here’s what I have so far:
> test.md
>
> # A section
>
> ## A subsection
>
> Heres a paragraph.
>
> Heres another
>
> custom_writer.lua
>
>
> function Header(lev, s, attr)
>     level_sequences = {
>         "section",
>         "subsection",
>         "subsubsection",
>         "subsubsubsection"
>     }
>     return string.format("\\%s{%s}", level_sequences[lev], s)
> end
>
> function Para(s)
>     return s.."\\parskip"
> end
>
> function Str(s)
>     return s
> end
>
> function Space()
>     return " "
> end
>
> Question
>
> As far as I understand from the docs
> <https://pandoc.org/custom-writers.html>
>
> A writer using the classic style defines rendering functions for each
> element of the pandoc AST
>
> I checked the resulting JSON from my markdown file and the only the
> following elements occur:
>
>    - Header
>    - Para
>    - Str
>    - Space
>
> It seems to my that I’ve covered all the necessary elements in the AST, so
> I’m not sure why pandoc complains with Error running lua: attempt to call
> a nil value when I do the following:
>
> pandoc test.md -t custom_writer.lua
>
> Does anyone know what I’m missing in custom_writer.lua?
> ​
>
> --
> 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/06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n%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/CAMwawgOHhZuGtjpnK5Poi4B9iQcuNynjE-riKuSa04Gbf%3DN58w%40mail.gmail.com.

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

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

end of thread, other threads:[~2022-04-20 15:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 14:38 Custom pandoc writer in lua: attempt to call nil value A A
     [not found] ` <06eadb3d-05b3-46f8-8cf6-8f84e1acc6c2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-04-20 15:09   ` Bastien DUMONT
2022-04-20 15:15   ` A A

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