public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to resolve "WARNING: Undefined function 'Figure'"? Is there a workaround?
@ 2023-11-28 17:03 Klaus R.
       [not found] ` <84b364a6-bbfe-4c9b-b825-d0f52557229fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Klaus R. @ 2023-11-28 17:03 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi,

To generate my documentation, I use a toolchain that generates a markdown 
file from various sources, the last step is the generation of Confluence 
HTML via Pandoc. Since Pandoc does not directly support Confluence HTML, I 
use a patched version of 
https://github.com/jpbarrette/pandoc-confluence-writer (patched because the 
generated HTMl is not always quite correct and some features I need are 
missing). This worked well for a long time, but after the last update (from 
Pandoc 2.19.2 to 3.1.8) I got a series of warnings:



*WARNING: Undefined function 'Figure'WARNING: Undefined function 
'Figure'...*

and the HTML code for the images is completely missing. I tried Pandoc 
3.1.9, same result. Confusing: the Lua code of pandoc-confluence-writer 
does not contain a call to a function named "Figure". Just to analyze the 
problem, i tried custom-markdown.lua from 
https://gist.github.com/tarleb/5a9c3fbfa47b0e6d3643efd8af2994b9 and i got:


*Error running Lua:custom-markdown.lua:19: No function to convert Figure 
(Block)*

What's going on? Is this a bug in Pandoc? Is there a workaround?

At the moment I will be using version 2.19.2, but I would like to be able 
to upgrade to newer versions of Pandoc.

Minimal example:





*# ExampleJust an example.![Fancy example](img/mypic.png){scale=70}*


Regards,
Klaus

-- 
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/84b364a6-bbfe-4c9b-b825-d0f52557229fn%40googlegroups.com.

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

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

* Re: How to resolve "WARNING: Undefined function 'Figure'"? Is there a workaround?
       [not found] ` <84b364a6-bbfe-4c9b-b825-d0f52557229fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2023-11-28 17:31   ` 'William Lupton' via pandoc-discuss
       [not found]     ` <CAEe_xxg1bdy8nKFf1uY4NojPTxJgxTur-7Es5Y+rHMaXOtKeBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-11-28 17:31 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

The Figure element was added in 3.0: search https://pandoc.org/releases.html
for "Support complex figures" for full details.

So I think that your Confluence writer needs to be updated! I see that it
has a CaptionedImage function and suspect that this will no longer be
called, and that the needs-to-be-added Figure function will get called
instead, but probably not with exactly the same arguments.

Are you OK with hacking this? I don't mind having a go if not... let me
know!

On Tue, 28 Nov 2023 at 17:04, Klaus R. <k-rindfrey-Mmb7MZpHnFY@public.gmane.org> wrote:

> Hi,
>
> To generate my documentation, I use a toolchain that generates a markdown
> file from various sources, the last step is the generation of Confluence
> HTML via Pandoc. Since Pandoc does not directly support Confluence HTML, I
> use a patched version of
> https://github.com/jpbarrette/pandoc-confluence-writer (patched because
> the generated HTMl is not always quite correct and some features I need are
> missing). This worked well for a long time, but after the last update (from
> Pandoc 2.19.2 to 3.1.8) I got a series of warnings:
>
>
>
> *WARNING: Undefined function 'Figure'WARNING: Undefined function
> 'Figure'...*
>
> and the HTML code for the images is completely missing. I tried Pandoc
> 3.1.9, same result. Confusing: the Lua code of pandoc-confluence-writer
> does not contain a call to a function named "Figure". Just to analyze the
> problem, i tried custom-markdown.lua from
> https://gist.github.com/tarleb/5a9c3fbfa47b0e6d3643efd8af2994b9 and i got:
>
>
> *Error running Lua:custom-markdown.lua:19: No function to convert Figure
> (Block)*
>
> What's going on? Is this a bug in Pandoc? Is there a workaround?
>
> At the moment I will be using version 2.19.2, but I would like to be able
> to upgrade to newer versions of Pandoc.
>
> Minimal example:
>
>
>
>
>
> *# ExampleJust an example.![Fancy example](img/mypic.png){scale=70}*
>
>
> Regards,
> Klaus
>
> --
> 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/84b364a6-bbfe-4c9b-b825-d0f52557229fn%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/84b364a6-bbfe-4c9b-b825-d0f52557229fn%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/CAEe_xxg1bdy8nKFf1uY4NojPTxJgxTur-7Es5Y%2BrHMaXOtKeBA%40mail.gmail.com.

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

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

