Skip to main content

Convert Rich Text to Markdown with Airtable Extension


Lom_Labs
Forum|alt.badge.img+12

Hello everyone!  I have created a new scripting extension which allows you to convert formatted text in your rich text fields into markdown! 

The extension will look through all the records in the table you have selected and convert the selected field's text into markdown so that you can use it for your email, Slack, etc automations

Please feel free to reach out to me if you have any questions or feedback!

Base with extension installed

Installation instructions:
1. Click "Extension" at the top right
2. Click "Add Extension"
3. Click the "Scripting" extension
4. Click "Add Extension"
5. Paste the code below in!

 

let settings = input.config({ title: `Convert rich text field to markdown`, items: [ input.config.table("table", { label: `Table` }), input.config.field("richTextField", { parentTable: `table`, label: `Rich text field` }), input.config.field("markdownField", { parentTable: `table`, label: `Output field` }), ], }); let { table, richTextField, markdownField } = settings; let query = await table.selectRecordsAsync() let updates = new Array query.records.forEach((record) => { updates.push({ id: record.id, fields:{ [markdownField.name]: record.getCellValue(richTextField.name) } }) }); while (updates.length > 0) { await table.updateRecordsAsync(updates.slice(0, 50)); updates = updates.slice(50); }

 

 

3 replies

kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6001 replies
  • March 22, 2023

Looks like you are having fun writing scripts! 

I noticed that your screen shot shows a single line text field for your output field. I recommend using a long text field without rich text formatting as the output field. Single line text fields are not designed to have multiple lines of text, which markdown often has.


Lom_Labs
Forum|alt.badge.img+12
  • Author
  • Inspiring
  • 48 replies
  • March 23, 2023
kuovonne wrote:

Looks like you are having fun writing scripts! 

I noticed that your screen shot shows a single line text field for your output field. I recommend using a long text field without rich text formatting as the output field. Single line text fields are not designed to have multiple lines of text, which markdown often has.


You are right!  I have updated the base so that it uses a long text field for the output field now 

Thank you  😀


Forum|alt.badge.img+12

Works great! And to anyone reading this post who is less familiar with scripts, just paste the script as the OP suggested, and then you have to set the Script settings to indicate what fields you want to convert from->to