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

render_kramdown_list.js « renderers « services « rich_content_editor « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 949ca0e5c2a38556d1ce1be84106daf87428bbc6 (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
import { renderUneditableBranch as render } from './render_utils';

const isKramdownTOC = ({ type, literal }) => type === 'text' && literal === 'TOC';

const canRender = node => {
  let targetNode = node;
  while (targetNode !== null) {
    const { firstChild } = targetNode;
    const isLeaf = firstChild === null;
    if (isLeaf) {
      if (isKramdownTOC(targetNode)) {
        return true;
      }

      break;
    }

    targetNode = targetNode.firstChild;
  }

  return false;
};

export default { canRender, render };