* Re: How to resolve "WARNING: Undefined function 'Figure'"? Is there a workaround?
       [not found]     ` <CAEe_xxg1bdy8nKFf1uY4NojPTxJgxTur-7Es5Y+rHMaXOtKeBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-11-28 18:14       ` 'William Lupton' via pandoc-discuss
       [not found]         ` <CAEe_xxjzpptPpYC9cAPP4GaSw32qmOA8d0KeV-8MsgyS8=QGMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-11-28 18:14 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

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

Something like this should work? The change to attributes() is a hack to
use 'data-scale' rather than 'scale' and the change to Image() is to insert
the alt text and the attributes. The main change is the new Figure()
function (oops... I see that I'm ignoring its attributes).

% git diff -w
diff --git a/confluence.lua b/confluence.lua
index 3057d10..1a7d8ef 100644
--- a/confluence.lua
+++ b/confluence.lua
@@ -38,7 +38,9 @@ local function attributes(attr)
   local attr_table = {}
   for x,y in pairs(attr) do
       if y and y ~= "" then
-      table.insert(attr_table, ' ' .. x .. '="' .. escape(y,true) .. '"')
+          local p = ""
+          if x == "scale" then p = "data-" end
+      table.insert(attr_table, ' ' .. p .. x .. '="' .. escape(y,true) ..
'"')
     end
   end
   return table.concat(attr_table)
@@ -162,7 +164,7 @@ end

 function Image(s, src, tit, attr)
   return "<img src='" .. escape(src,true) .. "' title='" ..
-         escape(tit,true) .. "'/>"
+      escape(tit,true) .. "' alt='" .. s .. "'" .. attributes(attr)  ..
"/>"
 end

 function Code(s, attr)
@@ -330,6 +332,14 @@ function CaptionedImage(src, tit, caption, attr)
    return Div('<table><tbody><tr><td><ac:image><ri:attachment
ri:filename="' .. escape(src,true) .. '" /></ac:image></td></tr><tr><td>'
.. escape(caption) .. '</td></tr></tbody></table>', attr_cpy)
 end

+
+function Figure(caption, image, attr)
+    local figcaption = '<figcaption aria-hidden="true">' ..
+        caption .. "</figcaption>"
+    return "<figure>\n" .. image .. "\n" .. figcaption .. "\n" ..
"</figure>"
+end
+
+
 -- Caption is a string, aligns is an array of strings,
 -- widths is an array of floats, headers is an array of
 -- strings, rows is an array of arrays of strings.
@@ -411,4 +421,3 @@ meta.__index =
     return function() return "" end
   end
 setmetatable(_G, meta)
-

On Tue, 28 Nov 2023 at 17:31, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
wrote:

> The Figure element was added in 3.0: search
> https://pandoc.org/releases.html for "Support complex figures" for full
> details.
>
> So I think that your Confluence writer needs to be updated! I see that it
> has a CaptionedImage function and suspect that this will no longer be
> called, and that the needs-to-be-added Figure function will get called
> instead, but probably not with exactly the same arguments.
>
> Are you OK with hacking this? I don't mind having a go if not... let me
> know!
>
> On Tue, 28 Nov 2023 at 17:04, Klaus R. <k-rindfrey-Mmb7MZpHnFY@public.gmane.org> wrote:
>
>> Hi,
>>
>> To generate my documentation, I use a toolchain that generates a markdown
>> file from various sources, the last step is the generation of Confluence
>> HTML via Pandoc. Since Pandoc does not directly support Confluence HTML, I
>> use a patched version of
>> https://github.com/jpbarrette/pandoc-confluence-writer (patched because
>> the generated HTMl is not always quite correct and some features I need are
>> missing). This worked well for a long time, but after the last update (from
>> Pandoc 2.19.2 to 3.1.8) I got a series of warnings:
>>
>>
>>
>> *WARNING: Undefined function 'Figure'WARNING: Undefined function
>> 'Figure'...*
>>
>> and the HTML code for the images is completely missing. I tried Pandoc
>> 3.1.9, same result. Confusing: the Lua code of pandoc-confluence-writer
>> does not contain a call to a function named "Figure". Just to analyze the
>> problem, i tried custom-markdown.lua from
>> https://gist.github.com/tarleb/5a9c3fbfa47b0e6d3643efd8af2994b9 and i
>> got:
>>
>>
>> *Error running Lua:custom-markdown.lua:19: No function to convert Figure
>> (Block)*
>>
>> What's going on? Is this a bug in Pandoc? Is there a workaround?
>>
>> At the moment I will be using version 2.19.2, but I would like to be able
>> to upgrade to newer versions of Pandoc.
>>
>> Minimal example:
>>
>>
>>
>>
>>
>> *# ExampleJust an example.![Fancy example](img/mypic.png){scale=70}*
>>
>>
>> Regards,
>> Klaus
>>
>> --
>> 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/84b364a6-bbfe-4c9b-b825-d0f52557229fn%40googlegroups.com
>> <https://groups.google.com/d/msgid/pandoc-discuss/84b364a6-bbfe-4c9b-b825-d0f52557229fn%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/CAEe_xxjzpptPpYC9cAPP4GaSw32qmOA8d0KeV-8MsgyS8%3DQGMQ%40mail.gmail.com.

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

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

* Re: How to resolve "WARNING: Undefined function 'Figure'"? Is there a workaround?
       [not found]         ` <CAEe_xxjzpptPpYC9cAPP4GaSw32qmOA8d0KeV-8MsgyS8=QGMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-11-28 19:33           ` 'William Lupton' via pandoc-discuss
       [not found]             ` <CAEe_xxj2MwNy9-G21jAfSq15sA2OHMuBNFeVXTO4nvO7Sp_Wqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: 'William Lupton' via pandoc-discuss @ 2023-11-28 19:33 UTC (permalink / raw)
  To: pandoc-discuss

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

