caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
10.91k stars 384 forks source link

Markdown -> HTML Formatting Issues #1084

Closed caronc closed 3 months ago

caronc commented 3 months ago

Discussed in https://github.com/caronc/apprise/discussions/1081

Originally posted by **rcdailey** March 10, 2024 I'd like help addressing two issues: 1. Using markdown format of `markdown`, I am not seeing discord notifications with embeds. 1. Using markdown format of `markdown`, I am not seeing proper HTML formatting in emails. First, here's the configuration I'm using in the web UI (with the important bits snipped out): ```yml urls: - https://discord.com/api/webhooks/snip/snip - mailto://apppassword@fastmail.com?user=me@domain.com&to=user@fastmail.com ``` I then go to the Notifications tab and send a notification using these settings: ![image](https://github.com/caronc/apprise/assets/1768054/b3492063-f521-4e6b-ae6e-4849e4c60068) Here is how the notification looks in Discord (this applies to point number 1): ![image](https://github.com/caronc/apprise/assets/1768054/8333e984-d987-4f70-a5ff-2c82ede6a703) And this is how it looks in email (this applies to point number 2): ![image](https://github.com/caronc/apprise/assets/1768054/4e661c78-a48b-476a-970e-7e2ef4adf339) My expectation is that Apprise will format markdown to whatever renders best on the platform to which notifications are sent. In Email, that would mean I expect proper HTML output. For Discord, this means I expect an embed. I guess the first thing to address is if my expectation is accurate. I wasn't able to find any general documentation that describes the role Apprise plays in this area. Using persistent storage mode for configuration, it's really up to the user to specify where notifications will go. I prefer this approach because I do not want to have to support individual notification platforms in my .NET application, which is where I'm ultimately integrating this. That's the whole purpose & value of Apprise, in my opinion: It handles the details of sending notifications to various places so my app only needs to send to 1 endpoint. I prefer to send notifications using Markdown syntax because this, in my opinion, offers the best mechanism to render notifications using different formats. Markdown looks good and readable in plain text and has a way to render into HTML. It's a good middle-ground that allows me to send notification text in a singular way from my application, thus reducing complexity. Assuming I'm correct on the expectation side of things -- I'd like to understand why the formatting isn't coming through as I expect on Discord and Email. Your guidance is appreciated!
caronc commented 3 months ago

So a couple of things; I did do an update to help with the formatting with respect to your example. The emails now look like this: image

But can also look like this too: image

The first image is created from input that looks like this:

## Some Heading

With Data:
- Foo
- Bar

While the second image is created from this:

## Some Heading

With Data:

- Foo
- Bar

The subtle difference is the new line after the With Data: entry.

After looking into the markdown docks (of the library Apprise uses to convert it to HTML, it documents that without the new line implies you did not want to manipulate the string. The new line however causes the bullets.

This PR though also fixes the fact the first example will now properly place new lines in the output which is also an improvement to what it was before.

After learning about some of the added options from markdown -> html, i also added table support too. So this:

First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell
Content Cell  | Content Cell

can become nicely formated in an email as well: image

caronc commented 3 months ago

Code has been merge to master branch; It'll be available in the next release. :rocket: