Passed
Push — master ( 1ac98c...ed1e15 )
by P.R.
01:49
created

TextHtmlFormatter.generate()   A

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
crap 1
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9 1
from sdoc.helper.Html import Html
10 1
from sdoc.sdoc2.NodeStore import NodeStore
11 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
12
13
14 1
class TextHtmlFormatter(HtmlFormatter):
15
    """
16
    HtmlFormatter for generating HTML code for text.
17
    """
18
19
    # ------------------------------------------------------------------------------------------------------------------
20 1
    def generate(self, node, file):
21
        """
22
        Generates the HTML code for a text node.
23
24
        :param sdoc.sdoc2.node.TextNode.TextNode node: The text node.
25
        :param file file: The output file.
26
        """
27 1
        file.write(Html.escape(node.argument))
28
29 1
        HtmlFormatter.generate(self, node, file)
30
31
32
# ----------------------------------------------------------------------------------------------------------------------
33
NodeStore.register_formatter('TEXT', 'html', TextHtmlFormatter)
34