From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31005 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: William Lupton Newsgroups: gmane.text.pandoc Subject: Re: Printing lua tables Date: Mon, 18 Jul 2022 09:46:13 +0100 Message-ID: References: <551a3f2a8d364717bcc569baa974573a@unibe.ch> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000016eaa105e4106773" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17956"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCS4HJ6WSAHBBYN32SLAMGQEOJHC3KY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Jul 18 10:46:29 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ua1-f64.google.com ([209.85.222.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oDMOa-0004UE-TK for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 18 Jul 2022 10:46:29 +0200 Original-Received: by mail-ua1-f64.google.com with SMTP id c45-20020ab01470000000b0038361e2d746sf5361485uae.15 for ; Mon, 18 Jul 2022 01:46:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658133987; cv=pass; d=google.com; s=arc-20160816; b=VPV5hrWg15ajcISwlLsYSqmHy+OTyLJ0ytGKUvVZktutZZqj1DjZSmcQaygvg2nA3W GrwcbL+WOFaRX65MtPQxehPMAGvXqXu0DM1WFdB4p05bipkk4v4Y3Ku12dSGRAzpP+TR yyUo/rXCRlGpPBZNSPuY381v5VLiReQngCdgUwhm44V3Ns+UQfhMR313Rl+WtaIxEuam 1XqApM9/6zPruWIDSGGpptqNSdFvTyeSYZ5Aswfx515mRXXxUJjnxl5iW/XIdip9QH9R GMW7tH0jrNZ4SSjE9mHjGwQgBCcuMCEP0sbejza855dIbI3evmGnl02pumSztpMQVkrQ NtYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature; bh=z6bDn2Jgft9rWBuVFDx3Q+jF7kZjjQOSR8ay8KxlnQQ=; b=km7inOP1abBvB83ceCdYW/Iway4HSGa4bK33AK3R7osn4VfT78ltL4Py6v2ta6TDE1 DkK5LZpMNVVBsRjOEVZc6gsIl0RvNE30+6z2cHOrCEGgY08g20EXWTwoXprr9xa7wDuv wIMKVlzhYohqlofkM/l+PBowtX0n5DIW68dfUQNE0B4n4iK5Nyx5DIs8Q/KdrUs2noM2 IoceNanqushaFS0PZUUab51SjO8O5Tpb1ocIXWZd7hVNtvWerKkO1EzZOFVNiFIngwav bLh/bZlnsms7jb9FKl1FohiCMBsuUlg0EqbeD19dwtLO+B0i84vF3M7yrgaxqQpSqp5I pu0Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20210112.gappssmtp.com header.s=20210112 header.b="ZQ0JCbe/"; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::b2e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject:to:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=z6bDn2Jgft9rWBuVFDx3Q+jF7kZjjQOSR8ay8KxlnQQ=; b=DagtPE4v4Sp5v3U9T4jWU2nZSIDyaCRx1BeJDuO4GIywZY+CuZpwW7EC4f7QL8Q+jG D3axjlbigg9jtzCvwq7aZjGC/1GPJXmxMRcw37DBTuLD3LdYOWnk+/Nq01BjLZAMuu3R y8scBt5NPqkWURyEFUFLLHgX4xC8ImUKYbSmvIW4/52edvY8mLmXggDa0iP/NteCpP3d N5nsqpsQsn7SzzcVq2e+TJJitu4fe/Twz7LUefkU5ptYXnopii/1yVNTpBnjc7Zbmjx7 x8J6az+vqDPCCYfVDkV9mxLpc2WU+SdYMh54XuVH8Hto4k1lSh9Ylo6XC8ibIwpP+NCz tRrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=z6bDn2Jgft9rWBuVFDx3Q+jF7kZjjQOSR8ay8KxlnQQ=; b=hpTaVDMQCK3ww+ud3gBFnN35CsWnl9Z/JL09FdfyY7fWhcZpJotDl9VY525jkOiBic JwdFGkxM7YlO0V3Vphn2dhbbN7MuICpY33JbmYAQLPDI1RNlfMz94P2uW3gYvYZ6sVgr NbNznfaSYgpXAFddMkDE7eWvg3w9Lhu8FAgv8/bxcO7LiLlMboAGsUb7OVAn1N6FsKhe pIONL1GkqdOBhE/RGcPWn7gKqVN6vevWiv4g4XBDKr1tysgFZAVsCqF4kQx2M/a7r0TO UnrSUtYU6z0fDeR+c4DiHI8+V3MY66yrqmqxGp3gAHuc/VIXCNpE5B/ol2BabR+Z0ohq CRlA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora9BiIBlaqX4WTWpGl7k+VgLg1Sgl2dnTiZAAmKkkeM0r47vSKWA QN9rTHGbYAJvD6H3opwlR1E= X-Google-Smtp-Source: AGRyM1vgAYZfdj35rOUvb4NWhOdbI33VRrxjGpAwuzqqDSd4DfAc8uN19nReQjE8oEKiPLItmCaRGg== X-Received: by 2002:ab0:6011:0:b0:382:9522:a1ff with SMTP id j17-20020ab06011000000b003829522a1ffmr8849581ual.76.1658133987832; Mon, 18 Jul 2022 01:46:27 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a67:a407:0:b0:356:5325:e003 with SMTP id n7-20020a67a407000000b003565325e003ls1210441vse.3.-pod-prod-gmail; Mon, 18 Jul 2022 01:46:24 -0700 (PDT) X-Received: by 2002:a67:3c3:0:b0:357:5ad6:ceed with SMTP id 186-20020a6703c3000000b003575ad6ceedmr8369850vsd.52.1658133984371; Mon, 18 Jul 2022 01:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658133984; cv=none; d=google.com; s=arc-20160816; b=MIuJpmHbQB6u4VKSPmA7igkQeXEJW7wqxyLR3Y2dRzd/D5Wkl1+0Bgno8jHPcV2ELZ UUzxlOhjNbCkd4PCAg5m2d/+7NYewpBYoAMVSTcYounioniCWHlAvEMxWqQ5/LFGCeMn BPjITEfkC4SNnOaMNKNH2MF1HRT3Y7QKvpSrKBMM/17lsKsaiiIKhCpXNDnjT+6xfzgy 1Uee4/xeWHBiNG5CTFeSLgyPqjUyUXsWBZLC58Rm8I++W5kO4AxYVtBF8dr8+u1WWEx1 53ZtNnrr/HxWz7CqgcPexguzSEkMuphM2wH1ivPLZq8Piv/kFtN8EdpnkXiWA3IX67Hc bgmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=WTTGYC1nY7fB8Br0BGx4yB+5vLirdcAK+T6xcwg6w50=; b=HHGo1o53SQ4ZSP/X1mDU+hBLU6BPQyBWsWSpwtPpTUXhhy50W6X3C/kAxzqPMV839s qItUUKKa5j08NrrUoHbv/oD/jddtkJlh4W7U4FAgAmr09TKsdLpmqISrMeI42ixjqgBI V6N12pzVePKFbsolt9XuQZE351ju4ybBMHPyvt0u8h0adXXElfQ8ZgDl4u/CJLViBJZY /dG71La6S/+RCzoQ3ZaRdFNGHZMzXT3FESqIQvtq6fzNsLpPm8a35i08OIH9lsGhc5vt bWbTFv8stTrpk0nsRLGGW2luF+h5wIQKCt3yDiMpTa9ggvN4U95QILMj0a6c2rXN8Mm/ mfPw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20210112.gappssmtp.com header.s=20210112 header.b="ZQ0JCbe/"; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::b2e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org Original-Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com. [2607:f8b0:4864:20::b2e]) by gmr-mx.google.com with ESMTPS id 132-20020a1f188a000000b003700a12ecbcsi554390vky.5.2022.07.18.01.46.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Jul 2022 01:46:24 -0700 (PDT) Received-SPF: pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::b2e as permitted sender) client-ip=2607:f8b0:4864:20::b2e; Original-Received: by mail-yb1-xb2e.google.com with SMTP id n74so19624513yba.3 for ; Mon, 18 Jul 2022 01:46:24 -0700 (PDT) X-Received: by 2002:a25:9947:0:b0:663:ec43:61eb with SMTP id n7-20020a259947000000b00663ec4361ebmr26277781ybo.115.1658133983710; Mon, 18 Jul 2022 01:46:23 -0700 (PDT) In-Reply-To: X-Original-Sender: wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20210112.gappssmtp.com header.s=20210112 header.b="ZQ0JCbe/"; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::b2e as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:31005 Archived-At: --00000000000016eaa105e4106773 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable All, Here's a shameless plug to let everyone know that these pandoc-aware logging functions are now available at https://github.com/wlupton/pandoc-lua-logging and will soon be referenced from https://pandoc.org/lua-filters.html#debugging-lua-filters. Things have moved on a bit since I sent the message below. Please do take a look; I hope that people will find them useful. All feedback is welcome. Thanks, William PS, These functions work with (at least) pandoc 2.16.1 and 2.18. On Thu, 23 Jun 2022 at 13:25, William Lupton wrote: > I've created https://github.com/jgm/pandoc/issues/8146 to continue this > discussion. > > On Tue, 7 Jun 2022 at 16:24, William Lupton > wrote: > >> All, >> >> I've split this out into two functions (each currently in its own >> [attached as .lua.txt] file): >> >> - dump(value, maxlen=3D70) that returns a possibly multi-line string >> representation of a value >> - output(...) that's a utility function that outputs space-separated >> arguments, each passed to dump() and with a terminating newline if ne= eded >> >> Here's an updated example filter (it uses output() and doesn't call >> dump() directly): >> >> local output =3D require 'output' >> function Pandoc(doc) >> output('meta', doc.meta) >> output('blocks', doc.blocks) >> end >> >> Please feel free to do whatever you like with these functions. >> >> In my environment I have an additional layer in which I derive a >> log-level from PANDOC_STATE.{trace,verbosity} and use this in a set of >> logging functions like this one (*please let me know if you'd like me to >> supply these too*): >> >> function error(...) >> if logLevel >=3D -1 then >> output('(E)', ...) >> end >> end >> >> Cheers, >> William >> >> On Tue, 7 Jun 2022 at 15:13, William Lupton >> wrote: >> >>> I'll need to extract the reporting functions. I'll do that soon, and >>> post the result. This is currently working in pandoc 2.16.1 (and earlie= r). >>> I haven't yet bitten the bullet of the move to 2.18. >>> >>> On Tue, 7 Jun 2022 at 14:55, John MacFarlane wrote: >>> >>>> >>>> That looks nice. Can you share your utils.lua? >>>> >>>> William Lupton writes: >>>> >>>> > I think I've mentioned this before... but I'd be happy to contribute >>>> (in a >>>> > suitable form) the somewhat-pandoc-aware utility that I use for this= . >>>> > >>>> > Given this input: >>>> > >>>> > *% *cat doc.md >>>> > >>>> > --- >>>> > >>>> > a: 1 >>>> > >>>> > b: | >>>> > >>>> > 2 3 4 >>>> > >>>> > --- >>>> > >>>> > >>>> > # Header >>>> > >>>> > >>>> > This is a sentence (and a paragraph). >>>> > >>>> > >>>> > * This is a list item >>>> > >>>> > * And another >>>> > >>>> > >>>> > | Right | Left | Default | Center | >>>> > >>>> > |------:|:-----|---------|:------:| >>>> > >>>> > | 12 | 12 | 12 | 12 | >>>> > >>>> > | 123 | 123 | 123 | 123 | >>>> > >>>> > | 1 | 1 | 1 | 1 | >>>> > >>>> > >>>> > : Demonstration of pipe table syntax. >>>> > >>>> > and this filter: >>>> > >>>> > *% *cat rep.lua >>>> > >>>> > local utils =3D require 'utils' >>>> > >>>> > >>>> > -- do it this way to avoid reporting MetaBlocks twice >>>> > >>>> > function Pandoc(doc) >>>> > >>>> > utils.temp('meta', doc.meta) >>>> > >>>> > utils.temp('blocks', doc.blocks) >>>> > >>>> > end >>>> > >>>> > this command: >>>> > >>>> > pandoc doc.md -L rep.lua >/dev/null 2>doc.txt >>>> > >>>> > generates the attached. >>>> > >>>> > On Tue, 7 Jun 2022 at 08:57, wrote: >>>> > >>>> >> Hi, >>>> >> >>>> >> When playing around with filters I use pprint.lua or inspect.lua to >>>> >> visualize lua tables. Would it make sense to include some sort of >>>> =C2=ABprint >>>> >> the contents of this table=C2=BB to pandoc ? >>>> >> >>>> >> Best, >>>> >> >>>> >> Denis >>>> >> >>>> >> -- >>>> >>> --=20 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 e= mail 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_xxhWAxdJJ5LYj0QXoLTfUSpREBqDwxiUfPFoMB8GQNrdJA%40mail.g= mail.com. --00000000000016eaa105e4106773 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
All,

