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

generate_chapter()   A

Complexity

Conditions 2

Size

Total Lines 11

Duplication

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