From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/22811 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: Lua: print an AST value? Date: Sun, 26 May 2019 19:44:11 +0200 Message-ID: References: <29f97153-8af9-442b-8458-6bd5d219a4f8@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000043f28b0589cdfbb0" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="3758"; mail-complaints-to="usenet@blaine.gmane.org" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCWMVYEK54FRB5NAVPTQKGQESGCY2BY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun May 26 19:44:22 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-wr1-f64.google.com ([209.85.221.64]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hUxC2-0000t4-61 for gtp-pandoc-discuss@m.gmane.org; Sun, 26 May 2019 19:44:22 +0200 Original-Received: by mail-wr1-f64.google.com with SMTP id g1sf6955674wrw.20 for ; Sun, 26 May 2019 10:44:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1558892661; cv=pass; d=google.com; s=arc-20160816; b=H5BcYRUN+QQU/P3cZeDLWnWOtmEjbYq5sHO3zw0Hz4DtqBXpYIv0QONcOkN7zpwLxZ bbe5CdNiOQKheu7ow7/5DMFmxYew6K0hOzfOc+QSj4/gQn+rFtSk8GueCU5cYglYPyIn 7otbRVw7kCcQimPQFQVynZsKfEFPVcQsFHYbTNZV5dvOWr414Ui2aN4WkGLFHsym6CY3 Cg3UVf6k1zilYlyAz3JeHxydTAsEhtM9gxCle7Nr5qqEZqr4JjVQ15e471Z9pc1Efz4a bP56PriGDbzRqDdloVHAPmFnFS6Q9tS8RZh2xgA18yUt4Qcmlfrek6OxXqayKNK5XSQp zufQ== 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 :dkim-signature; bh=sa7fExPHd/GAj/TKRBhdvR3Wm0cm9TkpAhNEchZDNcw=; b=cRxRwYdb8uez2KyPBKDtUw+2puS2vbsyPv6IgqarPBA5e7/kg84XBz6VwfEGhQ8Qvm N6ALbbPjXZegA0TBTdmJXHrEQaaSEz/B8spqpG9QB/NEWej+lzf4XXcGfq8SMY38Ep0d RYamaGROb27VziH0ZznbJBUF0HxBJRkaEMUxCcFAow4eku8wlMm9+o6Gl8AdKk3VlA2s oEaHFGxtfIGfUqlaVKjMTsMPXAEYBya8TNvAksxoosWiX4Nm+oLnZdIPuwu1/kcwCvTH DQZbTNi8i9TijTsiuDeiqBTMHPxo01mGMLw7FVcSXTRoDKyvUaoase4WxbtNH+r9UIUk qTog== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GGzvXoYn; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; 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=sa7fExPHd/GAj/TKRBhdvR3Wm0cm9TkpAhNEchZDNcw=; b=L65fD2JwTXOX6NlRXNxbe44KTR3OTlKbaBxB0vjoYef9tEO9LoSILtuFOyt4a900US tQLaA9ShR4Qwq+0EmFKfBMReb1dAHjPwjNoJgofD0QYB7m1Gu/UGbveZVOTOKIUEB1tP 7aL5K/KZ/6nFlrUVEqY2hWMPZo8/WQCWxF9s7USszQBgI8nO6A7uwAM1wmPmxF1t+e+D 62IhLsdCQvK7yodj764rmYo2ncP/J0ja0a+whij58qziCJQc3m5hfKalsTAbUzUMPevv CTv+ASMc0f9y5E3/u8MNgvvTtzqKxADL5Ri4TK8EUROe8yAstCck1pONOf3XnYdawF2D TH4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=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=sa7fExPHd/GAj/TKRBhdvR3Wm0cm9TkpAhNEchZDNcw=; b=F48BwADQSp0TbKcsljXOeiGFi6CPh4S3BSJVctCNrD6Fn/oWg40bjzFZwQes6pqFiR E7+Np6vOeeMyE+X4fIvTO+/S3q66yTrfjqCz3nWFVEcWSvT4Ip/Wq/zipb9O8DrUY6C2 3svs6b6OAEQ/d7Eh/lJKtAfvhh/u0qGZrZngya2dqbbMYCgbwIsk3y+ZK6kfqpefA+Xf TQYYETqhyZkOH6DYsJ5yUK7yyQ91KOj3aXy1rgQIQjTHPxHCfJRJKpZy4tvTWTYGHBF4 Cl0OzqWdxZt6bK97lfH7sVe75dfMUq4QCdSCwsqbSI/S0dqiQ66plDIunCdVF3AyrtuL yEOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=sa7fExPHd/GAj/TKRBhdvR3Wm0cm9TkpAhNEchZDNcw=; b=Sdyg4NGWu6UBBTkmSGiZf1JG5WuMnjvCCwALtwRyBAaoqz6JBQi0PwfiG/N42PioLB UKEab9Tc7HdBWocrikqQeQJ/NzIyglDmTDo2q6gE4DMRrU2Pu4vaMt97aVzOl6IIz/+T wGrJ1hrBmOc+JQooihZjg2RIdwKPyVu3/GDplIqpobi56rznM2fruotkcLIi0ma+j1r7 AR42c9N5yMR7Jga6dRpSHaumHADxw6i97KhPYopyaVm66Iafjls28vlk0wFhnzuJoiBM asTSLl8pBnLtBcRocbLBscI8U1vHv4OaClS7MJyf12o9MV0dNB2W96rQ+QEmXVQGHi98 9WiQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAW42kx/UlX5T3og2/h4m3rPSQBTXnv7HqFRDJywfdsL4Q6juqo+ 6q7A3mFefUvET7g7dBqchrQ= X-Google-Smtp-Source: APXvYqxxh7RkT+8h79JamYhF52aytrPq4J+MA1tKN4+001W8G3S570zcealspkiLhae4P1BaWsvDMw== X-Received: by 2002:a1c:f910:: with SMTP id x16mr6739255wmh.132.1558892661672; Sun, 26 May 2019 10:44:21 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:adf:9d90:: with SMTP id p16ls641845wre.11.gmail; Sun, 26 May 2019 10:44:20 -0700 (PDT) X-Received: by 2002:adf:dc04:: with SMTP id t4mr22048345wri.126.1558892660922; Sun, 26 May 2019 10:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558892660; cv=none; d=google.com; s=arc-20160816; b=uXqxO0clqUN+VwWkADdyWTUW/UjjPXOQDTFza/XvFoInb7aW30dc34HDXr2DOa5j+L P5nj99UEvRFODbISV/nwgFZgbiR5I1e0m6mLCQcOcyRHAVBlIYnkO4XKJvcLiGcfy2vH 1xdgOiVPEfz6pG7XSN911GdvW/g0NmjzMcm5KK9pd9M5umdOun3U10NLmtT43RS785t2 CkQWF/rZcfO9GWJUp+ck8p0zQqWQZrHuxXDdbJLcUVnaHBmGaCU7o/7EpPoAn7zNes6/ 5i0JHFYHYvbv5sFUAKO7GdTv+gjCCcbPMSNUEtvFuv8AJqHO1xGe6bJJW1Gsfm1zXEwO xh+A== 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=S4FnvpWAyVn6vkpvu9m+9oz+9o+fKgUXCNZQ9cyOvFM=; b=YFkMDXP+N+zQeq5JM20MTRz9auMg9pxfLwywTEoGkozRQiqwIQxVxy7gundwk7jKXW PfdBgh35iZ9ulxbP66JBy+L3RqlzuFj43c7tSe7JfK3QCpYUbeDL6owkCcNJwdCzTk1E lis2sJHYPBuXuXtuRPakxD6JJJw5SQc7OVTpQktVCj/hDuHTD2EIBtYjeP8hqbcPJggj WgFrBjgZwCU5ksUnDZYTjEx22LlnTgSjSo1F1lXN8hPXXOwL/y2k2aPFNle2WFj11vtb NPI9T9faJnj6HsucMByGooGu94Z4Pz42OgzcEDC4MDsERk3kL6twmTzgLRRQoPW/xwVE OI5A== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GGzvXoYn; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com. [2a00:1450:4864:20::42f]) by gmr-mx.google.com with ESMTPS id h126si1056904wmf.2.2019.05.26.10.44.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 May 2019 10:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f as permitted sender) client-ip=2a00:1450:4864:20::42f; Original-Received: by mail-wr1-x42f.google.com with SMTP id d18so14614870wrs.5 for ; Sun, 26 May 2019 10:44:20 -0700 (PDT) X-Received: by 2002:adf:f704:: with SMTP id r4mr15400152wrp.27.1558892660386; Sun, 26 May 2019 10:44:20 -0700 (PDT) In-Reply-To: <29f97153-8af9-442b-8458-6bd5d219a4f8-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GGzvXoYn; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::42f as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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.org gmane.text.pandoc:22811 Archived-At: --00000000000043f28b0589cdfbb0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Have you tried `pandoc.utils.stringify()`? It doesn't include formatting but it's better than nothing. You could even write a small `pandoc.walk_*()` filter which inserts some basic "formatting" as literal strings like `*` around Emph and run it on an AST value before stringifying: ````lua local para =3D pandoc.Para({emph}) local insert_formatting =3D { Emph =3D function (elem) return { pandoc.Str('*'), elem, pandoc.Str('*'), } end } para =3D pandoc.walk_block(para, insert_formatting) local str =3D pandoc.stringify(para) ```` I agree that it would be good to have an API function to convert an AST element to markup, sort of `pandoc.read()` in reverse. Den s=C3=B6n 26 maj 2019 13:21Axel Rauschmayer skrev: > As an error message in a Lua filter, I=E2=80=99d like to print an AST val= ue in > some manner: > > - I found plans for outputting AST values to Markdown etc. That would > be the best solution, but it=E2=80=99s not ready yet. > https://groups.google.com/d/topic/pandoc-discuss/LM1l4z8xEhQ/discussio= n > - Alternatively, printing the AST would also do. E.g., it could look > like here: https://pandoc.org/try/ > > -- > 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/29f97153-8af9-442b-8458-= 6bd5d219a4f8%40googlegroups.com > > . > For more options, visit https://groups.google.com/d/optout. > --=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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/CADAJKhC5orrK2vS_ELxRJHgmD2UQk%2Btg-2AqamGMFzyKf74U5A%40mail= .gmail.com. For more options, visit https://groups.google.com/d/optout. --00000000000043f28b0589cdfbb0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Have you tried `pandoc.utils.stringify(= )`?

