Welcome to mirror list, hosted at ThFree Co, Russian Federation.

table_of_contents.js « nodes « markdown « behaviors « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4a0256c4644ddb34313ac8b5e617f02e1b534282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { __ } from '~/locale';
import { HIGHER_PARSE_RULE_PRIORITY } from '../constants';

// Transforms generated HTML back to GFM for Banzai::Filter::TableOfContentsFilter
export default () => ({
  name: 'table_of_contents',
  schema: {
    group: 'block',
    atom: true,
    parseDOM: [
      {
        tag: 'ul.section-nav',
        priority: HIGHER_PARSE_RULE_PRIORITY,
      },
      {
        tag: 'p.table-of-contents',
        priority: HIGHER_PARSE_RULE_PRIORITY,
      },
    ],
    toDOM: () => ['p', { class: 'table-of-contents' }, __('Table of Contents')],
  },
  toMarkdown: (state, node) => {
    state.write('[[_TOC_]]');
    state.closeBlock(node);
  },
});