экранирование символов при помощи html.encode
, теперь сгенерированные документы открываются
This commit is contained in:
parent
683e32bee8
commit
30a567fc9d
@ -1,6 +1,7 @@
|
|||||||
from docxtpl import DocxTemplate
|
from docxtpl import DocxTemplate
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
|
import html
|
||||||
|
|
||||||
# Загрузка шаблона
|
# Загрузка шаблона
|
||||||
doc = DocxTemplate("template/source-code-template.docx")
|
doc = DocxTemplate("template/source-code-template.docx")
|
||||||
@ -14,9 +15,10 @@ def get_sources(source_root):
|
|||||||
|
|
||||||
def _get_file_context(source_root, filename):
|
def _get_file_context(source_root, filename):
|
||||||
with open(source_root + filename, 'r', encoding="utf8") as f:
|
with open(source_root + filename, 'r', encoding="utf8") as f:
|
||||||
|
content = f.read()
|
||||||
return {
|
return {
|
||||||
'filename': filename.replace('\\', '/'), # для шиндовс, чтобы правильно генерить пути
|
'filename': filename.replace('\\', '/'), # для шиндовс, чтобы правильно генерить пути
|
||||||
'content': f.read()
|
'content': html.escape(content, quote=True)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user