It doesn't inclu= de formatting but it's better than nothing. You could even write a smal= l `pandoc.walk_*()` filter which inserts some basic "formatting" = as literal strings like `*` around Emph and run it on an AST value before s= tringifying:

````lua
local para =3D pandoc.Para({emph})
local insert_formatting =3D {
=C2=A0 Emph =3D fun= ction (elem)
=C2=A0 =C2=A0 return {
=C2=A0 =C2=A0 =C2=A0 pandoc.Str('*'),
=C2=A0 =C2=A0 =C2=A0 elem,
=C2=A0 =C2=A0 =C2=A0 pan= doc.Str('*'),
=C2=A0 =C2=A0 }
=C2=A0 end
}
para = =3D pandoc.walk_block(para, insert_formatting)
local= str =3D pandoc.stringify(para)
````

I agree that it would be good to have= an API function to convert an AST element to markup, sort of `pandoc.read(= )` in reverse.

Den s=C3=B6n 26 maj 2019 13:21Axel Rauschmayer <rauschma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
As an error message in a = Lua filter, I=E2=80=99d like to print an AST value in some manner:

--
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 pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To post to this group, send email to pandoc-discuss@googlegrou= ps.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/29f97153-8af9= -442b-8458-6bd5d219a4f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://group= s.google.com/d/msgid/pandoc-discuss/CADAJKhC5orrK2vS_ELxRJHgmD2UQk%2Btg-2Aq= amGMFzyKf74U5A%40mail.gmail.com.
For more options, visit http= s://groups.google.com/d/optout.
--00000000000043f28b0589cdfbb0--