Dalgona / Serum

Static website generator for Elixir fans
https://dalgona.dev/Serum
MIT License
320 stars 27 forks source link

(add) Option to format readable HTML #134

Open igalic opened 4 years ago

igalic commented 4 years ago

I like to have produce readable HTML on my site.

Is there an option i can pass to Serum / Earmark to do that?

Dalgona commented 4 years ago

As far as I know, there's no such option in Earmark. Even Floki, which is a HTML parser used internally by Serum, does not have one.

Still, I would like to have this feature in Serum one day, by implementing HTML pretty formatter on my own (if necessary 😅).

EDIT: I forgot to mention that there's currently no HTML pretty formatter package on Hex either... That's why I said I'd implement it on my own if necessary. 🤣

Dalgona commented 4 years ago

In the meantime, I'm sad to say this, you might want to temporarily rely on an external program and optionally a shell script for automation.

igalic commented 3 years ago

here's my Makefile to build my websites:

tidy!=(which tidy5 || which tidy)
update-static:
    rm -rf site/
    env TZ=UTC MIX_ENV=prod mix serum.build
    $(tidy) -config tidy.config site/*.html || true
    $(tidy) -config tidy.config site/thoughts/*.html || true

with the following tidy.config:

indent: auto
indent-spaces: 4
tidy-mark: no
punctuation-wrap: yes
vertical-space: yes
wrap: 111
quiet: yes
write-back: yes

i'm happy with this solution, and will close this issue for now.

Dalgona commented 3 years ago

Thank you for the update! And I'm also sorry for not being able to actively develop/maintain this project for the moment. 🙏

igalic commented 3 years ago

no worries, it works well enough without active development!

Dalgona commented 3 years ago

Just noticed that Floki v0.30.0 introduced a new option called :pretty in Floki.raw_html/2. It does not provide fine-grained configuration options (just "pretty or not"), but I'll look into it.