A plugin is an extension that adds additional features to MarkBind. Some non-essential MarkBind functionalities are provided as plugins so that you can enable/disable/configure them as necessary. MarkBind also supports adding external plugins (written by you or other third parties).
MarkBind's philosophy is to bake-in all necessary functionality into MarkBind itself rather than expect users to go hunting for suitable plugins. Hence, we do not anticipate MarkBind users to rely heavily on such external plugins.
Managing Plugins
Plugins are managed via the following two properties in the site.json.
plugins: An array of plugin names to use.
pluginsContext: Parameters passed to each plugin, specified as key-value pairs.
Alternatively, if you are using a custom search bar, you can assign the div element the id algolia-search-input to connect it to Algolia DocSearch.
<divid="algolia-search-input"></div>
By default, Algolia DocSearch indexes all content on the page, including content in components that are hidden to the user during the initial render (e.g. Panels). To exclude these content from being indexed, you can add .algolia-no-index to the selectors_exclude attribute in your DocSearch configuration.
The algolia-no-index class is automatically added to content hidden by MarkBind's Vue components. You may also add the algolia-no-index class to content that you do not want to be indexed by Algolia DocSearch.
Plugin: codeBlockCopyButtons
This plugin adds a copy button to fenced code blocks so that readers can copy the code easily.
To enable it, simply add codeBlockCopyButtons to your site's plugins.
site.json
{
...
"plugins": [
"codeBlockCopyButtons" ],
}
This is what it'll look like once added:
Plugin: codeBlockWrapButtons
This plugin adds a wrap text button to fenced code blocks so that readers can read long lines of code without scrolling sideways.
To enable it, simply add codeBlockWrapButtons to your site's plugins.
site.json
{
...
"plugins": [
"codeBlockWrapButtons" ],
}
This is what it'll look like once added:
Clicking the wrap text button will result in the following:
In case a single long word is encountered, it will be split across multiple lines similar to the following:
Plugin: Tags
With this plugin you can use tags to selectively filter content when building a site.
Toggling alternative contents
Tags are specified by the tags attribute, and can be attached to any HTML element. During rendering, only elements that match tags specified in the site.json files will be rendered.
All other tagged elements will be filtered out. In this case, only the element with the language--java tag will be rendered. This is helpful when creating multiple versions of a page without having to maintain separate copies.
If the filterTags plugin is not enabled in site.json, all tagged elements will be rendered.
You can also use multiple tags in a single HTML element. Specify each tag in the tags attribute separated by a space. An element will be rendered if any of the tags matches the one in site.json.
Example Attaching multiple tags to an element:
# For loops
<ptags="language--java language--C#">for (int i = 0; i < 5; i++) { ... }</p>
As long as the language--java or language--C# tag is specified, the code snippet will be rendered.
Alternatively, you can specify tags to render for a page in the frontmatter.
language--java is overridden by -language--*, so only language--C# is shown.
This only works because tags are processed left to right, so all language--* tags are hidden before language--C#. Tags in site.json are processed after tags in <frontmatter>.
Then, to add a Disqus comment section on a page, all you need to do is to add a <disqus/> HTML tag to any MarkBind source file.
It may be a good idea to create a layout with <disqus/> in it, so that you won't have to repeat it on every page.
Plugin: MathDelimiters
This plugin allows you to use additional delimiters for your math formulae. Available delimiters are listed in the markdown-it-texmath package.
These delimiters are supported without guarantee that they will be rendered correctly, especially when they happen to conflict with
other MarkBind syntax.
Note that the default delimiters still function as expected, this plugin simply adds the additional delimiters.
To enable this plugin, add mathDelimiters to your site's plugins and specify the delimters in the context.
The access key is exposed to public.
This is generally ok since the access key is an alias to your email and is equivalent to revealing your email to public.
However it is possible that malicious users might use the access key in other forms.
This might subject the email linked to the access key to spam with irrelevant form submissions.
To add a form to your site, use a <web-3-form> tag.
Web3Forms plugin also supports a default 'Contact Us' form.
The header will be <p class="h2">Contact Us</p> for the default form if no header is specified.
This uses Bootstrap to style the header.
CODE:
<web-3-formdefault />
OUTPUT:
Contact Us
CODE:
<web-3-formdefaultheader="**New header**"/>
OUTPUT:
New header
Web3Forms plugin supports common inputs.
The inputs supported are
name-input
email-input
message-input
submit-button
CODE:
<web-3-formheader="**Form with name input**"><name-input></name-input></web-3-form><web-3-formheader="**Form with email input**"><email-input></email-input></web-3-form><web-3-formheader="**Form with message input**"><message-input></message-input></web-3-form><web-3-formheader="**Form with submit button**"><submit-button></submit-button></web-3-form>
OUTPUT:
Form with name input
Form with email input
Form with message input
Form with submit button
Web3Forms plugin supports customised header and styles
<web-3-formdefaulttype="warning"header="Here's a form :rocket:"color="red"dismissible></web-3-form>
OUTPUT:
Here's a form 🚀
Plugin: DataTable
The DataTable plugin enhances the functionality of tables in your MarkBind site by integrating the DataTables library. It allows you to add searching and sorting capabilities to your tables with minimal configuration. The necessary CSS and JavaScript files are already included in the project, so no additional CDN or plugin context configuration is required.
To enable this plugin, simply add dataTable to your site's plugins:
site.json
{
...
"plugins": [
"dataTable" ]
}
To create a table with DataTable features, use one of the following syntaxes:
<d-tablesearchable>| Book Title | Author | Year Published |
|---------------------------|------------------|----------------|
| To Kill a Mockingbird | Harper Lee | 1960 |
| 1984 | George Orwell | 1949 |
| Pride and Prejudice | Jane Austen | 1813 |
| The Great Gatsby | F. Scott Fitzgerald | 1925 |
</d-table>
OUTPUT:
Book Title
Author
Year Published
To Kill a Mockingbird
Harper Lee
1960
1984
George Orwell
1949
Pride and Prejudice
Jane Austen
1813
The Great Gatsby
F. Scott Fitzgerald
1925
Example Sortable and Searchable Table:
CODE:
<d-tablesortablesearchable>| City | Country | Population |
|-------------|-----------|------------|
| New York | USA | 8,336,817 |
| London | UK | 9,002,488 |
| Paris | France | 2,161,063 |
| Tokyo | Japan | 13,960,236 |
| Sydney | Australia | 5,367,206 |
</d-table>
OUTPUT:
City
Country
Population
New York
USA
8,336,817
London
UK
9,002,488
Paris
France
2,161,063
Tokyo
Japan
13,960,236
Sydney
Australia
5,367,206
The DataTable plugin automatically renders the table with the specified features based on the presence of the sortable and searchable attributes in the <d-table> tag. You can use either one or both attributes to control the desired functionality for each table.
Plugin: Mermaid
This plugin allows you to utilize Mermaid by automatically importing the library and initializing the rendering of the diagrams.
Mermaid is a JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically.
To enable this plugin, add mermaid to your site's plugins.
site.json
{
...
"plugins": [
"mermaid" ]
}
Optional: Specify an alternative URL to load the Mermaid code
To create a Mermaid diagram, use the <mermaid> tag and provide the diagram definition within the tag. Usage of standard Mermaid syntax using the <pre class="mermaid"> block directly in Markdown files is also supported for users who prefer to do so.
Example Pie Chart:
CODE:
<mermaid>pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 15
</mermaid><preclass="mermaid">%%{init: {"pie": {"textPosition": 0.5}, "themeVariables": {"pieOuterStrokeWidth": "5px"}, 'theme': 'dark'} }%%
pie showData
title Key elements in Product X
"Calcium" : 42.96
"Potassium" : 50.05
"Magnesium" : 10.01
"Iron" : 5
</pre>
OUTPUT:
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 15
%%{init: {"pie": {"textPosition": 0.5}, "themeVariables": {"pieOuterStrokeWidth": "5px"}, 'theme': 'dark'} }%%
pie showData
title Key elements in Product X
"Calcium" : 42.96
"Potassium" : 50.05
"Magnesium" : 10.01
"Iron" : 5
Example Flowchart:
CODE:
<mermaid>flowchart TD
A[Start] --> B{Is it?}
B -->|Yes| C[OK]
C --> D[Rethink]
D --> B
B ---->|No| E[End]
</mermaid>
OUTPUT:
flowchart TD
A[Start] --> B{Is it?}
B -->|Yes| C[OK]
C --> D[Rethink]
D --> B
B ---->|No| E[End]
Example User Journey Diagram:
CODE:
<mermaid>journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
</mermaid>
OUTPUT:
journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
The plugin automatically converts the <mermaid> tags into appropriate <pre> elements for rendering the diagrams using the Mermaid library.
Using External Plugins
Adding External Plugins
WARNING: Plugins are executable programs that can be written by anyone. This means that they might contain malicious code that may damage your computer.
Only run plugins from sources that you trust. Do not run the plugin if the source/origin of the plugin cannot be ascertained.
Plugins come as .js files. To install an external plugin, simply put it in the _markbind/plugins folder. To use the plugin, update the site.json file the same way you did for built-in plugins.
Writing Plugins
You may also write your own plugins! Refer here for the available interfaces to do so.