rochacbruno / marmite

Markdown makes sites - A Static Site Generator for Blogs
https://rochacbruno.github.io/marmite/
GNU Affero General Public License v3.0
340 stars 19 forks source link

Windows: CRLF line endings cause "Invalid frontmatter format" build error #99

Open bit-png opened 3 days ago

bit-png commented 3 days ago

I followed the instructions to install Marmite and start making a blog on Windows. When serving this project with marmite --serve --watch myblog site in Windows, and editing a file in Visual Studio using its default line endings:

---
date: 2024-10-25
tags: hello,world
---

# Hello World
...

The following error appears:

INFO  marmite::site] Change detected. Rebuilding site...
ERROR marmite::site] Failed to process file myblog\hello-world.md: Invalid frontmatter format
INFO  marmite::site] Generated site\index.html

(All my test files used CRLF line endings, but the error only affected the ones with metadata.)

I can fix this within VS Code by switching the file's line endings from CR+LF to just LF, but this issue might need a fix or a note in the documentation for Windows users.

rochacbruno commented 3 days ago

thanks for reporting, I don't have windows to test it, let's wait for a PR

rochacbruno commented 3 days ago

It looks like the problem is with serving + watching.

Can you try building without those options?

marmite myblog site

Does that render the site correctly?

You can open the site directly in the browser to test.

bit-png commented 2 days ago

Even when just compiling the site (using marmite blog static) it still causes the error message. Here's the full output:

C:\blog>marmite blog site
[2024-10-30T20:32:19Z INFO  marmite::site] Config loaded from: defaults
[2024-10-30T20:32:19Z ERROR marmite::site] Failed to process file blog\hello-world.md: Invalid frontmatter format
[2024-10-30T20:32:19Z INFO  marmite::site] Generated site\404.html
[2024-10-30T20:32:19Z INFO  marmite::site] Generated site\tags.html
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\Atkinson-Hyperlegible-Regular-102.woff
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\custom.css
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\custom.js
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\favicon.ico
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\github-dark.min.css
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\github-light.min.css
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\highlight.min.js
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\marmite.css
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\marmite.js
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\pico.min.css
[2024-10-30T20:32:19Z INFO  marmite::embedded] Generated site\static\robots.txt
[2024-10-30T20:32:19Z ERROR marmite::site] Failed to copy site\static\custom.css: The process cannot access the file because it is being used by another process. (os error 32)
[2024-10-30T20:32:19Z ERROR marmite::site] Failed to copy site\static\custom.js: The process cannot access the file because it is being used by another process. (os error 32)
[2024-10-30T20:32:19Z INFO  marmite::site] Copied site\static\favicon.ico to site\favicon.ico
[2024-10-30T20:32:19Z INFO  marmite::site] Copied site\static\robots.txt to site\robots.txt
[2024-10-30T20:32:19Z INFO  marmite::site] Site generated at: site/

(The custom.css/js errors can be ignored, as I've tested a slightly bigger blog with them and they seem to work fine.)

I think the error is from a library -- I see it coming from \frontmatter-gen-0.0.2\src\error.rs and \extractor.rs, because the latter searches for "---\n" when looking for data, and there is no such line ending on Windows-made files.