sections.py 413 B

123456789101112
  1. def section(title: str, body: dict, indent: int = 2, underline: bool = True) -> str:
  2. text = (
  3. f"**--{title}**--:\n"
  4. if underline
  5. else f"**{title}**:\n"
  6. )
  7. for key, value in body.items():
  8. if not isinstance(value, list):
  9. text += f"{' ' * indent}**{key}:** `{value}`\n"
  10. else:
  11. text += f"{' ' * indent}**{key}:** {value[0]}\n"
  12. return text