function renderRichText(body) { let sections = body.sections || []; let html = []; sections.forEach(section => { html.push(renderSection(section)); }); return html.join(''); } function renderSection(section) { let blocks = section.blocks || []; let inline = blocks.length > 1; let html = []; blocks.forEach(block => { html.push(renderBlock(block, inline)); }); return '

' + html.join('') + '

'; } function renderBlock(block, inline) { let type = ''; let inner = ''; if (block.type === 'text') { type = 'text'; inner = block.value; } else if (block.type === 'image') { type = 'image'; if (inline === true) { type += ' inline'; } // inner = ''; inner = ''; } else if (block.type === 'audio') { type = 'audio'; inner = ''; } return '' + inner + ''; }