Home

Awesome

Obsidian Code Previews Plugin

中文

Example

Specific examples can be use Open folder as vault open example.zip.

Path

<details open> <summary> Basic </summary>

Code language is extname by path

<pre><code>```preview path: hello.js ```</code></pre> </details> <details open> <summary> Relative Path </summary> <pre><code>```preview path: ./hello.js ```</code></pre> </details> <details open> <summary> Absolute Path </summary>

The root path is Vault folder

<pre><code>```preview path: /sub/color.css ```</code></pre> <pre><code>```preview path: /hello.js ```</code></pre> </details>

CodeBlock language

Code language is extname by path

Language key: languagelang

<details open> <summary> language、lang </summary> <pre><code>```preview path: ./hello.js lang: ts ```</code></pre> <pre><code>```preview path: ./hello.js language: ts ```</code></pre> </details>

Select display line range

custom start or end

<details open> <summary> The third line of the file ends </summary> <pre><code>```preview path: /sub/color.css start: 3 ```</code></pre> </details> <details open> <summary> The first line to the third line </summary> <pre><code>```preview path: /sub/color.css end: 3 ```</code></pre> </details> <details open> <summary> Only preview the third line </summary> <pre><code>```preview path: /sub/color.css start: 3 end: 3 ```</code></pre> </details> <details open> <summary> Line Range </summary> <pre><code>```preview path: /sub/color.css start: 2 end: 3 ```</code></pre> </details> <details open> <summary> end increase by start </summary>

end: "+1", config " is required.

<pre><code>```preview path: /sub/color.css start: 2 end: "+1" ```</code></pre> </details> <details open> <summary> Use RegExp or Search text) </summary>

/dd\d{2}/

<pre><code>```preview path: /sub/color.css start: body end: /dd\d{2}/ ```</code></pre>

If you don't know RegExp, just use text directly. like:

start: body: match body inside the line end: dd00dd: match dd00dd inside the line

<pre><code>```preview path: /sub/color.css start: body end: dd00dd ```</code></pre> </details>

Highlight

<details open> <summary> By line </summary> <pre><code>```preview path: /sub/color.css highlight: 1 ```</code></pre> </details> <details open> <summary> Range </summary> <pre><code>```preview path: /sub/color.css highlight: 1-3 ```</code></pre> </details> <details open> <summary> Search text </summary> <pre><code>```preview path: /sub/color.css highlight: dd00dd ```</code></pre> </details> <details open> <summary> RegExp </summary> <pre><code>```preview path: /sub/color.css highlight: /dd\d{2}/ ```</code></pre> </details> <details open> <summary> Multi rule </summary>

Separator ,.

<pre><code>```preview path: /sub/color.css highlight: /dd\d{2}/, 1, body ```</code></pre>

YAML list

<pre><code>```preview path: /sub/color.css highlight: - /dd\d{2}/ - 1 - body ```</code></pre> </details>

CodeBlock YAML config

ConfigDescriptionTypeDefault
pathfile pathstringRequired
startpreview start line. Start with 1number or string or RegExp-
endpreview end line.number or string or RegExp-
highlighthighlight linesnumber or string or RegExp-
linenumberdisplay line Numbers, priority is greater than the plugin configurationtrue or falseplugin config

Plugin configuration

ConfigDescriptionTypeDefault
watchAliasListening Alias folder changes, update input suggest. May affect performancebooleanfalse
watchCodeListen to the previewed code file and update the render when the file changes. May affect performancebooleanfalse
highLightColorhighlight backgroundcss color#2d82cc20
includeinclude path, Empty is AllArray<string or RegExp>[]
excludeexclude pathArray<string or RegExp>["node_modules", ".obsidian"]
includeFileinclude file, RequiredArray<string or RegExp>["/\.js$/", "/\.css$/"]
excludeFileexclude fileArray<string or RegExp>[]
aliasalias pathstring | Aliascode
linenumberdisplay linenumbertrue or falsetrue

Thank

linenumber, highlight Based on obsidian-better-codeblock his implementation