Oh sorry, I didn't use the CaptionedImage() code... but I'm sure you get
the idea.

On Tue, 28 Nov 2023, 18:14 William Lupton, <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
wrote:

> Something like this should work? The change to attributes() is a hack to
> use 'data-scale' rather than 'scale' and the change to Image() is to insert
> the alt text and the attributes. The main change is the new Figure()
> function (oops... I see that I'm ignoring its attributes).
>
> % git diff -w
> diff --git a/confluence.lua b/confluence.lua
> index 3057d10..1a7d8ef 100644
> --- a/confluence.lua
> +++ b/confluence.lua
> @@ -38,7 +38,9 @@ local function attributes(attr)
>    local attr_table = {}
>    for x,y in pairs(attr) do
>        if y and y ~= "" then
> -      table.insert(attr_table, ' ' .. x .. '="' .. escape(y,true) .. '"')
> +          local p = ""
> +          if x == "scale" then p = "data-" end
> +      table.insert(attr_table, ' ' .. p .. x .. '="' .. escape(y,true) ..
> '"')
>      end
>    end
>    return table.concat(attr_table)
> @@ -162,7 +164,7 @@ end
>
>  function Image(s, src, tit, attr)
>    return "<img src='" .. escape(src,true) .. "' title='" ..
> -         escape(tit,true) .. "'/>"
> +      escape(tit,true) .. "' alt='" .. s .. "'" .. attributes(attr)  ..
> "/>"
>  end
>
>  function Code(s, attr)
> @@ -330,6 +332,14 @@ function CaptionedImage(src, tit, caption, attr)
>     return Div('<table><tbody><tr><td><ac:image><ri:attachment
> ri:filename="' .. escape(src,true) .. '" /></ac:image></td></tr><tr><td>'
> .. escape(caption) .. '</td></tr></tbody></table>', attr_cpy)
>  end
>
> +
> +function Figure(caption, image, attr)
> +    local figcaption = '<figcaption aria-hidden="true">' ..
> +        caption .. "</figcaption>"
> +    return "<figure>\n" .. image .. "\n" .. figcaption .. "\n" ..
> "</figure>"
> +end
> +
> +
>  -- Caption is a string, aligns is an array of strings,
>  -- widths is an array of floats, headers is an array of
>  -- strings, rows is an array of arrays of strings.
> @@ -411,4 +421,3 @@ meta.__index =
>      return function() return "" end
>    end
>  setmetatable(_G, meta)
> -
>
> On Tue, 28 Nov 2023 at 17:31, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
> wrote:
>
>> The Figure element was added in 3.0: search
>> https://pandoc.org/releases.html for "Support complex figures" for full
>> details.
>>
>> So I think that your Confluence writer needs to be updated! I see that it
>> has a CaptionedImage function and suspect that this will no longer be
>> called, and that the needs-to-be-added Figure function will get called
>> instead, but probably not with exactly the same arguments.
>>
>> Are you OK with hacking this? I don't mind having a go if not... let me
>> know!
>>
>> On Tue, 28 Nov 2023 at 17:04, Klaus R. <k-rindfrey-Mmb7MZpHnFY@public.gmane.org> wrote:
>>
>>> Hi,
>>>
>>> To generate my documentation, I use a toolchain that generates a
>>> markdown file from various sources, the last step is the generation of
>>> Confluence HTML via Pandoc. Since Pandoc does not directly support
>>> Confluence HTML, I use a patched version of
>>> https://github.com/jpbarrette/pandoc-confluence-writer (patched because
>>> the generated HTMl is not always quite correct and some features I need are
>>> missing). This worked well for a long time, but after the last update (from
>>> Pandoc 2.19.2 to 3.1.8) I got a series of warnings:
>>>
>>>
>>>
>>> *WARNING: Undefined function 'Figure'WARNING: Undefined function
>>> 'Figure'...*
>>>
>>> and the HTML code for the images is completely missing. I tried Pandoc
>>> 3.1.9, same result. Confusing: the Lua code of pandoc-confluence-writer
>>> does not contain a call to a function named "Figure". Just to analyze the
>>> problem, i tried custom-markdown.lua from
>>> https://gist.github.com/tarleb/5a9c3fbfa47b0e6d3643efd8af2994b9 and i
>>> got:
>>>
>>>
>>> *Error running Lua:custom-markdown.lua:19: No function to convert Figure
>>> (Block)*
>>>
>>> What's going on? Is this a bug in Pandoc? Is there a workaround?
>>>
>>> At the moment I will be using version 2.19.2, but I would like to be
>>> able to upgrade to newer versions of Pandoc.
>>>
>>> Minimal example:
>>>
>>>
>>>
>>>
>>>
>>> *# ExampleJust an example.![Fancy example](img/mypic.png){scale=70}*
>>>
>>>
>>> Regards,
>>> Klaus
>>>
>>> --
>>> 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/84b364a6-bbfe-4c9b-b825-d0f52557229fn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/84b364a6-bbfe-4c9b-b825-d0f52557229fn%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/CAEe_xxj2MwNy9-G21jAfSq15sA2OHMuBNFeVXTO4nvO7Sp_Wqw%40mail.gmail.com.

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

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

