1<?php
2
3/**
4 * Created by IntelliJ IDEA.
5 * User: michael
6 * Date: 7/7/17
7 * Time: 4:49 PM
8 */
9
10namespace dokuwiki\plugin\prosemirror\parser;
11
12class HeadingNode extends Node
13{
14    protected $parent;
15    protected $level;
16    protected $text;
17
18    public function __construct($data, Node $parent)
19    {
20        if (trim($data['content'][0]['text']) === '') {
21            return;
22        }
23
24        $this->parent = &$parent;
25        $this->level = $data['attrs']['level'];
26        $this->text = $data['content'][0]['text'];
27    }
28
29    public function toSyntax()
30    {
31        $wrapper = [
32            1 => '======',
33            2 => '=====',
34            3 => '====',
35            4 => '===',
36            5 => '==',
37        ];
38
39        return $wrapper[$this->level] . ' ' . $this->text . ' ' . $wrapper[$this->level];
40    }
41}
42