* Lua filter documentation errors? @ 2019-10-24 19:35 ChrisD [not found] ` <193ee2fd-7b82-6176-5cfd-353353816019-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org> 0 siblings, 1 reply; 2+ messages in thread From: ChrisD @ 2019-10-24 19:35 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw I have been playing with lua filters, and I have a few corrections to the lua-filters page in the documentation. Nothing urgent, just figured I would pass these along... 1) The example for mediabag.fetch (https://pandoc.org/lua-filters.html#mediabag-fetch) is incorrect. Fetch returns two values. The second line should read: local mt, contents = pandoc.mediabag.fetch(diagram_url, ".") 2) In the mediabag list example usage (https://pandoc.org/lua-filters.html#mediabag-list), the for statement is incorrect. It needs a "do", and the colon should be removed. 3) The docs on mediabag (https://pandoc.org/lua-filters.html#module-pandoc.mediabag) say that "The media bag is used when pandoc is called with the --extract-media or --standalone option." The media bag appears to be populated only when --extract-media is used, and not if --standalone is used without --extract-media. 4) The example for replacing placeholders with metadata values (https://pandoc.org/lua-filters.html#replacing-placeholders-with-their-metadata-value) fails if the metadata includes boolean values. For example, if your YAML includes a line such as: toc: true The code will fail with the error "attempt to index a boolean value". That's because boolean values are stored in the metadata table as MetaBools, which are lua booleans, not tables, and the "v.t" will fail. I believe this code will also fail if the metadata table contained a MetaString, though I do not know how to get a MetaString into the meta table; strings seem to be represented as MetaInlines. The code should check for MetaBools and MetaStrings, or check that (type(v) == "table"). -- 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/193ee2fd-7b82-6176-5cfd-353353816019%40intielectronics.com. ^ permalink raw reply [flat|nested] 2+ messages in thread
[parent not found: <193ee2fd-7b82-6176-5cfd-353353816019-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org>]
* Re: Lua filter documentation errors? [not found] ` <193ee2fd-7b82-6176-5cfd-353353816019-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org> @ 2019-10-25 5:18 ` John MacFarlane 0 siblings, 0 replies; 2+ messages in thread From: John MacFarlane @ 2019-10-25 5:18 UTC (permalink / raw) To: ChrisD, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw Thanks a lot. I've added an issue on the tracker: https://github.com/jgm/pandoc/issues/5851 ChrisD <cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org> writes: > I have been playing with lua filters, and I have a few corrections to the lua-filters page in the documentation. Nothing urgent, just figured I would pass these along... > > 1) The example for mediabag.fetch (https://pandoc.org/lua-filters.html#mediabag-fetch) is incorrect. Fetch returns two values. The second line should read: > > local mt, contents = pandoc.mediabag.fetch(diagram_url, ".") > > 2) In the mediabag list example usage (https://pandoc.org/lua-filters.html#mediabag-list), the for statement is incorrect. It needs a "do", and the colon should be removed. > > 3) The docs on mediabag (https://pandoc.org/lua-filters.html#module-pandoc.mediabag) say that "The media bag is used when pandoc is called with the --extract-media or --standalone option." > > The media bag appears to be populated only when --extract-media is used, and not if --standalone is used without --extract-media. > > 4) The example for replacing placeholders with metadata values (https://pandoc.org/lua-filters.html#replacing-placeholders-with-their-metadata-value) fails if the metadata includes boolean values. > > For example, if your YAML includes a line such as: > toc: true > > The code will fail with the error "attempt to index a boolean value". That's because boolean values are stored in the metadata table as MetaBools, which are lua booleans, not tables, and the "v.t" will fail. I believe this code will also fail if the metadata table contained a MetaString, though I do not know how to get a MetaString into the meta table; strings seem to be represented as MetaInlines. The code should check for MetaBools and MetaStrings, or check that (type(v) == "table"). > > > > > > > -- > 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/193ee2fd-7b82-6176-5cfd-353353816019%40intielectronics.com. -- 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/m25zkds8qt.fsf%40johnmacfarlane.net. ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-25 5:18 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-10-24 19:35 Lua filter documentation errors? ChrisD [not found] ` <193ee2fd-7b82-6176-5cfd-353353816019-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org> 2019-10-25 5:18 ` John MacFarlane
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).