From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/27123 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Denis_Bitouz=C3=A9?= Newsgroups: gmane.text.pandoc Subject: Re: How to indent a block when exporting to reStructuredText Date: Thu, 03 Dec 2020 11:11:55 +0100 Message-ID: <87k0tzci6s.fsf@example.com> References: <875z5n7rsg.fsf@example.com> <87eekbjl2a.fsf@example.com> <877dq2iq4d.fsf@example.com> <871rg8fqo3.fsf@example.com> <0d1533ca-8cf8-4a50-8318-a770eaaf2d31n@googlegroups.com> <87360oduiq.fsf@example.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23141"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCGN3HPB5UNBB37TUL7AKGQEO6OGLNQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Dec 03 11:12:04 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f62.google.com ([209.85.167.62]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kklal-0005uS-Pf for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 03 Dec 2020 11:12:03 +0100 Original-Received: by mail-lf1-f62.google.com with SMTP id m12sf275850lfa.2 for ; Thu, 03 Dec 2020 02:12:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1606990323; cv=pass; d=google.com; s=arc-20160816; b=Ocnt3k6hLJgPSmml5p5+m4qLgfH3UyhfDYLS9jQAXEI3OE0lBkA98Y3ewcXzG1LQyE l+aHCQgnC987LA6hQmrclQhJX9Kj7ZmPs7Azd27uu9ZKg4yDCkvfbag39+B/RaSGpeYd j/Ls1Gsx+Z7EUSYmLvUWOtpm1KTLws5bgBgZOUqzAO4pLGpE5UfkCQrNXFMmrgTAKwlA acfch77jSGbUweybH7hhfRP7Nxdo5R50eleyJks+IO5/I9Nz/4qVMI9/GMll+rJxo1Iy oLxnuq8E6OQrOY2yIS/pzHQLYBXp08xFbb5H4MqucYAzGBwyUxWnWEbS2sBhySvNGfZ1 inDw== 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:content-transfer-encoding :mime-version:user-agent:message-id:in-reply-to:date:references :subject:to:from:dkim-filter:sender:dkim-signature; bh=b3kXglj1lh3savR1lQwurL8PBcIKsJIFEPc1exj9b2I=; b=apmukdY+O71+3JJP8z21Pnzy3EJMdJLtthKzGwBmAWSb8aLrk0u/g894DU71S10WrV 9sI0LjGozImwpV5/eEnWWNs7yXMIfe8huX+/j1mWJ6W1qnA5QewlancrywXfRkuAi3Y/ xcFJBh1cEJr5zY9IxwoxCjwvMrUA59imlBc9x6fWj9sXjO4pSUUG30jni84F+bmhE46p YISlfBe9fAIDBS0v89P3Y1E3KtNavSJY0eq+CAZG6i2g/b+ZZJLnpleylU3qvlc2LhLe EavSueT8yKjMk2LpBt4kjUE+CA0FCEWTqx1GHLbPhtMNFONpBpX/pVprFkTtH9/xabKF K36w== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@univ-littoral.fr header.s=08AB4CC0-EC74-11E6-899C-5B0ECAA5E567 header.b=T3jHn4HC; spf=pass (google.com: domain of denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org designates 195.220.130.147 as permitted sender) smtp.mailfrom=denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:dkim-filter:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding :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=b3kXglj1lh3savR1lQwurL8PBcIKsJIFEPc1exj9b2I=; b=F7x2IMPK/s0mXevywTMh1+0mQeq8RLfYQF/zmjnAJEz/w/JwwdgtFe9eM4YJQSzaA0 t6Tz5Bj895bSmm08/RE+U3BOu4jmDhbB2a/hXU372AG1qFEYfz4M8HcPQk1gYfQiJJNb qr4cOYpuldyaD3kWHzdTYX9O3TKC9bhetUNI5QJKftJDCz4PU6ythh5k25A2FwLZgncr e6FlaWO4jPorsAk+dDXCJMq2rFig71NzamLzy6SwHpfXcWF4Z+kHBj3HetwqC8gouRJF YYQpUL2JteItzCFQeB0OVE3y4YWkDQ52PQs3ZaVs0pCXcM4QdkrFClmdHJozTXtf+QYB FJ4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:dkim-filter:from:to:subject:references :date:in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding: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=b3kXglj1lh3savR1lQwurL8PBcIKsJIFEPc1exj9b2I=; b=PpkQbZBtfgI3Pnx7/B5A0oIGaUkvJhNDG9BBZIBjSuNlhhJblRll74VmUqr8qEJuU6 gBjYnv9Lh7P0phrVXNpr7PQPxZ5H+nXGSzARG9x064DvY2nJHw/TYMXiII5zsJP9bUMG 6yWr7NPqJulsFnw/0PBTMR7Cyv6CB0TQaFjyI1XUG+sxVCFtdNh3o3jG1Kh59D2wpDMD qyrw2GX4IYMKd/6644i9xpPzRWYk/63sZrT+OFnIkUyS0AYCVsbf1k074oUwPE6+ah13 baNP+2i/iwT2PBpK+2u4e1dJNChyF6avDMPczSRFr Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM5328wCoxKe+jNjG94vkronn+e2Ok1D6pkq5rm/nikeLLhKUTJ0DI N0rWsTPRqu6u8cWfL+3/LKg= X-Google-Smtp-Source: ABdhPJxPqSptySEYOKZDJgGUd/oU5Gt3yQeZX4KaZ9yOgZO80foaBys0lz3r8UARuzjOGTu8MZNUxw== X-Received: by 2002:a2e:948:: with SMTP id 69mr980969ljj.180.1606990323373; Thu, 03 Dec 2020 02:12:03 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:ac2:5a02:: with SMTP id q2ls53970lfn.1.gmail; Thu, 03 Dec 2020 02:11:58 -0800 (PST) X-Received: by 2002:ac2:4ac7:: with SMTP id m7mr928353lfp.513.1606990318250; Thu, 03 Dec 2020 02:11:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606990318; cv=none; d=google.com; s=arc-20160816; b=QEbRu+V7MwsPUvskXnQf6xhjNjcdmh8lUtQQJozX5Btrbb/vVcTUz7kdIwl4Dnuo0a Ioe+5RviWbVRb3GiAAFeotoKmp5o2aDM//VDzqK3LKNHi5SdpaG0859Yel5zBRxQ+OM+ 3YVwrFvpOb5P349pQMokr9dtPR44mb5LsTu3+2BzcvxeNfZzqdaye5Rxz/kHmVUOCH5o XPYq2650/HSS3ekNdGE3W34tRlM7VQd4ilSJdP6cbBL+Z/fsl/XCpIdmoJxYt80bk9wS 9nkUddXgxoAQvAe/bDxK/LvBFIlh4uHqordLfeeYtbORIq/60WZsXp5iDzU61rTuekk2 vLcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:to:from:dkim-signature :dkim-filter; bh=PcXINXSFY37EXGhkCsLeL8O74b6KAXjqKAmirLSL4V0=; b=jQC+Uqo5KW0EVhAbjCgQoJ3Gf3+BBgnBSjgA9x+a5ixCmup1g3QHB3MFNrnXs8TN9f JHiMSBf+BXBq539xul11tqR4VshBQxaKBN9JeWjmnhDHjpcKVvKD+997S+ff5y0cpxgL 0E6sdaE8OF6livb9WKRuyLDCpMBfT3Ml4KDjqmXqngnxZBQ2k8FHDb13zyxnKctgBMO+ POMbsHcJ2mQ4QqA1EFTaeoZIMKXldMpWgN+knMQOu/SPo5chYWGnU1mRkLds6pIlzgQN NBAzgUzGU4hpsOjlnPKxqYPOyj++2BERytTbTBnBcDTFdc9xLLwGJQj+usTeemYu+0vg s0jg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@univ-littoral.fr header.s=08AB4CC0-EC74-11E6-899C-5B0ECAA5E567 header.b=T3jHn4HC; spf=pass (google.com: domain of denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org designates 195.220.130.147 as permitted sender) smtp.mailfrom=denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org Original-Received: from zmmta1.univ-littoral.fr (zmmta1.univ-littoral.fr. [195.220.130.147]) by gmr-mx.google.com with ESMTPS id h19si29272ljh.7.2020.12.03.02.11.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2020 02:11:58 -0800 (PST) Received-SPF: pass (google.com: domain of denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org designates 195.220.130.147 as permitted sender) client-ip=195.220.130.147; Original-Received: from localhost (localhost [127.0.0.1]) by zmmta1.univ-littoral.fr (Postfix) with ESMTP id 9B1ED1352AE for ; Thu, 3 Dec 2020 11:11:57 +0100 (CET) Original-Received: from zmmta1.univ-littoral.fr ([127.0.0.1]) by localhost (zmmta1.univ-littoral.fr [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id DBiaOj2sOlvK for ; Thu, 3 Dec 2020 11:11:57 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zmmta1.univ-littoral.fr (Postfix) with ESMTP id 3BB71135D77 for ; Thu, 3 Dec 2020 11:11:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.9.2 zmmta1.univ-littoral.fr 3BB71135D77 X-Virus-Scanned: amavisd-new at Original-Received: from zmmta1.univ-littoral.fr ([127.0.0.1]) by localhost (zmmta1.univ-littoral.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 59RWrEMMeQLT for ; Thu, 3 Dec 2020 11:11:57 +0100 (CET) Original-Received: from drums-bis (176-135-84-20.abo.bbox.fr [176.135.84.20]) by zmmta1.univ-littoral.fr (Postfix) with ESMTPSA id 0C1421352AE for ; Thu, 3 Dec 2020 11:11:56 +0100 (CET) X-Url: http://gte.univ-littoral.fr/members/dbitouze/pub/latex X-Archive: encrypt In-Reply-To: (ebkysko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org's message of "Wed, 2 Dec 2020 11:15:15 -0800 (PST)") X-Original-Sender: denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@univ-littoral.fr header.s=08AB4CC0-EC74-11E6-899C-5B0ECAA5E567 header.b=T3jHn4HC; spf=pass (google.com: domain of denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org designates 195.220.130.147 as permitted sender) smtp.mailfrom=denis.bitouze-PToOLB6qFnLddoiwg0DPyg@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:27123 Archived-At: Le 02/12/20 =C3=A0 11h15, EBkysko a =C3=A9crit : >> still returns the same error message > > because you left the `=3D {}` later in the code. > for now, perhaps it might be better for you to use Lua's usual > `table.insert(note,...)` notation etc. rather than using `List` and > `:insert` notation... one step at a time... OK. I still locally initialize `note` and `contents` with `pandoc.List()`. >> If I understand well, it should then be... > > A good beginning. Actually, `block.c[1]` will be the first `Inline`, whic= h > is a `pandoc` element... It's not literally a string, it is an element of > type `Str`... see the nuance? > See jm's answer. Seen, and useful :) > As for ``, as I said in my correction, it would be the last item, > i.e. `block.c[#block.c]`, which is more adequate if `Para` has more than > one `Inline` in its list. OK, done. >> Unfortunately, I don't see what to do > > If you look at the code, it discards the `block` when '' is found f= or > example. Because of the line `note =3D {}` (that I replaced by `note =3D pandoc.List= ()`) > So you'd lose all that paragraph. Indeed, the resulting `test.rst` is empty, even with the line `note =3D pandoc.List()` is commented :$ > For a more complex situation, like when the native output gives `Para [St= r > "", SoftBreak, Str "Foo"]`, you need to discard '' and > 'SoftBreak' from the list, but keep 'Foo'. OK. > In general, you would *remove* the first item from the table `block.c`; > after this, you can check if the *new* first item is really 'SoftBreak', > and *remove* it also if true. OK, I tried to generalize this in case there are other `SoftBreak`. > You would then be left with a table containing only the rest of the para > items, i.e. the `Para` without the '' (and possibly without the > 'SoftBreak'). > This modified `Para` block should then be inserted in the new `note` tabl= e. > Do similarly in the end for '', but removing the last item(s) of t= he > `Para` list of `Inline`s. > > I'll let you translate this into code! Here is my attempt to do that but, unfortunately, it still gives an empty resulting `test.rst` file: --8<---------------cut here---------------start------------->8--- function isNoteStart(block) return block.t =3D=3D 'Para' and block.c[1].t =3D=3D 'Str' and block.c[1= ].text =3D=3D "" end function isNoteEnd(block) return block.t =3D=3D 'Para' and block.c[#block.c].t =3D=3D 'Str' and bl= ock.c[#block.c].text =3D=3D "" end function Pandoc(el) local inNote =3D false local contents =3D pandoc.List() local note =3D pandoc.List() for _,block in ipairs(el.blocks) do if isNoteEnd(block) then table.remove(block.c, #block.c) inNote =3D false -- contents:insert(pandoc.Div(note, pandoc.Attr("",{"note"}))) table.insert(contents,pandoc.Div(note, pandoc.Attr("",{"note"}))) elseif isNoteStart(block) then inNote =3D true -- note =3D pandoc.List() table.remove(block.c, 1) for i=3D1,#block.c-1 do if block.c[i].t =3D=3D 'SoftBreak' then table.remove(block.c, 1) end end elseif inNote then -- note:insert(block) table.insert(note,block) else -- contents:insert(block) table.insert(contents,block) end end el.blocks =3D contents return pandoc.Pandoc(el) end --8<---------------cut here---------------end--------------->8--- >> Not sure to understand (about pandoc constructor) > > In the end, you want to create a new pandoc document with the new modifie= d > content, and for this you use `pandoc.Pandoc` constructor/creator. > You will have filled the `content` table with a list of pandoc `Block` > elements, which is what `pandoc.Pandoc` takes as first argument. I understand better now :) Many thanks again! --=20 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/87k0tzci6s.fsf%40example.com.