Extension
<gem-book> renders Markdown and also extends the Markdown syntax. In addition, some methods are provided for users to customize <gem-book>.
Markdown enhancement
Code blocks info string
Syntax:
Use highlight example:
Fixed heading anchor hash
By default, hash is generated based on the title text field, but sometimes you need to fix the hash, such as internationalization.
Highlight blockquote
NOTE
This is
[!NOTE]
TIP
This is
[!TIP]
IMPORTANT
This is
[!IMPORTANT]
WARNING
This is
[!WARNING]
CAUTION
This is
[!CAUTION]
Slots
Slot allows you to customize <gem-book> but the content, currently supported slots are sidebar-before, main-before, main-after, nav-inside.
Can use --template specified template file
Plugins
Use plugin
GemBook uses custom elements as a plugin system, they can customize the rendering of Markdown content or enhance the ability of <gem-book>. The following is how to use the built-in plugin <gbp-raw>.
import plugin:
Then use it in Markdown to render files in the warehouse:
TIP
Attribute should not be line break when using a plugin in Markdown, otherwise it will be interrupted by the
<p>tag as the inline element.GemBook built-in plugin supports automatic import, the disadvantage is that it will be loaded after rendering documents. It is possible that the page will flash
VSCode cannot use Emmet in MarkDown files by default. You can enable it through settings:
"emmet.excludeLanguages": [], "emmet.includeLanguages": {"markdown": "html"},
Plugin development
GemBook exposes a class GemBookPluginElement, which extends from GemElement,
GemBookPluginElement and read the <gem-book> configuration in the following way: