-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem?
It would be really nice to support multi-dimensional padding of the content within the final SVG. I've been working on a parallel exercise where I needed some extra definition of the padding around my output SVG box, as well as overall output size.
Describe the solution you'd like
CSS style declaration for padding would be like:
- 1 value: all sides
- 2 values: vertical | horizontal
- 3 values: top | horizontal | bottom
- 4 values: top | right | bottom | left"
Proposed API (if applicable)
# How would you like to use this feature?
from mdsvg import render
svg = render("# Hello", padding=[X]) # All sides same padding (existing behaviour)
svg = render("# Hello", padding=[X, Y]) # Top and bottom X, Left/Right Y
svg = render("# Hello", padding=[X, Y, Z]) # Top X, Left/Right Y, Bottom Z
svg = render("# Hello", padding=[X, Y, Z, W]) # Top X, Right Y, Bottom Z, Left WDescribe alternatives you've considered
In theory you could just have named arguments (LeftPad, TopPad, etc.) but this API would feel at home for many users with Web experience.
Additional context
In my own project, I define all my padding at the start of my translate function (Similar behaviour to render())
# Snipped arguments for brevity - your "Style" arg handles what I've removed.
def md_to_svg(
md_text: str,
...
padding: int | list[int] = PADDING,
) -> str:
# * Handle padding assignment.
if isinstance(padding, int):
_top_pad = padding
_bottom_pad = padding
_left_pad = padding
_right_pad = padding
# ? CSS rules
if isinstance(padding, list):
match len(padding):
case 1:
_top_pad = padding[0]
_bottom_pad = padding[0]
_left_pad = padding[0]
_right_pad = padding[0]
case 2:
_top_pad = padding[0]
_bottom_pad = padding[0]
_left_pad = padding[1]
_right_pad = padding[1]
case 3:
_top_pad = padding[0]
_left_pad = padding[1]
_right_pad = padding[1]
_bottom_pad = padding[2]
case 4:
_top_pad = padding[0]
_left_pad = padding[1]
_right_pad = padding[2]
_bottom_pad = padding[3]
case _: _top_pad = paddingMy use case is a CLI, so I am fine accepting a variable list.
Cheers!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request