Replace [TOC] markers with tables of contents in your exports


Here is a custom template based on “Styled HTML” that will substitute [TOC] markers with tables of contents (mostly for backward compatibility with SEv4).


<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="" />

{{#if pdf}}
<body class="stackedit stackedit--pdf">
<body class="stackedit">
  <div class="stackedit__html">{{#transformToc files.0.content.toc}}{{{files.0.content.html}}}{{/transformToc}}</div>



Handlebars.registerHelper('transformToc', function (toc, options) {
  var result = options.fn(this);
  var toc = '<div class="toc">' +, toc) + '</div>';
  return new Handlebars.SafeString(
    result.replace(/\[toc\]/gi, toc)

How to use the table of contents from the side bar?

Sorry to revive the topic, but here it returns an error:
TypeError: options.fn is not a function.

Is it normal?