tlienart / Franklin.jl

(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
https://franklinjl.org
MIT License
951 stars 113 forks source link

Franklin.serve gives up too easily sometimes #405

Open fredrikekre opened 4 years ago

fredrikekre commented 4 years ago

I notice that Franklin.serve gives up and errors out quite often when you are in the middle of editing the source files. Here are some example errors:

ERROR: Franklin.HTMLBlockError("I found a lonely {{end}}.")
ERROR: Franklin.HTMLBlockError("I found a HBlock that did not match anything, verify '{{}}'")

I believe this happens because of my habits to press Ctrl+S quite often. Would be nice if Frankling kept retrying instead of giving up.

tlienart commented 4 years ago

Thanks that's an interesting point 🤔 ; the errors you're mentioning are most likely to happen when working on the layout which potentially affect all pages though so that pushed me to have Franklin fail early rather than have weird things happening, would you have suggestions for how to do this cleanly?

lucasvreis commented 4 years ago

Maybe it could print the error but do nothing to the generated site until the errors are gone?

tlienart commented 4 years ago

Yeah, I’ll have a think about it, the difficult part is to work out what to render in case of error; if you just render the top bit it might still look awful if, for instance, that block happens in a div and fails to close it properly;

Maybe what we could have is just a default “rendering failed due to X” page but the server doesn’t stop, and so as soon as it’s fixed the page gets loaded properly

lucasvreis commented 4 years ago

What I had in mind was to keep the entire site in the state prior to the edit which caused the error; I'm not really aware of the way Franklin updates things, so maybe this could be a bit difficult?

But I also think that just having the server not to stop is good enough, for the only problem I see is the annoyance of going back to the terminal and restarting the server :upside_down_face:

tlienart commented 4 years ago

Hmmmmm your first comment might be doable but trickier, also I think if the goal is to not go back to the terminal too often then the page should inform you of the error...

Ok here’s what I’ll try to do: add an error banner at the top of the page upon error; if there was previously html that was generated properly, use that with the banner, otherwise show a blank page.

It might take me some time to implement properly though 😬

tk3369 commented 4 years ago

I encountered this problem several times when I forgot to close an equation with $ sign. When I run serve, I also expect it to be more forgiving. I don't mind it throwing an error to the terminal though. Here's my setup:

  1. VSCode editing the markdown file with integrated terminal at the bottom running serve
  2. Separate browser window to preview changes