Visitar URL original
Don't indent <head> & <body> · prettier/prettier · Discussion #14761 · GitHub
Skip to content
Discussion options

You must be logged in to vote

Hi, @Potherca!

I think this is exactly the kind of case where a Prettier plugin is the right escape hatch.

I agree that this probably should not become a new core Prettier option. But if a project wants a specific formatting rule like “do not indent <head> and <body> under <html>”, then the practical solution is to move that decision into a custom printer.

This is basically what I did in @poliklot/prettier-plugin-handlebars.

It is a Prettier plugin for HTML-heavy classic Handlebars templates. It registers its own parser and printer:

export const parsers = {
  handlebars: {
    parse,
    astFormat: "handlebars-ast",
    locStart,
    locEnd,
  },
};

export const printers = {
  "handlebar…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Potherca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants