项目作者: hiro0218

项目描述 :
generate "table of contents".
高级语言: TypeScript
项目地址: git://github.com/hiro0218/mokuji.js.git
创建时间: 2017-06-07T16:57:20Z
项目社区:https://github.com/hiro0218/mokuji.js

开源协议:MIT License

下载


mokuji.js

A table of content JavaScript Library.

Installation

  1. npm install --save mokuji.js

Usage

  1. import { Mokuji } from 'mokuji.js';
  2. const textElement = document.querySelector('.text');
  3. const mokujiList = Mokuji(textElement);
  4. if (!mokujiList) return;
  5. const listElement = document.querySelector('.list');
  6. listElement?.appendChild(mokujiList);

Options

  1. {
  2. anchorType: true,
  3. anchorLink: false,
  4. anchorLinkSymbol: '#',
  5. anchorLinkPosition: 'before',
  6. anchorLinkClassName: '',
  7. anchorContainerTagName: 'ol',
  8. minLevel: 1,
  9. maxLevel: 6,
  10. }

anchorType

(default: true)

Like Wikipedia’s anchor, multibyte characters are replaced by escape sequences.

こんにちは.E3.81.93.E3.82.93.E3.81.AB.E3.81.A1.E3.81.AF

(default: false)

enable/disable the anchor link in the headings

anchorLinkSymbol

(default: '#')

set the anchor link symbol

anchorLinkPosition

(default: 'before')

set position (before/after) the anchor link in headings.

anchorLinkClassName

(default: '')

set anchor link class name. Multiple class names can be specified with spaces.

anchorContainerTagName

(default: 'ol')

set the container element tag name for the table of contents. Possible values are ‘ol’ or ‘ul’.

minLevel

(default: 1)

set the minimum heading level to include in the table of contents (1 means h1).

maxLevel

(default: 6)

set the maximum heading level to include in the table of contents (6 means h6).