serum v1.0.0 Serum.Plugins.TableOfContents

A Serum plugin that inserts a table of contents.

Using the Plugin

First, add this plugin to your serum.exs:

%{
  plugins: [
    Serum.Plugins.TableOfContents
  ]
}

This plugin works with both pages(.md, .html, and .html.eex) and blog posts(.md). Insert the <serum-toc> tag at the position you want to display a table of contents at.

<serum-toc start="2" end="4"></serum-toc>

The start and end attributes define a range of heading level this plugin recognizes. In the case of the above example, <h1>, <h5>, and <h6> tags are ignored when generating a table of contents.

Notes

You may use <serum-toc> tag more than once in a single page. However, all occurrences of this tag will be replaced with a table of contents generated using the attributes of the first one. That is, for example, all three tags in the code below expand to the same table of contents, showing a 2-level deep list.

<serum-toc start="2" end="3"></serum-toc>
...
<serum-toc></serum-toc>
...
<serum-toc></serum-toc>

It's recommended that you wrap a <serum-toc> tag with a <div> tag when using in a markdown file, to ensure a well-formed structure of HTML output.

<div><serum-toc ...></serum-toc></div>

And finally, make sure you close every <serum-toc> tag properly with </serum-toc>.

Link to this section Summary

Functions

Returns the short description of the plugin.

Returns the version requirement of Elixir.

Returns a list of optional callbacks which the plugin implements.

Returns the name of the plugin.

Called after producing a HTML fragment for each page.

Returns the version requirement of Serum.

Returns the version of the plugin.

Link to this section Functions

Returns the short description of the plugin.

You must implement this callback, or the plugin may fail.

Callback implementation for Serum.Plugin.description/0.

Returns the version requirement of Elixir.

Refer to this document for the string format.

You must implement this callback, or the plugin may fail.

Callback implementation for Serum.Plugin.elixir/0.

Returns a list of optional callbacks which the plugin implements.

For example, if your plugin implements build_started/2 and finalizing/2, you must implement this callback so that it returns [:build_started, :finalizing].

You must implement this callback, or the plugin may fail.

Callback implementation for Serum.Plugin.implements/0.

Returns the name of the plugin.

You must implement this callback, or the plugin may fail.

Callback implementation for Serum.Plugin.name/0.

Link to this function

rendered_fragment(frag)

Called after producing a HTML fragment for each page.

Plugins can modify the contents and metadata of each fragment here.

Callback implementation for Serum.Plugin.rendered_fragment/1.

Returns the version requirement of Serum.

Refer to this document for the string format.

You must implement this callback, or the plugin may fail.

Callback implementation for Serum.Plugin.serum/0.

Returns the version of the plugin.

The returned version string must follow the semantic versioning scheme.

You must implement this callback, or the plugin may fail.

Callback implementation for Serum.Plugin.version/0.