# Markdown

Markdown formatter returns message blocks formatted using classic [Markdown](https://www.markdownguide.org/) syntax. This format is widely adopted by messenger apps and wikis.

Also, it can be used to format messages for emails.

### Example

```python
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from markdown import markdown
from smtplib import SMTP
from typing import List

def send_email_markdown_message(
    smtp_host: str,
    smtp_port: int,
    smtp_user: str,
    smtp_password: str,
    sender_name: str,
    sender_email: str,
    receiver_emails: List[str],
    message_subject: str,
    message_blocks: List[str],
):
    """
    Basic utility function to send email messages from SnowKill examples
    """
    multipart_msg = MIMEMultipart("alternative")
    multipart_msg["Subject"] = message_subject
    multipart_msg["From"] = f"{sender_name} <{sender_email}>"
    multipart_msg["To"] = ",".join(receiver_emails)

    message_markdown_content = "\n\n".join(message_blocks)
    message_html_content = email_template.replace("{{ content }}", markdown(message_markdown_content, extensions=["fenced_code"]))

    multipart_msg.attach(MIMEText(message_markdown_content, "plain"))
    multipart_msg.attach(MIMEText(message_html_content, "html"))

    with SMTP(host=smtp_host, port=smtp_port) as server:
        server.login(smtp_user, smtp_password)
        response = server.send_message(multipart_msg, sender_email, receiver_emails)

    return response

...

snowkill_formatter = MarkdownFormatter(getenv("SNOWSIGHT_BASE_URL"))

# Send notification for each new check result
for r in check_results:
    message_blocks = snowkill_formatter.format(r)

    response = send_email_markdown_message(
        smtp_host=getenv("SMTP_HOST"),
        smtp_port=int(getenv("SMTP_PORT")),
        smtp_user=getenv("SMTP_USER"),
        smtp_password=getenv("SMTP_PASSWORD"),
        sender_name="Snowflake Monitor",
        sender_email=getenv("SENDER_EMAIL"),
        receiver_emails=[getenv("RECEIVER_EMAIL")],
        message_subject=message_blocks[0][3:],
        message_blocks=message_blocks,
    )

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snowkill.net/formatter/built-in-formatters/markdown.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
