| 123456789101112131415161718192021222324252627282930 |
- n = "\n"
- w = " "
- bold = lambda x: f"**{x}:** "
- bold_ul = lambda x: f"**--{x}:**-- "
- mono = lambda x: f"`{x}`{n}"
- def section(
- title: str,
- body: dict,
- indent: int = 2,
- underline: bool = True,
- ) -> str:
- text = (bold_ul(title) + n) if underline else bold(title) + n
- for key, value in body.items():
- text += (
- indent * w
- + bold(key)
- + (
- (value[0] + n)
- if isinstance(value, list)
- else mono(value)
- )
- )
- return text
|