| 86 | } |
| 87 | |
| 88 | export const highlightEntitiesExampleCode = async (entities: Entity[]) => { |
| 89 | for (const entity of entities) { |
| 90 | const { example } = entity |
| 91 | if (example) { |
| 92 | const { code, language } = example |
| 93 | example.codeHighlighted = code |
| 94 | if (language) { |
| 95 | try { |
| 96 | // make sure to trim any extra /n at the end |
| 97 | example.codeHighlighted = hljs.highlight(code.trim(), { language }).value |
| 98 | } catch (error) { |
| 99 | // ignore any highlighting errors |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | return entities |
| 105 | } |
| 106 | |
| 107 | async function checkImageExists(url: string): Promise<boolean> { |
| 108 | try { |