swift-markdown-ui icon indicating copy to clipboard operation
swift-markdown-ui copied to clipboard

Custom spacing before and after bulleted list

Open AlexNsbmr opened this issue 1 year ago • 3 comments
trafficstars

First of all, thank you for this amazing library!

Currently, it is not possible to set custom spacing specifically before and after bulleted list blocks in MarkdownUI. This feature would greatly enhance the ability to control the layout and presentation of lists within the library.

Screenshot 2024-07-03 at 09 36 12

At present, any changes to spacing affect the overall block styles, making it impossible to target only bulleted lists.

Are there any plans to add support for setting custom spacing before and after bulleted list blocks in future updates?

AlexNsbmr avatar Jul 03 '24 07:07 AlexNsbmr

Hi @AlexNsbmr,

You can control top and bottom margins for lists by overriding the current theme's list block style.

Markdown {
  """
  A list:

  * Item 1
  * Item 2
  * Item 3

  Paragraph after the list.
  """
}
.markdownBlockStyle(\.list) { label in
  label.markdownMargin(top: .zero, bottom: .em(0.8))
}

This change applies to all list types: bulleted, numerical and task lists. At the moment there are no plans to allow overriding the style for a single type of list. What is the reasoning behind having different margins depending on the list type?

gonzalezreal avatar Jul 03 '24 09:07 gonzalezreal

It only accepts the top and bottom margins, so how about the leading margin before the bullets?

ArchimedesTrajano avatar Oct 14 '24 15:10 ArchimedesTrajano

+1 to the left/right margins. Currently it's indented too much.

metasidd avatar Mar 11 '25 06:03 metasidd

I'd also like to modify the left/right margins (or however indentation is handled). Specifically, on watchOS it's a waste of space to indent the top-level list... and so I'd like that top-level list to be aligned all the way to the left, and then preferably have a small indentation for every nested list. I've been looking through the codebase, but I don't understand how exactly indentation is handled.

262hz avatar Sep 15 '25 19:09 262hz