hunk.code_window: /* eslint-disable no-mixed-operators */
   // Ported from https://github.com/waylonflinn/markdown-it-katex
   /* Process inline math */
  
hunk.labels: replace keep keep keep
hunk.file_path: packages/slidev/node/plugins/markdown-it-katex.ts
hunk.type: replace
file: import { join } from 'node:path'
  import type { InlineConfig } from 'vite'
  import { createServer as createViteServer, resolveConfig } from 'vite'
  import { mergeViteConfigs } from './common'
  import type { ResolvedSlidevOptions, SlidevServerOptions } from './options'
  import { ViteSlidevPlugin } from './plugins/preset'
  
  export async function createServer(
    options: ResolvedSlidevOptions,
    viteConfig: InlineConfig = {},
    serverOptions: SlidevServerOptions = {},
  ) {
    const rawConfig = await resolveConfig({}, 'serve', options.entry)
    const pluginOptions = rawConfig.slidev || {}
  
    // default open editor to code, #312
    process.env.EDITOR = process.env.EDITOR || 'code'
  
    const server = await createViteServer(
      await mergeViteConfigs(
        options,
        viteConfig,
        <InlineConfig>({
          optimizeDeps: {
            entries: [
              join(options.clientRoot, 'main.ts'),
            ],
          },
          plugins: [
            await ViteSlidevPlugin(options, pluginOptions, serverOptions),
          ],
        }),
        'serve',
      ),
    )
  
    return server
  }
  