Here's a shameless = plug to let everyone know that these pandoc-aware logging functions are now= available at=C2=A0https://github.com/wlupton/pandoc-lua-logging and will soon be refere= nced from https://pandoc.org/lua-filters.html#debugging-lua-filters.

Things have moved on a bit since I sent the message below= . Please do take a look; I hope that people will find them useful. All feed= back is welcome.

Thanks,
William

PS, These functions work with (at least) pandoc 2.16.1 an= d 2.18.

On Thu, 23 Jun 2022 at 13:25, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> wrote:
<= /div>
I&#= 39;ve created=C2=A0https://github.com/jgm/pandoc/issues/8146 to continue t= his discussion.

On Tue, 7 Jun 2022 at 16:24, William Lupton <wlupton@broadband-for= um.org> wrote:
All,

I'= ;ve split this out into two functions (each currently in its own [attached = as .lua.txt] file):
  • dump(value, maxlen= =3D70) that returns a possibly multi-line string representation of a= value
  • output(...) that's a uti= lity function that outputs space-separated arguments, each passed to dump()= and with a terminating newline if needed
Here's an updat= ed example filter (it uses output() and doe= sn't call dump() directly):
<= br>
local output =3D require 'output= '
function Pandoc(doc)
=C2=A0 =C2=A0 output('meta', doc.m= eta)
=C2=A0 =C2=A0 output('blocks', doc.blocks)
end

