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

HTML Beautify: do not format YAML front matter #510

Closed
chaenu opened this issue Aug 15, 2014 · 5 comments
Closed

HTML Beautify: do not format YAML front matter #510

chaenu opened this issue Aug 15, 2014 · 5 comments

Comments

@chaenu
Copy link

chaenu commented Aug 15, 2014

Static site generators like Assemble or Middleman or Jekyll are supporting YAML front matter at the top of a template. When running html beautify on these templates, the front matter gets messed up.

So this yaml front matter:


---
title: Test
is-test: true

---

converts to:

--- title: Test is-test: true ---

I would suggest to ignore everything "wrapped" between three dashes or to add an extra option.

Further information: http://assemble.io/docs/YAML.html or http://middlemanapp.com/basics/frontmatter/

@bitwiseman
Copy link
Member

There are so many of the templating systems the people what to use with js, html, and css.
@einars, @evocateur do you have any thoughts/opinions of whether (or how) the beautifiers can be modified so we aren't adding special cases into all the core code to deal with all these?

@evocateur
Copy link
Contributor

Short of dramatically refactoring with a robust AST parser (e.g., Esprima), providing a plugin interface to allow custom poking of such an AST, and thus abandoning the Python version, I don't see this happening. (And almost all of the AST code generators, like escodegen, produce output that is extremely difficult to customize)

To be perhaps a little more blunt, this project should not do anything more than beautify JS. Notice I left out HTML and CSS, but if they must remain, then they should only beautify CSS and HTML. It is time-wasting folly to attempt to contort our static parser to allow for every pre- and post-processor's malformed "sugar" of syntax.

We don't beautify YAML, nor Markdown/LESS/SASS/React/Go/Ruby/Brainfuck for that matter. Curmudgeonliness aside, the encroaching complexity of supporting every weird meta-syntax fever dreamt by our strange beautiful community of front-end craftspeople is just loony. There are other beautifiers, today, that do attempt to engage the AST angle (though the plugin APIs, if they exist at all, tend to be very immature).

@bitwiseman
Copy link
Member

Very reasonable. Same principle as "beautifier is not a general purpose formatter".

The js beautifier provides an easy api for wrapping it inside another beautifier. That is exactly what the html beautifier does. When it encounters javascript, the html beautifier passes control to the js beautifier and then integrates the output. People are welcome to wrap or modify the components provided by this project to create their own. If people are interested and willing to take/share responsibility, they could make their projects part of beautify-web.

In the short-term, we should probably start marking bug requests based outside of html, css, and javascript, and then decide where to go from there.

@Serhioromano
Copy link

Serhioromano commented Apr 20, 2017

I do believe that beautifier should have a parameter like preservenewlines . If it already have it then preserve new lines in the text. It is not only issue of front matter. For example let's say there is HTML code and some people work in VS Code and other in MidnightCommander right on the server. that is why all text is formatted like this.

<p>
    This is multiple
    line text, that is
    easy to read in 
    MC
</p>

This works right when HTML is rendered and also visible in MC. But if someone format it with beautifier this is gone.

So preserve new lines in the text would be awesome.

@bitwiseman
Copy link
Member

I think this is fixed. Just needs a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants