Markdown (or MDX) from Plone REST API

I'd like to retrieve Markdown (or, preferably, MDX) content from Plone's REST API but I cannot seem to find documentation on the process.

(.json (.get requests "" :headers PloneKit.HEADERS :auth PloneKit.AUTH))


 "text" {"content-type" "text/x-web-markdown"
         "data" "<h1>This is plain pre</h1>\n<p>Pre formatted</p>"
         "encoding" "utf-8"}

But the data is not in Markdown format. Is this possible?

plone.restapi currently does not support Markdown format. Plone might have a portal_transform to transform HTML to Markdown (not sure, you would need to check) and then you could write a custom endpoint (or enhance an existing endpoint) to return Markdown instead of JSON.

I would suggest starting simple and writing a custom endpoint specific to your needs. In the long run, we might include this feature in plone.restapi core. Though, this is not on the short/mid-term roadmap so far.

1 Like

as far as i get it, the "content-type" is set correct, but the data (structure) of this json return isn't markdown. its html (with newlines)

either content-type is "text/xhtml-blabla" and data is html or content-type is text/x-web-markdown and data is markdown.

but maybe i get it wrong ...

Is your content in Plone markdown or do you want to convert html to markdown?

PS: If you convert html to markdown and back to html, it will not look the same. Especially tables are problematic in markdown, so often I need to 'keep them in html'. Note: Markdown supports html, so markdown can contain html

Thank you. I'd like to store content that can be converted by the consumer. Plone has attractive data modeling capabilities that are more important to me than its internal rendering features.

My content can be plain text. I tried that with the "text" field (plain text is fine) but that is also converted to HTML (inserting <p> tags).

Is it possible to store text in Plone as text/plain while displaying line breaks? I could store Markdown content as text/plain and default plaintext rendering would be sufficient. I want to avoid HTML in my content and still render it in a human-readable format.

Plone mostly stores text as it is input. Exception: for security reasons, HTML structures deemed dangerous are by default filtered out -- this can be customized.

Views determine how the objects are presented -- e.g. whether text is treated as HTML or plain text. You can override existing views or define your own views.

Many things can be achieved with CSS, too. You can e.g. use CSS to keep newlines in a block.

A bit off topic, but my add-on saves 'both html and markdown' (it converts markdown to html and saves it in another field). (a did this because I could not get the default plone conversion to do all I wanted).

I have not touched the code in a while, but I use the markdown editor 'all the time',