Code File Embed

by Willian Saez
5
4
3
2
1
New Plugin

Description

Embed the contents of a vault file as a syntax-highlighted code block via a codefile fenced block. - This plugin has not been manually reviewed by Obsidian staff.

Reviews

No reviews yet.

Stats

stars
downloads
0
forks
0
days
NaN
days
NaN
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
0
commits

Latest Version

Invalid date

Changelog

README file from

Github

Code File Embed (Obsidian plugin)

Embed the current contents of a vault file as a syntax-highlighted code block, instead of copy-pasting code into a fenced block.

Usage

Point a codefile block at a file. The language is inferred from the extension.

```codefile src/foo.abap
```

Line range (1-based, inclusive):

```codefile src/foo.abap:10-25
```

Single line: :10. The path can also go in the block body (first line) if you prefer. Paths resolve like Obsidian links (relative to the current note, shortest-unique names work).

Features

  • Syntax highlighting by extension, reusing Obsidian's own renderer (theme + copy button included).
  • Live update: the block re-renders when the target file is saved or renamed.
  • Optional clickable header showing the file path.
  • Configurable extension → language map and max file size in settings.

Development

npm install
npm run dev    # watch build -> main.js
npm run build  # type-check + production bundle
npm test       # unit tests (parser, langMap)

Copy main.js, manifest.json, and styles.css into <vault>/.obsidian/plugins/codefile/ to try it in a vault.