Skip to content

I2I: prettier for HTML #27198

@alanorozco

Description

@alanorozco

Motivation

prettier is used for automatically formatting most code in this repo, except for HTML files.

When applying prettier directly, the AMP boilerplate will explode into many lines, even though it's usually written as one. This creates noise.

This issue describes a strategy for auto-formatting HTML files in this repository, while keeping the boilerplate written as one line.

State of <!-- prettier-ignore -->

<!-- prettier-ignore --> will only ignore the first node on the next line. This is problematic for AMP documents that hold a second <noscript> node in their boilerplate, which will not be ignored. This applies for every AMP format except ads.

A feature request for prettier introduces ignore range blocks for HTML. This would allow us to include any type of AMP boilerplate in one ignore section:

<head>
  <!-- prettier-ignore-start -->
  <style amp-boilerplate>/* ... */</style><noscript><style amp-boilerplate>/* ... */</style></noscript>
  <!-- prettier-ignore-end -->
</head>

Opportunities

Including the boilerplate in a prettier-ignore block would allow the Playground to use prettier (/cc @ampproject/wg-outreach)

/cc @ampproject/wg-infra

Metadata

Metadata

Labels

INTENT TO IMPLEMENTProposes implementation of a significant new feature. https://bit.ly/amp-contribute-codeStaleInactive for one year or moreWG: infraWG: outreach

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions