Completed
Pull Request — master (#22)
by Oleg
01:36
created

generate_chapter()   A

Complexity

Conditions 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 13
rs 9.4285
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9
from sdoc.sdoc2 import node_store
10
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
11
12
13
class ParagraphHtmlFormatter(HtmlFormatter):
14
    """
15
    HtmlFormatter for generating HTML code for paragraph.
16
    """
17
    # ------------------------------------------------------------------------------------------------------------------
18
    def generate(self, node, file):
19
        """
20
        Generates the HTML code for a paragraph node.
21
22
        :param sdoc.sdoc2.node.ParagraphNode.ParagraphNode node: The paragraph node.
23
        :param file file: The output file.
24
        """
25
        file.write('<p>')
26
        super().generate(node, file)
27
        file.write('</p>')
28
29
    # ------------------------------------------------------------------------------------------------------------------
30
    def generate_chapter(self, node, file):
31
        """
32
        Generates the HTML code for a paragraph node.
33
34
        :param sdoc.sdoc2.node.ParagraphNode.ParagraphNode node: The paragraph node.
35
        :param file file: The output file.
36
        """
37
        if file:
38
            file.write('<p>')
39
            super().generate_chapter(node, file)
40
            file.write('</p>')
41
        else:
42
            super().generate_chapter(node, file)
43
44
# ----------------------------------------------------------------------------------------------------------------------
45
node_store.register_formatter('paragraph', 'html', ParagraphHtmlFormatter)
46