public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* spacing between items in plain text
@ 2022-04-09 21:01 Julian Bradfield
       [not found] ` <25169.62483.641766.380124-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Julian Bradfield @ 2022-04-09 21:01 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I've failed to find an answer to this by searching, so ...

Consider the following markdown:

------------------
1. A list
    * with sub lists
    * point 2

2. Second main item
    * subitem 1
    * subitem 2

3. main item without sublists

4. another main item without sublists
------------------

If I convert it to plain text (pandoc 2.5), I get:

------------------
1.  A list
    -   with sub lists
    -   point 2
2.  Second main item
    -   subitem 1
    -   subitem 2
3.  main item without sublists

4.  another main item without sublists
------------------

which is horribly inconsistent. I would like spaces before level 1
items, whether or not there are sublists.

How can I do this?


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: spacing between items in plain text
       [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
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien DUMONT @ 2022-04-10  9:42 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I guess that you could achieve this by adding a blank line after every level-1 item, but pandoc 2.17 handles your sample file as you expect.

Le Saturday 09 April 2022 à 10:01:07PM, Julian Bradfield a écrit :
> I've failed to find an answer to this by searching, so ...
> 
> Consider the following markdown:
> 
> ------------------
> 1. A list
>     * with sub lists
>     * point 2
> 
> 2. Second main item
>     * subitem 1
>     * subitem 2
> 
> 3. main item without sublists
> 
> 4. another main item without sublists
> ------------------
> 
> If I convert it to plain text (pandoc 2.5), I get:
> 
> ------------------
> 1.  A list
>     -   with sub lists
>     -   point 2
> 2.  Second main item
>     -   subitem 1
>     -   subitem 2
> 3.  main item without sublists
> 
> 4.  another main item without sublists
> ------------------
> 
> which is horribly inconsistent. I would like spaces before level 1
> items, whether or not there are sublists.
> 
> How can I do this?
> 
> 
> -- 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
> 
> -- 
> 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/25169.62483.641766.380124%40high.jcbradfield.org.

-- 
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/YlKmgfjl63CZtrzS%40localhost.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: spacing between items in plain text
  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>
  0 siblings, 1 reply; 6+ messages in thread
From: Julian Bradfield @ 2022-04-10 11:03 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Bastien DUMONT <bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@public.gmane.org>:
>I guess that you could achieve this by adding a blank line after every level-1 item, but pandoc 2.17 handles your sample file as you expect.

No, it doesn't. It puts space before the sublists as well.
What I want is line-spacing as in the original.
As far as I understand the Markdown spec, the level 1 list is loose
and the sublists are tight, so I would expect spacing to be as in the
original.


2.18:
----------------
1. A list
    * with sub lists
    * point 2

2. Second main item
    * subitem 1
    * subitem 2

3. main item without sublists

4. another main item without sublists
----------------

rendered as
----------------
1.  A list

    -   with sub lists
    -   point 2

2.  Second main item

    -   subitem 1
    -   subitem 2

3.  main item without sublists

4.  another main item without sublists
-----------------


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: spacing between items in plain text
       [not found]       ` <25170.47468.723172.999462-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
@ 2022-04-10 11:59         ` Bastien DUMONT
  2022-04-10 15:31           ` Julian Bradfield
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien DUMONT @ 2022-04-10 11:59 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

> 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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: spacing between items in plain text
  2022-04-10 11:59         ` Bastien DUMONT
@ 2022-04-10 15:31           ` Julian Bradfield
       [not found]             ` <25170.63586.916772.985317-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Julian Bradfield @ 2022-04-10 15:31 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Bastien DUMONT <bastien.dumont-VwIFZPTo/vqsTnJN9+BGXg@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.

Oh, I see, I think: you mean that the list is loose by virtue of the
space between items, and therefore it must also have spaces between
the blocks within its items?


>The following lua filter works with your sample file:

Thank you very much! I have managed to avoid lua so far, and barely
use pandoc, so that's saved me a couple of hours of learning curve.

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: spacing between items in plain text
       [not found]             ` <25170.63586.916772.985317-2Bkq8O7kH1dDWdl4zjylUmD2FQJk+8+b@public.gmane.org>
@ 2022-04-13 18:03               ` gnpan
  0 siblings, 0 replies; 6+ messages in thread
From: gnpan @ 2022-04-13 18:03 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1780 bytes --]

I think a good way to deal with lists that have sublists is to avoid empty 
lines and use four spaces before * so as to get the sublists indented: 

1. A list
    * with sub lists 
    * point 2 
2. Second main item
    * subitem 1 
    * subitem 2 
3. main item without sublists
4. another main item without sublists 

will give this:

1.  A list
    -   with sub lists
    -   point 2
2.  Second main item
    -   subitem 1
    -   subitem 2
3.  main item without sublists
4.  another main item without sublists

On Sunday, 10 April 2022 at 18:31:55 UTC+3 j...-9iOJEv++55WFxr2TtlUqVg@public.gmane.org wrote:

> Bastien DUMONT <bastien...-VwIFZPTo/vqsTnJN9+BGXg@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.
>
> Oh, I see, I think: you mean that the list is loose by virtue of the
> space between items, and therefore it must also have spaces between
> the blocks within its items?
>
>
> >The following lua filter works with your sample file:
>
> Thank you very much! I have managed to avoid lua so far, and barely
> use pandoc, so that's saved me a couple of hours of learning curve.
>
> -- 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>

-- 
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/3009daf8-6c3c-4ca1-9f2e-f5a34656c1fcn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2676 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-13 18:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-09 21:01 spacing between items in plain text 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
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

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).