--- title: Include description: Markdown partials and code snippets from files, written in Markdown. keywords: partial, import, transclusion, snippet, reuse, include file, source code, code region tagline: A line that pastes a Markdown partial, or a few lines of real source, into the page from a file. group: Authoring tools icon: file-input blurb: Partials and snippets from files credits: 'Arguments from automd.' --- ::examples :::example{label="Partial"} ```md :include{src="./partials/install.md"} ``` ::: :::example{label="Region"} ```md :include{src="./partials/ducks.ts" region="estimate"} ``` ::: :::example{label="Lines"} ```md :include{src="./partials/ducks.ts" lines="8:10"} ``` ::: :::example{label="As code"} ```md :include{src="./partials/install.md" code} ``` ::: :: ## Features - A Markdown file pastes into the page, and any other file becomes a code block in its extension's language. - Pick lines by number, or by a named region that moves with the code. - The page parses once, so heading ids stay unique across partials. - Paths can't leave `root`, in any runtime. - comark-ui leaves it off until you turn it on, since it reads from disk. ## Usage Write `:include` with one colon, alone on its line, with the file in `src`. ::example ```md :include{src="./partials/install.md"} ``` :: A `.md`, `.mdc`, or `.markdown` file pastes without its frontmatter, and its own includes resolve from its folder. An include inside fenced code stays as written. ### Source Use the `src` prop to name the file. A relative path starts at the page's folder, or at the including partial's. A path that starts with `/` starts at `root`. ```md :include{src="./parts/pizza-policy.md"} :include{src="/src/ducks.ts"} ``` ### Lines Use the `lines` prop to include some of the file's lines, 1-based and inclusive. `"10:"` and `":24"` leave one end open. Lines count from the top of the file, frontmatter included. ::example ```md :include{src="./partials/ducks.ts" lines="8:10"} ``` :: ### Region Use the `region` prop to include the lines between `#region estimate` and `#endregion estimate`. A marker starts its line, after a comment opener if any: `//`, `#`, `/*`, `