Import Code Snippets โ
You can import code snippets from existing files via the following syntax:
md
<<< @/snippets/snippet.jsTIP
The value of @ corresponds to your package's root directory. It's recommended to put snippets in @/snippets in order to be compatible with the Monaco editor. Alternatively, you can also import from relative paths.
You can also use a VS Code region to only include the corresponding part of the code file:
md
<<< @/snippets/snippet.js#region-nameTo explicitly specify the language of the imported code, you can add a language identifier after:
md
<<< @/snippets/snippet.js tsAny code block features like line highlighting and Monaco editor are also supported:
md
<<< @/snippets/snippet.js {2,3|5}{lines:true}
<<< @/snippets/snippet.js ts {monaco}{height:200px}Note that you can use {*} as a placeholder of โจ Line Highlighting:
md
<<< @/snippets/snippet.js {*}{lines:true}