const card2Html = (elem, link) => { const name = elem.attr('name'); const data = elem.attr('value')?.split('data:')[1]?.replace('undefined', ''); const value = JSON.parse(decodeURIComponent(data || '[]')); let html = ''; switch (name) { case 'board': case 'emoji': case 'flowchart2': case 'image': case 'mindmap': case 'puml': html = ``; break; case 'bookmarkInline': case 'bookmarklink': html = `${value.detail.title}`; break; case 'checkbox': html = ``; break; case 'codeblock': html = `${value.code.replace(/\n/g, '
')}
`; break; case 'diagram': html = ``; break; case 'file': case 'localdoc': html = `${value.name}`; break; case 'hr': html = '
'; break; case 'mention': html = `${value.name}`; break; case 'table': html = value.html; break; case 'thirdparty': case 'youku': // YES, youku name with bilibli iframe // https://www.yuque.com/api/docs/nn5lyk?book_id=297292&include_contributors=true if (elem.attr('alias') === 'music163') { html = ``; } else if (elem.attr('alias') === 'bilibili' || elem.attr('alias') === undefined) { html = ``; } else { throw Error(`Unhandled thirdparty on ${link}: ${elem.attr('alias')}`); } break; case 'video': // fake video src html = ``; break; default: throw Error(`Unhandled card on ${link}: ${name}`); } elem.replaceWith(html); }; module.exports = { card2Html, };