diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..adbf108 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include novel_compiler templates *.docx \ No newline at end of file diff --git a/novel_compiler/novel_compiler.py b/novel_compiler/novel_compiler.py index e96dbbc..7ab79a3 100644 --- a/novel_compiler/novel_compiler.py +++ b/novel_compiler/novel_compiler.py @@ -6,6 +6,7 @@ import tempfile import MarkdownPP import json from lxml import etree +from importlib.resources import path TITLE_MARKER = '# ' AUTHOR_MARKER = '### ' @@ -123,8 +124,12 @@ def main(): ) arguments = parser.parse_args() - arguments.template.close() - doc = DocxTemplate(arguments.template.name) + if arguments.template: + arguments.template.close() + doc = DocxTemplate(arguments.template.name) + else: + with path('novel_compiler.templates', 'novel.docx') as novel_template: + doc = DocxTemplate(novel_template) if arguments.pp: mdfile = tempfile.TemporaryFile(mode='w+') MarkdownPP.MarkdownPP( diff --git a/novel_compiler/templates/__init__.py b/novel_compiler/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/novel_compiler/template.docx b/novel_compiler/templates/template.docx similarity index 100% rename from novel_compiler/template.docx rename to novel_compiler/templates/template.docx