Please feel free to do whatever you like with these functi= ons.

In my environment I have an additional= layer in which I derive a log-level from PANDOC_S= TATE.{trace,verbosity} and use this in a set of logging functions li= ke this one (please let me know if you'd like me to supply these too= ):

function err= or(...)
=C2=A0 =C2=A0 if logLevel >=3D -1 then
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 output('(E)', ...)
=C2=A0 =C2=A0 end
end

Cheers,
William

On Tue, 7 Jun 2022 at 1= 5:13, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> wrote:
I'll need to= extract the reporting functions. I'll do that soon, and post the resul= t. This is currently working in pandoc 2.16.1 (and earlier). I haven't = yet bitten the bullet of the move to 2.18.

On Tue, 7 Jun 2022 at 14:55, John= MacFarlane <jgm@b= erkeley.edu> wrote:

That looks nice.=C2=A0 Can you share your utils.lua?

William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> writes:

> I think I've mentioned this before... but I'd be happy to cont= ribute (in a
> suitable form) the somewhat-pandoc-aware utility that I use for this.<= br> >
> Given this input:
>
> *% *cat doc.md
>
> ---
>
> a: 1
>
> b: |
>
>=C2=A0 =C2=A02 3 4
>
> ---
>
>
> # Header
>
>
> This is a sentence (and a paragraph).
>
>
> * This is a list item
>
> * And another
>
>
> | Right | Left | Default | Center |
>
> |------:|:-----|---------|:------:|
>
> |=C2=A0 =C2=A012=C2=A0 |=C2=A0 12=C2=A0 |=C2=A0 =C2=A0 12=C2=A0 =C2=A0= |=C2=A0 =C2=A0 12=C2=A0 |
>
> |=C2=A0 123=C2=A0 |=C2=A0 123 |=C2=A0 =C2=A0123=C2=A0 =C2=A0|=C2=A0 = =C2=A0123=C2=A0 |
>
> |=C2=A0 =C2=A0 1=C2=A0 |=C2=A0 =C2=A0 1 |=C2=A0 =C2=A0 =C2=A01=C2=A0 = =C2=A0|=C2=A0 =C2=A0 =C2=A01=C2=A0 |
>
>
> : Demonstration of pipe table syntax.
>
> and this filter:
>
> *% *cat rep.lua
>
> local utils =3D require 'utils'
>
>
> -- do it this way to avoid reporting MetaBlocks twice
>
> function Pandoc(doc)
>
>=C2=A0 =C2=A0 =C2=A0utils.temp('meta', doc.meta)
>
>=C2=A0 =C2=A0 =C2=A0utils.temp('blocks', doc.blocks)
>
> end
>
> this command:
>
> pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
>
> generates the attached.
>
> On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
>
>> Hi,
>>
>> When playing around with filters I use pprint.lua or inspect.lua t= o
>> visualize lua tables. Would it make sense to include some sort of = =C2=ABprint
>> the contents of this table=C2=BB to pandoc ?
>>
>> Best,
>>
>> Denis
>>
>> --

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.= google.com/d/msgid/pandoc-discuss/CAEe_xxhWAxdJJ5LYj0QXoLTfUSpREBqDwxiUfPFo= MB8GQNrdJA%40mail.gmail.com.
--00000000000016eaa105e4106773--