Total Complexity | 1 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | from typing import Any |
||
2 | |||
3 | from sdoc.helper.Html import Html |
||
4 | from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter |
||
5 | from sdoc.sdoc2.node.TextNode import TextNode |
||
6 | from sdoc.sdoc2.NodeStore import NodeStore |
||
7 | |||
8 | |||
9 | class TextHtmlFormatter(HtmlFormatter): |
||
10 | """ |
||
11 | HtmlFormatter for generating HTML code for text. |
||
12 | """ |
||
13 | |||
14 | # ------------------------------------------------------------------------------------------------------------------ |
||
15 | def generate(self, node: TextNode, file: Any) -> None: |
||
16 | """ |
||
17 | Generates the HTML code for a text node. |
||
18 | |||
19 | :param TextNode node: The text node. |
||
20 | :param any file: The output file. |
||
21 | """ |
||
22 | file.write(Html.escape(node.argument)) |
||
23 | |||
24 | HtmlFormatter.generate(self, node, file) |
||
25 | |||
26 | |||
27 | # ---------------------------------------------------------------------------------------------------------------------- |
||
28 | NodeStore.register_formatter('TEXT', 'html', TextHtmlFormatter) |
||
29 |