gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.43k stars 296 forks source link

Custom spacing before and after bulleted list #334

Open AlexNsbmr opened 2 months ago

AlexNsbmr commented 2 months ago

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?

gonzalezreal commented 2 months ago

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?