Cimbali / markdown-viewer

Markdown (.md) file viewer WebExtension for your browser.
Other
165 stars 28 forks source link

UTF-8 encoding #34

Closed gaul closed 6 years ago

gaul commented 6 years ago

Which character encoding does Markdown View use? I see rendered as ✓.

y6nH commented 6 years ago

The generated HTML document does not specify an encoding for UTF-8 files without a byte order mark. If you have control of the file you're viewing, make sure you save it as UTF-8 with a BOM. Otherwise, you can find the character encoding options hidden deep in the browser menu and set it there.

It would be nice to have the generated HTML default to UTF-8.

Keith94 commented 6 years ago

Also with this .md file, it renders · like ·

KeithLRobertson commented 6 years ago

It would be nice to have the generated HTML default to UTF-8

UTF-8 is a mapping from characters to/from bytes. Character encoding is only relevant when you're working with byte streams, for example when covering the .md file (a byte stream) into a markdown character stream. The extension takes the markdown character stream and converts it into an HTML character stream (using markdown-it), and displays that in the browser. It never handles HTML as a byte stream. Therefore, character encoding is not relevant when we're talking about the generated HTML.

I see ✓ rendered as ✓. renders · like ·

As noted in several other issues, this extension requires a BOM on the markdown file so that it can determine the character encoding. If you can determine how to make it default to UTF-8, I would welcome the PR submission.