Skip to content
Multiple languages code blocks for GitBook
Branch: master
Clone or download
Pull request Compare This branch is 35 commits ahead of GitbookIO:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
assets
.gitignore
README.md
index.js
package.json
preview.png

README.md

path param codetabs

Include multiple languages code block to your GitBook (for example when documenting an API).

Preview

Installation

Adds the plugin to your book.json, then run gitbook install if you are building your book locally.

{
    "plugins": ["path-params-codetabs"]
}

Highlight Path Parameter

In order to highlight path parameters, change {% codetabs %} to {% pathCodetabs %}, then cover up the parameter with {}.

{% pathCodetabs name="CURL", type="bash" -%}
curl -X POST http://genius.genie.ggg/abc/{userId}/{HelloCount}/hey
{% endcodetabs %}

Highlight Path Parameter Example

Using codetabs

This is a code block with tabs for each languages:

{% pathCodetabs name="Python", type="py" -%}
msg = "Hello World"
print msg
{%- language name="JavaScript", type="js" -%}
var msg = "Hello World";
console.log(msg);
{%- endpathCodetabs %}

Escaping templating syntax

For languages using syntax like {{, {%; we have to escape these content:

Here is some angular and react code

{% codetabs name="Python", type="py" -%}
    {% raw %}
    <h1>Hello {{yourName}}!</h1>
    {% endraw %}
{%- language name="React", type="js" -%}
var React = require('react')
{%- endcodetabs %}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.