From: H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Wrapping sections of existing document in <div></div>
Date: Mon, 19 Jun 2023 20:14:57 -0400 [thread overview]
Message-ID: <AC708553-331A-45D3-A618-EAA8BB7784A5@meddatainc.com> (raw)
In-Reply-To: <e3258495-d762-2f54-cff3-a2607261bcf7-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
On June 19, 2023 6:11:35 PM EDT, H <agents-FcZObrvlYduBUy7/sJONFg@public.gmane.org> wrote:
>What is the "best" way of wrapping parts of an existing document in
><div></div> in a filter?
>
>Using insert.table(existingtable, pandoc.Div(existingtextblocks)) does
>not work since the existing text blocks get duplicated in the output.
>
>I see two options but there might be others:
>
>- Surround existing text blocks with pandoc.RawInline(1, 'html,
>'<div>') and pandoc.RawInLine('html', '</div>').
>
>- Create a new table and use insert.table(newtable,
>pandoc.Div(existingtextblock)) and also insert the rest of the
>document.
>
>Are there other options?
Replying to my own question, it seems the most "elegant" way of accomplishing this requires this to be done be in two stages:
- First, delete the blocks in question from the block list table, eg doc.blocks.
- Second, insert them into the same table using pandoc.Div().
Unfortunately it seems table.delete() does not accept a list of blocks, only one block at a time, pandoc.Div, on the other hand, accepts a table. Here is a code example when I was trying it out:
local temp = {}
for i = 3, 1, -1 do
table.insert(temp, table.remove(doc.blocks, 5))
end
table.insert(doc.blocks, 2, pandoc.Div(temp))
The above code removes blocks 5 through 7 from doc.blocks, then inserts them, in the same order but surrounded by <div></div>, in position 2.
If there is a better way of accomplishing this, I would appreciate hearing it.
next prev parent reply other threads:[~2023-06-20 0:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 22:11 H
[not found] ` <e3258495-d762-2f54-cff3-a2607261bcf7-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-06-20 0:14 ` H [this message]
[not found] ` <AC708553-331A-45D3-A618-EAA8BB7784A5-FcZObrvlYduBUy7/sJONFg@public.gmane.org>
2023-06-20 10:37 ` mf
[not found] ` <e42adc8d-f75c-4b91-7777-cc162e157c64-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-06-21 0:21 ` H
2023-06-21 15:36 ` BPJ
[not found] ` <CADAJKhBZGdihMMgb=2_9rT04RsobJyu+48HxtO5755ADPcnZBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-06-21 22:58 ` H
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AC708553-331A-45D3-A618-EAA8BB7784A5@meddatainc.com \
--to=agents-fczobrvlydubuy7/sjonfg@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).