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

Metadata not recognized when file starts with BOM #306

Open
DanielSundberg opened this issue Mar 29, 2016 · 1 comment
Open

Metadata not recognized when file starts with BOM #306

DanielSundberg opened this issue Mar 29, 2016 · 1 comment

Comments

@DanielSundberg
Copy link

When a content file starts with a UTF8 BOM I don't get any metadata which can result in hard-to-find bugs. We're using Wintersmith to generate a docs site and we allow multiple users to add content. It is very easy to unintentionally save a file with wrong BOM configuration.

To reproduce:

Create a Wintersmith site:


C:\Code\> wintersmith new .\test-site
initializing new wintersmith site in C:\Code\test-site using template blog
C:\Code\test-site
+-- [email protected]
+-- [email protected]
`-- [email protected]
done!
preinstall:. -> lifecycle / |#########################################################################--------|

Run wintersmith preview and navigate to the index page and check that the readme article is present:

2016-03-29 15_37_40-clipboard

Next open contents\articles\hello-world\index.md using an editor that can add a BOM char at the beginning of the file. In Notepad++ select Encoding/Convert to UTF-8 and save the file.

Refresh the preview and notice that the README link is missing:

2016-03-29 15_39_57-the wintersmith s blog

The root cause is that the metadata section is not detected properly since you're reading the first 3 chars of the content looking for "---" (markdown.coffee:123) which in this case is the BOM char.

The naive approach would be to use something like stripBOM() in https://github.com/jonschlinkert/fs-utils, but I don't know if that's enough for all cases?

@jnordberg
Copy link
Owner

I don't know either, didn't know BOM was a thing even :) We could modify the regex to allow it, maybe \s matches those chars by default.

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

No branches or pull requests

2 participants