-
Notifications
You must be signed in to change notification settings - Fork 3
/
markdown_to_html.py
42 lines (30 loc) · 1.21 KB
/
markdown_to_html.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Convierte archivos markdown a template html de "Acerca" de datosgobar
python markdown_to_html.py sections/publica-datos.md docs/publica-datos.html docs/andino-html/publica-datos.html "Publicá datos"
"""
import sys
import markdown
from andino_templates import PREVIEW_TEMPLATE, SECTION_TEMPLATE
def main(input_path, output_path_preview, output_path_section,
section_name):
# convierte el markdown a html
with open(input_path, "r") as f:
md = f.read()
html = markdown.markdown(md)
# genera el html de la sección para previsualizar en este repo
with open(output_path_preview, "wb") as f:
preview_html = PREVIEW_TEMPLATE.format(
document=html,
section_name=section_name
)
f.write(preview_html.encode("utf-8"))
# genera el html de la sección para subir al container de Andino
with open(output_path_section, "wb") as f:
section_html = SECTION_TEMPLATE.format(
document=html,
section_name=section_name
)
f.write(section_html.encode("utf-8"))
if __name__ == '__main__':
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])