From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/27112 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: EBkysko Newsgroups: gmane.text.pandoc Subject: Re: How to indent a block when exporting to reStructuredText Date: Wed, 2 Dec 2020 11:15:15 -0800 (PST) Message-ID: 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: multipart/mixed; boundary="----=_Part_9616_1056171400.1606936515596" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36849"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDW4B3GJ2UFBBR6PT77AKGQEJZ2C56Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Dec 02 20:15:23 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f55.google.com ([209.85.210.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kkXb0-0009Tz-SQ for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 02 Dec 2020 20:15:22 +0100 Original-Received: by mail-ot1-f55.google.com with SMTP id 36sf1425745otu.11 for ; Wed, 02 Dec 2020 11:15:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=lnAfgJdnw7a66XzJqUZSs0CP69UDYnAb2jMvqGT6A44=; b=UA18F2FPZrLq2mEbLIthxzdJMlEhWyw5Wfh5kt3jk/NdUc6QZXCaX+EqaX+HbDrr3b IGo0sn73whG5yEJ4hp2ondZrG87rHXsT6yoS+lQixjziYoQiOW0z/98IZcq89ot93pug 0geDX39OkjMKEZVF2RNIHCYuZYA7gy053oGOrl1Vb6wZSKDx0NxcM5xoy6wu2nDSY5mB KlbDx5wyCGavw/vUX9av7+pxOfrk6izXCUdGbesz9vW9kXx3fH8yucBzXqrk4k2TOJV2 13PEyQ9VPHtRTEJl43MROVfe/2OiFhs5LqUEGKreGfMb9D2IwsjItrJw6SdXnfow5Sw1 86eA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=lnAfgJdnw7a66XzJqUZSs0CP69UDYnAb2jMvqGT6A44=; b=D94MBUUHyiHuRqeC4tbPVyk5tyRuNbXegAI4dQIiyopUwUA7MMLsUAURcHQ+LrFfdQ ua2SFqwsssOisYBJgfz1oNehhuJ8vU7pz2UgnAXzxaDnSWLgrJ7r05tdN3mUTat3oIN4 teIhuqrwQ5DN1SkWy+gn6b9ARslVEWPqTqylWJFxSDH9Ov/HTsdn6xxpPuoBi2ORV/MQ MilQNxCiE+ZJCLk6AwFCP0tSRbuJgbhM9Tpf85apMbhi0MyZy+RdJO+44BEcyNRcHiZk luQ6xJi2NiUGbgUs07PiLfKsNY2LmI50sDjnB3nfEX8Eaty72DOfItj6SuiPyUe88A2F AnlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=lnAfgJdnw7a66XzJqUZSs0CP69UDYnAb2jMvqGT6A44=; b=SCjfIZX9l3z2S3PC0MoI96vbYHEODFpBMAx2cX/kdRWV6cDplgAA2VAh2Ww8CtWeOG jXBp0kaLETa+pU6Eyy8XurLOreNdzZVN06YldqL6D1fVloHo2Xq3YcqhvxGoDcp1ueiP hk60iPZAoYeO8exntXTXEaZ44oPu56lqQ55jK0oX6AzwopaDzKKrWLZz/Ylvr9QSTquq TGx/HumkX9ZHsUdiAYxuok3XbWi60I0YDoQr7LweWDCC1Fl8xnVNZqudcmazqFO7XE/6 PIg7liLHlHMxzJieyfG0ghIhnFuBCPQypw0P9nPY62U2lIIPOX1AGXT4vo0Wj9Ky4nQD h+fQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM533XM2anx7ia8N/An2FyKKvpTy62zRign42E/J0iNT5YMu4Us1fO mfbu0xE7Bela3cgjWe2S2Jc= X-Google-Smtp-Source: ABdhPJx2hVqsJZadSfeNxK5hDMx1yPwtVgG33ret2Tk38tM3dVYa1xIyGQ4+VF1UCGfZEiZFLpqgCg== X-Received: by 2002:a05:6830:214c:: with SMTP id r12mr3032242otd.90.1606936521942; Wed, 02 Dec 2020 11:15:21 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a4a:5e41:: with SMTP id h62ls193861oob.4.gmail; Wed, 02 Dec 2020 11:15:18 -0800 (PST) X-Received: by 2002:a4a:bb07:: with SMTP id f7mr2843963oop.44.1606936516548; Wed, 02 Dec 2020 11:15:16 -0800 (PST) In-Reply-To: <87360oduiq.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org> X-Original-Sender: ebkysko-Re5JQEeQqe8AvxtiuMwx3w@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:27112 Archived-At: ------=_Part_9616_1056171400.1606936515596 Content-Type: multipart/alternative; boundary="----=_Part_9617_2103051441.1606936515596" ------=_Part_9617_2103051441.1606936515596 Content-Type: text/plain; charset="UTF-8" > still returns the same error message because you left the `= {}` 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... > If I understand well, it should then be... A good beginning. Actually, `block.c[1]` will be the first `Inline`, which is a `pandoc` element... It's not literally a string, it is an element of type `Str`... see the nuance? See jm's answer. 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. > Unfortunately, I don't see what to do If you look at the code, it discards the `block` when '' is found for example. So you'd lose all that paragraph. For a more complex situation, like when the native output gives `Para [Str "", SoftBreak, Str "Foo"]`, you need to discard '' and 'SoftBreak' from the list, but keep 'Foo'. 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. 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` table. Do similarly in the end for '', but removing the last item(s) of the `Para` list of `Inline`s. I'll let you translate this into code! > Not sure to understand (about pandoc constructor) In the end, you want to create a new pandoc document with the new modified 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. -- 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/c210b412-3d47-45d5-a7e7-c55b1086d587n%40googlegroups.com. ------=_Part_9617_2103051441.1606936515596 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > still returns the same error message

because you left the = `=3D {}` later in the code.
for now, perhaps it might be better for yo= u to use Lua's usual `table.insert(note,...)` notation etc. rather than usi= ng `List` and `:insert` notation... one step at a time...

> If I = understand well, it should then be...

A good beginning. Actually, `b= lock.c[1]` will be the first `Inline`, which is a `pandoc` element... It's = not literally a string, it is an element of type `Str`... see the nuance?See jm's answer.

As for `</note>`, as I said in my correctio= n, it would be the last item, i.e. `block.c[#block.c]`, which is more adequ= ate if `Para` has more than one `Inline` in its list.

> Unfortuna= tely, I don't see what to do

If you look at the code, it discards th= e `block` when '<note>' is found for example. So you'd lose all that = paragraph.

For a more complex situation, like when the native o= utput gives `Para [Str "<note&= gt;", SoftBreak, Str "Foo"]`, you need to discard '<note>' and= 'SoftBreak' from the list, but keep 'Foo'.

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 tru= e.
You would then be left with a table containing only the rest of the p= ara items, i.e. the `Para` without the '<note>' (and possibly without= the 'SoftBreak').
This modified `Para` block should then be inserted in= the new `note` table. Do similarly in the end for '</note>', but rem= oving the last item(s) of the `Para` list of `Inline`s.

I'll let you= translate this into code!

> Not sure to understand (about pandoc= constructor)

In the end, you want to create a new pandoc document w= ith the new modified content, and for this you use `pandoc.Pandoc` construc= tor/creator.
You will have filled the `content` table with a list of pan= doc `Block` elements, which is what `pandoc.Pandoc` takes as first argument= .

--
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/c210b412-3d47-45d5-a7e7-c55b1086d587n%40googlegroups.= com.
------=_Part_9617_2103051441.1606936515596-- ------=_Part_9616_1056171400.1606936515596--