With the help of a number of people in the Elixir community, I was able to find two solutions to the problem.
The problem stems from Elixir's default use of utf-8 as the basic encoding for strings. This in itself is not a problem. It becomes a problem because Windows' console subsystem has a poor handling of utf-8.
Earmark uses smartypants to transform single and double quotes into curly single and double quotes. This is where Windows' console gets confused and prints gibberish.
Solutions:
- For the html rendering
The best solution here is to add utf-8 encoding in the template for the final html page.
<meta charset="utf-8" />
If you don't care about smart quotes, then you can also call Earmark with the smartypants option set to false to avoid using it
Earmark.as_html(markdown, %Earmark.Options{smartypants: false})
- For the console
Here you need to set the the console font to Lucida and run the command below , according to this question on stackoverflow
chcp 65001
I used it and it worked on my Windows 10 machine.
Notes: Thanks for Iinspectable for correcting a statement on Windows and utf-8 :)