Code examples

Example of code syntax highlighting.

· 1 min read
Code examples

Shell example with word highlight:

...
10-02 14:05:00.464  4821  5579 E NetworkSM: Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
10-02 14:05:00.464  4821  5579 E NetworkSM:  at libcore.io.IoBridge.isConnected(IoBridge.java:274)
10-02 14:05:00.464  4821  5579 E NetworkSM:  ... 28 more
10-02 14:05:00.586  4821  5121 E LocBroadcastReceiver: Error receiving zones from Home Assistant
10-02 14:05:00.586  4821  5121 E LocBroadcastReceiver: io.homeassistant.companion.android.common.data.integration.IntegrationException: javax.net.ssl.SSLHandshakeException: Unacceptable certificate: CN=R3, O=Let's Encrypt, C=US
10-02 14:05:00.586  4821  5121 E LocBroadcastReceiver:  at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl.getZones(IntegrationRepositoryImpl.kt:294)
10-02 14:05:00.586  4821  5121 E LocBroadcastReceiver:  at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl$getZones$1.invokeSuspend(Unknown Source:14)
...

JavaScript example with line highlight:

import { codeToHtml } from 'shiki'

const code = await codeToHtml('console.log("hello")', {
  lang: 'javascript',
  themes: {
    light: 'vitesse-light',
    dark: 'vitesse-dark',
  },
  defaultColor: false, // <--
})

JavaScript example with line focus:

import { codeToHtml } from 'shiki'

const code = await codeToHtml('console.log("hello")', {
  lang: 'javascript',
  themes: {
    light: 'vitesse-light',
    dark: 'vitesse-dark',
  },
  defaultColor: false,
})

JavaScript example with line diff:

import { codeToHtml } from 'shiki'

const code = await codeToHtml('console.log("hello")', {
  lang: 'javascript',
  lang: 'shell',
  themes: {
    light: 'vitesse-light',
    dark: 'vitesse-dark',
  },
  defaultColor: false,
})

Related Articles

Bookmark examples
· 1 min read
Code examples
· 1 min read
Card examples
· 2 min read
Markdown Style Guide
· 4 min read