Using 'markup' and 'html' when setting/updating card body

There are ‘markup’ and ‘html’ keys, which are describing the card’s body. While this is very convenient when fetching body text - currently it is giving us problems when creating/updating cards: you can not use only one of them when defining body text. And ‘html’ key overrides ‘markup’ if you use different text in ‘markup’ and ‘html’ keys.

So, the question is: why it is impossible to use only one of the keys (‘markup’ OR ‘html’) when creating or updating card. Do we really need to duplicate the same text first using markup syntax and then using html-syntax? This does not looks very productive and may lead to formatting errors.

Still struggling with this. So, there are two body-related keys: ‘markup’ and ‘html’. Newly created card will display the content of ‘html’ key, but only until you enter the edit mode: then the content of ‘html’ will be replaced with ‘markup’. Here is the video of the card created like this:

"card": {
    "markup": "This is markup.",
    "html": "This is html."
  }

It shows “This is html” right after creation and “This is markup” in Edit mode. If you leave ‘html’ empty - the card will show empty body right after creation. If you leave markup empty card will show the content of ‘html’ key right after creation, but will return to blank when you hit the Edit button.

Am I doing something wrong? Right now the only way to set the body text correctly is to fill both of the keys (‘markup’ and ‘html’), but this is not an easy task when doing programmatically, as the syntax is quite different. Can you, please, set the ‘markdown’ key as the default one and fill the ‘html’ key automatically at backend at the moment of card creation?

Can you bring some light here?
Thanks!

Yep, so the issue you’re bumping into is that currently all markdown to HTML rendering is done on the frontend, not the backend. This is for instant responsiveness / consistency, so that you are not waiting for a card to render when you edit it – it happens instantly.

I can understand how parsing markdown on the backend could be useful when using the API, so we will look into this.

However, for consistency’s sake it is much easier to just do all parsing with the frontend at the moment.

I strongly suggest to look into this as quick as possible. Just a quick example (this is a card in a simplest form: a list and an external link):

Снимок экрана 2020-07-06 в 11.52.27

To make this content ‘SN API ready’ in markdown format I just need to replace all the new lines with \n. And now take a look at the same content in html-format:

<p>Just an unordered list test:</p>\n<ul>\n<li>one\n<ul>\n<li>two</li>\n<li>three</li>\n</ul>\n</li>\n<li>four</li>\n</ul>\n<p>An <a href=\"https://apple.com\" class=\"external-link\" target=\"_blank\" rel=\"noreferrer noopener\">external link</a>.</p>\n

Being non-programmer, I’m sure I will be unable to parse markdown to html ‘on the fly’. This makes SN API almost unusable for me. :frowning:

Just a quick idea: to introduce another API call to convert markdown to html? This is not ideal because user will be forced to make two API calls instead of just one to create a card, but, at least, this will give us error-prone way of managing content formats…

Just found a useful command line tool to convert document formats:

https://pandoc.org

Works quite well to convert markdown to html. Back in business! :partying_face: