Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assume UTF-8 encoding for .markdown and .haml - using new Git.readFile functionality #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pirxpilot
Copy link

Only pull after new version of git-fs is published to npm.
This should fix encoding problems #18, #28 etc.
Tested with howtonode.org - seems OK.

Reads .markdown, .haml and snippets as "utf8"
Everything else is read as raw buffers - no conversion needed.

Reads .markdown, .haml and snippets as "utf8"
Everything else is read as raw buffers - no conversion needed.
@creationix
Copy link
Owner

Why not read everything as buffers. They automatically toString to utf8 strings when coerced.

@pirxpilot
Copy link
Author

I had another look. I am pretty sure my patch loads them as strings (i.e. explicitly passing 'utf8' encoding) only when they are used as strings. The results of Git.readFile are passed to 'Haml.compile' and various string methods (substr, match etc.) are called on them: I don't think such usage triggers implicit coercion.

There was actually one explicit conversion that I was able to remove from prepareMarkdown:

if (!(typeof markdown === 'string')) {
  markdown = markdown.toString();
}

After reading your comment I experimented with loading everything as buffers and wheat predictably breaks in couple of places.
What am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants