MCPcopy Index your code
hub / github.com/almariah/embed-code-file

github.com/almariah/embed-code-file @1.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.2.0 ↗ · + Follow
17 symbols 33 edges 5 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Embed Code File (Obsidian Plugin)

This plugin allows to embed code files from Obsidian vault or remote file (eg., GitHub). It works better with live preview feature of Obsidian.

Settings

The plugin include multiple language by default (c,cpp,java,python,go,ruby,javascript,js,typescript,ts,shell,sh,bash). You can include any needed language to the comma separated list.

How to use

First you need to activate the plugin from Community Plugins. Then you can embed the code as follow:

```embed-<some-language>
PATH: "vault://<some-path-to-code-file>" or "http[s]://<some-path-to-remote-file>"
LINES: "<some-line-number>,<other-number>,...,<some-range>"
TITLE: "<some-title>"
```

Examples:

Vault File:

```embed-cpp
PATH: "vault://Code/main.cpp"
LINES: "2,9,30-40,100-122,150"
TITLE: "Some title"
```

Remote File:

```embed-cpp
PATH: "https://raw.githubusercontent.com/almariah/embed-code-file/main/main.ts"
LINES: "30-40"
TITLE: "Some title"
```

where PATH, LINES and TITLE properties are set as YAML key-value pairs:

  • The PATH should be a code file in the vault or remote. If you have used GitHub for example, make sure to use https://raw.githubusercontent.com/...

  • The LINES will include only the specified lines of the code file. Every set of included lines either range or explicit line will append dots (...) to included line in a newline. If you want to get rid of dots, minimize the number of sets by using one range as much as you can.

  • If TITLE is not set, then the title of the code block will be PATH value.

You can use also TITLE with normal code block (without embed-), but make sure that the title value is set with double quotes:

```cpp TITLE: "Some title"
// some code
...
```

Using live preview feature will enhance the embedding experience.

Demo

Embed code file

Gif

Embed lines from code file

Gif

Embed lines from remote file (eg., GitHub)

Gif

Add title to normal code block

Gif

Extension points exported contracts — how you extend this code

EmbedCodeFileSettings (Interface)
(no doc)
settings.ts

Core symbols most depended-on inside this repo

saveSettings
called by 3
main.ts
insertTitlePreElement
called by 2
main.ts
analyseSrcLines
called by 1
utils.ts
extractSrcLines
called by 1
utils.ts
loadSettings
called by 1
main.ts
registerRenderer
called by 1
main.ts
addTitleLivePreview
called by 1
main.ts
addTitle
called by 1
main.ts

Shape

Method 9
Class 4
Function 3
Interface 1

Languages

TypeScript100%

Modules by API surface

main.ts9 symbols
settings.ts5 symbols
utils.ts3 symbols

For agents

$ claude mcp add embed-code-file \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact