amyreese / markdown-pp

Preprocessor for Markdown files to generate a table of contents and other documentation needs
MIT License
309 stars 68 forks source link

Forcing the encoding from the Processor down to the modules #78

Closed VincenzoLaSpesa closed 3 years ago

VincenzoLaSpesa commented 3 years ago

On windows there is still the issue of the wrong encoding if the sources use some unicode characters. With this I exposed the encoding parameter to the MarkdownPP class and now I can call it with:

MarkdownPP(input=infile, modules=['include', 'toc'], output=outfile, encoding="UTF8")

If no encoding is provided it's defaulted to sys.getdefaultencoding()

It was a quick fix I needed for one of my project, I'm open to any suggestion for writing it better.