foundation / panini

A super simple flat file generator.
Other
592 stars 104 forks source link

Adds BOM when using partials #98

Closed Inx51 closed 7 years ago

Inx51 commented 7 years ago

Hi! For some reason once I use my partials panini appears to add a BOM(&#65279) before the rendered partial..

Any ideas?.. I have tried to save all my files as UTF-8.. but that doesn't do it..

Inx51 commented 7 years ago

Turns out that Visual Studio adds BOM to alot of its created files... Found an extension for Visual Studio to prevent BOM.. however.. would be nice if panini just stripped that away from partials and layouts..

FracturedShader commented 7 years ago

I just ran into this, and submitted a fix.

gakimball commented 7 years ago

Merged #129.

@FracturedShader, while we're here, do you think you could do the same fix for Panini 2.0? Panini 1.0 is more or less EOL now.

I think there's two places where you'd need to do it.

First off, I'd recommend using the strip-bom library to do it. Keeps the codebase a little more slim :)

For pages, you'd probably want to add BOM stripping here, where the page is separated into Front Matter variables and a body. You can where the page.body string is returned in this function at the end. You'd want to strip the BOM from page.body and return the modified string instead.

For partials, there's one function the library uses to load files and read their contents, which you can see here. Right now the string comes straight from fs.readFile, so you can modify that to strip the BOM before returning the file's contents.

FracturedShader commented 7 years ago

@gakimball, sure thing! I'll do that after work tonight.

gakimball commented 7 years ago

@FracturedShader Awesome, thank you so much! :)

gakimball commented 7 years ago

Just published version 1.5.0, which has the BOM stripping.

gakimball commented 7 years ago

Merged #131 to get BOM stripping into 2.0.