Export to markdown / HTML

Given that markdown is the internal text markup language, and given that export to PDF is fully mature and functional, it would be nice if one could export a page of a set of pages to markdown besides pdf and using the same workflow.

The user case is crystal-clear: once a doc is ready for deliver to a third party, if some document format is mandatory (.docx for a lot of organizations) or desiderable (LaTeX for beautify the entire doc), then a markdown doc would be really appreciated. As using pandoc for converting a markdown doc into whatever you need is really simple and trouble-free, such functionality would save us unneeded minutes of copy+paste and re-formatting using a external editor like LyX

7 Likes

https://coda.io/developers/apis/v1#tag/Pages/operation/beginPageContentExport

it does not work.
{"statusCode":404,"statusMessage":"Not Found","message":"Doc does not exist or is inaccessible."}

I managed it to work with this set of bash commands:

export TOKEN=<your API token>

# Get docs:
curl -s -H "Authorization: Bearer $TOKEN" \
    "https://coda.io/apis/v1/docs" |
    jq '.items[] | {name:.name,id:.id}'

export DOC_ID=<your doc ID from the list>

# Get doc pages:
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://coda.io/apis/v1/docs/$DOC_ID/pages" |
  jq '.items[] | {name:.name,id:.id}'
  
export PAGE_ID=<your page ID from the list>

# Export page:
export EXPORT_ID=$(curl -s -H "Authorization: Bearer $TOKEN" -X POST -H "Content-Type: application/json" \
  -d '{"outputFormat": "markdown"}' \
  "https://coda.io/apis/v1/docs/$DOC_ID/pages/$PAGE_ID/export" | jq -r '.id')

# Poll the result:
export DOWNLOAD_LINK=$(curl -s -H "Authorization: Bearer $TOKEN" \
  "https://coda.io/apis/v1/docs/$DOC_ID/pages/$PAGE_ID/export/$EXPORT_ID" | jq -r '.downloadLink')

# Download markdown file
wget --compression=auto --content-disposition $DOWNLOAD_LINK
1 Like