Expressive Code
Reference advanced code block markers, diffs, line numbers, and configuration.
Dahlia enables Expressive Code by default. Use this reference when a page needs more than a basic fenced code block.
Configuration
Disable Expressive Code entirely when a site should use Astro’s built-in Shiki renderer instead.
dahlia({ markdown: { expressiveCode: false, },})Pass Expressive Code options through the Dahlia integration when you need to change the default themes or block behavior.
dahlia({ markdown: { expressiveCode: { themes: ['github-light', 'github-dark'], defaultProps: { wrap: true, }, }, },})Inserted And Deleted Lines
Use ins={...} and del={...} for changed lines. Plain {...} remains a
neutral highlight.
```json del={4} ins={5} {7} title="theme.config.json"{ "docsBase": "/docs", "appearance": { "accent": "blue", "accent": "emerald", "gray": "neutral" }, "pageActions": []}```{ "docsBase": "/docs", "appearance": { "accent": "blue", "accent": "emerald", "gray": "neutral" }, "pageActions": []}Inline Markers
Mark text inside a line with quoted strings or regular expressions. Prefix the
marker with ins=, del=, or mark= to choose the marker type.
```json "docsBase" ins='"/docs"' del='"/documentation"' title="theme.config.json"{ "docsBase": "/docs", "previousBase": "/documentation"}```{ "docsBase": "/docs", "previousBase": "/documentation"}Regular expressions are useful when the exact value changes across examples.
```ts /variant: '[^']+'/ title="src/site-nav.ts"export const siteNav = [ { label: 'Dashboard', href: '/app/', variant: 'soft' }, { label: 'Login', href: '/login/', variant: 'outline' },]```export const siteNav = [ { label: 'Dashboard', href: '/app/', variant: 'soft' }, { label: 'Login', href: '/login/', variant: 'outline' },]Diff Blocks
Use the diff language for compact before-and-after examples.
```diff- "accent": "blue"+ "accent": "emerald"```"accent": "blue""accent": "emerald"Use lang="..." when you want diff markers and syntax highlighting for the
underlying language.
```diff lang="json" title="theme.config.json" {- "accent": "blue"+ "accent": "emerald" }```{ "accent": "blue" "accent": "emerald"}Line Numbers
Dahlia includes Expressive Code’s line number plugin, but keeps line numbers off
by default. Add showLineNumbers to a block when line references matter.
```ts showLineNumbers title="src/content.config.ts"import { docsLoader } from '@prosefly/astro-theme-dahlia/content';import { defineCollection } from 'astro:content';
const docs = defineCollection({ loader: docsLoader(),});
export const collections = { docs };```import { docsLoader } from '@prosefly/astro-theme-dahlia/content';import { defineCollection } from 'astro:content';
const docs = defineCollection({ loader: docsLoader(),});
export const collections = { docs };Use startLineNumber for snippets taken from the middle of a file.
```json showLineNumbers startLineNumber=24 {27} title="theme.config.json" "appearance": { "accent": "indigo", "gray": "neutral", "radius": "medium" },``` "appearance": { "accent": "indigo", "gray": "neutral", "radius": "medium" },Hanging Indent
Use hangingIndent with wrap to keep wrapped lines easier to scan.
```ts wrap hangingIndent=2 title="src/sidebar.ts"export const sidebar = [{ label: 'Guides', items: [{ label: 'Getting Started', items: ['overview', 'installation', { label: 'Configuration', items: [{ autogenerate: { directory: 'configuration' } }] }] }] }]```export const sidebar = [{ label: 'Guides', items: [{ label: 'Getting Started', items: ['overview', 'installation', { label: 'Configuration', items: [{ autogenerate: { directory: 'configuration' } }] }] }] }]