From: Bastien DUMONT <bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: spacing between items in plain text
Date: Sun, 10 Apr 2022 11:59:13 +0000 [thread overview]
Message-ID: <YlLGkRv0l4t9WE2t@localhost> (raw)
In-Reply-To: <25170.47468.723172.999462-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
> As far as I understand the Markdown spec, the level 1 list is loose
> and the sublists are tight
For the same reason, it seems to me that the current output is right. But you can achieve your intent with a filter. As `pandoc -t native` shows, loose items are internally represented as Para elements and compact items as Plain. What you wish is to replace Para elements followed by a BulletList in an OrderedList or a BulletList with Plain elements with the same content.
The following lua filter works with your sample file:
```
local function isCompactList(elem)
return (elem.t == 'OrderedList' or elem.t == 'BulletList')
and elem.content[1][1].t == 'Plain'
end
local function process_list(list)
for _, item in pairs(list.content) do
if #item > 1 and item[1].t == 'Para' and isCompactList(item[2]) then
item[1] = pandoc.Plain(item[1].content)
end
end
return list
end
return {
{ OrderedList = process_list },
{ BulletList = process_list }
}
```
However, if you have more than two levels of lists, you may have to run it twice. I wrote it as a proof of concept, so it may have shortcomings with more complex lists or corner cases.
--
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/YlLGkRv0l4t9WE2t%40localhost.
next prev parent reply other threads:[~2022-04-10 11:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-09 21:01 Julian Bradfield
[not found] ` <25169.62483.641766.380124-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
2022-04-10 9:42 ` Bastien DUMONT
2022-04-10 11:03 ` Julian Bradfield
[not found] ` <25170.47468.723172.999462-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
2022-04-10 11:59 ` Bastien DUMONT [this message]
2022-04-10 15:31 ` Julian Bradfield
[not found] ` <25170.63586.916772.985317-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
2022-04-13 18:03 ` gnpan
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=YlLGkRv0l4t9WE2t@localhost \
--to=bastien.dumont-vwifzpto/vqstnjn9+bgxg@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).