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 DocumentHtmlFormatter(HtmlFormatter): |
14
|
|
|
""" |
15
|
|
|
HtmlFormatter for generating HTML code for document. |
16
|
|
|
""" |
17
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
18
|
|
|
def generate(self, node, file): |
19
|
|
|
""" |
20
|
|
|
Generates the HTML code for a document node. |
21
|
|
|
|
22
|
|
|
:param sdoc.sdoc2.node.DocumentNode.DocumentNode node: The document node. |
23
|
|
|
:param file file: The output file. |
24
|
|
|
""" |
25
|
|
|
file.write('<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="NL" lang="NL">') |
26
|
|
|
file.write('<head><meta charset="UTF-8"/><title>sdoc</title></head>') |
27
|
|
|
file.write('<body>') |
28
|
|
|
|
29
|
|
|
super().generate(node, file) |
30
|
|
|
|
31
|
|
|
file.write('</body>') |
32
|
|
|
file.write('</html>') |
33
|
|
|
file.close() |
34
|
|
|
|
35
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
36
|
|
|
def generate_chapter(self, node, file): |
37
|
|
|
""" |
38
|
|
|
Passing the document node, because not used in generating chapters of a document. |
39
|
|
|
|
40
|
|
|
:param sdoc.sdoc2.node.DocumentNode.DocumentNode node: The document node. |
41
|
|
|
:param file file: The output file. |
42
|
|
|
""" |
43
|
|
|
super().generate_chapter(node, file) |
44
|
|
|
|
45
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
46
|
|
|
node_store.register_formatter('document', 'html', DocumentHtmlFormatter) |
47
|
|
|
|