pengzhanbo 385059f214
docs: update en docs (#708)
* docs: update en docs

* chore: tweak

* chore: tweak

* chore: tweak
2025-10-09 15:46:05 +08:00

895 B

title, icon, createTime, permalink
title icon createTime permalink
Import Code mdi:import 2025/10/08 10:39:22 /en/guide/code/import/

Overview

Importing code allows you to include code from another file in your markdown file and have it highlighted.

It helps you reference code from other files in your articles, avoiding duplicate code writing.

Syntax

You can use the following syntax to import code blocks from files:

Input:

@[code](../snippet/snippet-1.js)

Output:

@code

If you only want to import a specific portion of the file:

<!-- Import only lines 1 to 10 -->
@[code{1-10}](../snippet/snippet-1.js)

The code language is inferred from the file extension, but we recommend explicitly specifying it:

<!-- Specify code language -->
@[code js](../snippet/snippet-1.js)

<!-- Line highlighting -->
@[code js{2,4-5}](../foo.js)