Skip to content

sbaechler/plugin-codesnippet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Include code snippets in your GitBook

This plugins makes it easy to import code files or uses variables in codeblocks in your GitBook.

How to use it?

Add it to your book.json configuration:

{
    "plugins": ["codesnippet"]
}

And then in your content:

This is a code snippet:

{% codesnippet "./myfile.js" %}{% endcodesnippet %}

Using a specific language:

This is a code snippet, display as HTML:

{% codesnippet "./myfile.ejs", language="html" %}{% endcodesnippet %}

Include a range of lines:

This is a code snippet, display as HTML:

{% codesnippet "./myfile.ejs", lines="2:5" %}{% endcodesnippet %}

Code blocks with templating syntax:

This is a code snippet, display as HTML:

{% codesnippet %}
curl {{ book.hostname|d("http://localhost") }}/myapi
{% endcodesnippet %}

About

Block to easily insert a file as a code block

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%