* Aw: Re: How to resolve "WARNING: Undefined function 'Figure'"? Is there a workaround?
       [not found]             ` <CAEe_xxj2MwNy9-G21jAfSq15sA2OHMuBNFeVXTO4nvO7Sp_Wqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2023-11-29  6:42               ` Klaus Rindfrey
  0 siblings, 0 replies; 5+ messages in thread
From: Klaus Rindfrey @ 2023-11-29  6:42 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/html, Size: 10085 bytes --]

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

end of thread, other threads:[~2023-11-29  6:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-28 17:03 How to resolve "WARNING: Undefined function 'Figure'"? Is there a workaround? Klaus R.
     [not found] ` <84b364a6-bbfe-4c9b-b825-d0f52557229fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-11-28 17:31   ` 'William Lupton' via pandoc-discuss
     [not found]     ` <CAEe_xxg1bdy8nKFf1uY4NojPTxJgxTur-7Es5Y+rHMaXOtKeBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-28 18:14       ` 'William Lupton' via pandoc-discuss
     [not found]         ` <CAEe_xxjzpptPpYC9cAPP4GaSw32qmOA8d0KeV-8MsgyS8=QGMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-28 19:33           ` 'William Lupton' via pandoc-discuss
     [not found]             ` <CAEe_xxj2MwNy9-G21jAfSq15sA2OHMuBNFeVXTO4nvO7Sp_Wqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-11-29  6:42               ` Aw: " Klaus Rindfrey

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