biome icon indicating copy to clipboard operation
biome copied to clipboard

📝 HTML directive casing does not match prettier

Open dyc3 opened this issue 1 year ago • 3 comments

Environment information

playground

Configuration

No response

Playground link

https://biomejs.dev/playground/?quoteStyle=single&indentWidth=4&arrowParentheses=as-needed&files.main.html=PAAhAGQAbwBjAHQAeQBwAGUAIABIAFQATQBMAD4ACgA%3D

Code of Conduct

  • [X] I agree to follow Biome's Code of Conduct

dyc3 avatar Sep 21 '24 10:09 dyc3

Another case: https://biomejs.dev/playground/?quoteStyle=single&indentWidth=4&arrowParentheses=as-needed&files.main.html=PAAhAEQATwBDAFQAWQBQAEUAIABIAFQATQBMAD4ACgA%3D

dyc3 avatar Sep 21 '24 10:09 dyc3

@dyc3 Hi, I dug this issue a bit and I suppose it's the common problem for all HTML tags. Here's the example with <DIV></DIV>

https://biomejs.dev/playground/?quoteStyle=single&indentWidth=4&arrowParentheses=as-needed&files.main.html=PABEAEkAVgA%2BADwALwBEAEkAVgA%2BAA%3D%3D

Just exploring at the moment, not committing into the fix.

viraxslot avatar Sep 22 '24 08:09 viraxslot

When the html directive in an HTML file is lowercase, Prettier outputs <!doctype>. Otherwise, it outputs <!DOCTYPE> in uppercase. See here

function printOpeningTagStartMarker(node) {
  switch (node.type) {
    case "ieConditionalComment":
    case "ieConditionalStartComment":
      return `<!--[if ${node.condition}`;
    case "ieConditionalEndComment":
      return "<!--<!";
    case "interpolation":
      return "{{";
    case "docType":
      return node.value === "html" ? "<!doctype" : "<!DOCTYPE";
    case "angularIcuExpression":
      return "{";
    case "element":
      if (node.condition) {
        return `<!--[if ${node.condition}]><!--><${node.rawName}`;
      }
    // fall through
    default:
      return `<${node.rawName}`;
  }
}

BTW, in the playground, if the doctype is not entirely uppercase or lowercase, Biome throws an format error, but Prettier doesn't.

image

shulaoda avatar Sep 28 '24 16:09 shulaoda