Skip to content

Commit

Permalink
Allow adding empty markdown files when creating empty book records
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Nov 20, 2020
1 parent 95c3c42 commit 10971de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/calibre/ebooks/oeb/polish/create.py
Expand Up @@ -24,7 +24,7 @@
from calibre.utils.zipfile import ZipFile, ZIP_STORED
from polyglot.builtins import as_bytes

valid_empty_formats = {'epub', 'txt', 'docx', 'azw3'}
valid_empty_formats = {'epub', 'txt', 'docx', 'azw3', 'md'}


def create_toc(mi, opf, html_name, lang):
Expand All @@ -45,6 +45,11 @@ def create_book(mi, path, fmt='epub', opf_name='metadata.opf', html_name='start.
if not mi.is_null('title'):
f.write(as_bytes(mi.title))
return
if fmt == 'md':
with open(path, 'w', encoding='utf-8') as f:
if not mi.is_null('title'):
print('#', mi.title, file=f)
return
if fmt == 'docx':
from calibre.ebooks.conversion.plumber import Plumber
from calibre.ebooks.docx.writer.container import DOCX
Expand Down

0 comments on commit 10971de

Please sign in to comment.