mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow adding empty markdown files when creating empty book records
This commit is contained in:
parent
95c3c42e2c
commit
10971de4b7
@ -24,7 +24,7 @@ from calibre.utils.logging import DevNull
|
||||
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):
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user