toc-and-anchor.js 622 B

123456789101112131415161718192021222324252627
  1. export default class TocAndAnchorConfigurer {
  2. constructor(crowi, renderToc) {
  3. this.crowi = crowi;
  4. this.renderToc = renderToc;
  5. }
  6. configure(md) {
  7. md.use(require('markdown-it-toc-and-anchor-with-slugid').default, {
  8. tocLastLevel: 3,
  9. anchorLinkBefore: false,
  10. anchorLinkSymbol: '',
  11. anchorLinkSymbolClassName: 'icon-link',
  12. anchorClassName: 'revision-head-link',
  13. });
  14. // set toc render function
  15. if (this.renderToc != null) {
  16. md.set({
  17. tocCallback: (tocMarkdown, tocArray, tocHtml) => {
  18. this.renderToc(tocHtml);
  19. },
  20. });
  21. }
  22. }
  23. }