|
From: Andreas K. <an...@ka...> - 2018-12-03 16:47:12
|
Hi,
I am probably doing something fundamentally wrong. I get a 'TypeError:
write() argument must be str, not bytes' message when I use
the markdown.markdownFromFile method when with an output file which I have
already opened for writing:
fd_html = open(htmlPath, 'w', encoding='utf-8')
markdown.markdownFromFile(input=mdPath,
output=fd_html,
encoding='utf-8',
extensions=['markdown.extensions.tables',
'markdown.extensions.def_list',
'markdown.extensions.footnotes', 'markdown.extensions.fenced_code',
'markdown.extensions.codehilite', 'markdown.extensions.attr_list']
)
fd_html.close()
If I let markdown.markdownFromFile open it instead it works fine:
markdown.markdownFromFile(input=mdPath,
output=htmlPath ,
encoding='utf-8',
extensions=['markdown.extensions.tables',
'markdown.extensions.def_list',
'markdown.extensions.footnotes', 'markdown.extensions.fenced_code',
'markdown.extensions.codehilite', 'markdown.extensions.attr_list']
)
The reason I want to open it myself if that i need to insert some more html
before the stuff generated by markdown.markdownFromFile.
What am I doing wrong?
/Andreas
|