Support formatting of heredoc with HTML (& potentially other embedded languages)
まだ誰も着手していません。
評価
調査の方向性
まず、提供された PHP heredoc の例を Prettier PHP playground で再現し、現在の出力を期待される HTML のフォーマットと比較します。heredoc の内容がどのように解析され、出力されるかを追跡し、PHP の補間と heredoc 構文を維持したまま埋め込み HTML をフォーマットできることを完了条件として定義します。その他の埋め込み言語への対応は、より広い範囲の後続作業とします。
索引モデルが issue の本文から書いたものです。
説明
Thanks for all the work on this project, Prettier team!
Description
For HTML specifically, this is probably related to better inline support, & https://github.com/prettier/plugin-php/issues/845#issuecomment-441405121 but I figured the implementation for this would be slightly more straight forward as the explicit marking of HTML may make it more likely a html node be fully represented in one string. Many editors (including VSCode) also already highlight these sections by default with their respective syntax highlightings. Whilst prettier's HTML parser is still too strict to deal with interpolated tags (e.g. <$foo></$foo>, other parsers (like the one used in VSCode's builtin HTML formatter), can handle it.
For other languages, I guess it would depend more on their parsers, but I foresee that we could probably either use some sort of placeholder-replacement system, or just pass the whole string as is & YOLO.
Prettier 1.16.4
PHP Plugin 0.10.2
# Options (if any):
--use-tabs --php-version 8.2 --brace-style 1tbs
Input:
<?php
function Component($foo) {
echo <<<HTML
<div data-this-should-break data-bruh data-intersection>foo: $foo</div>
HTML;
}
echo <<<HTML
<main>
{${Component(foo: "bar")}}
{${Component(foo: "baz")}}
</main>
HTML;
Output:
(The same)
<?php
function Component($foo) {
echo <<<HTML
<div data-this-should-break data-bruh data-intersection>foo: $foo</div>
HTML;
}
echo <<<HTML
<main>
{${Component(foo: "bar")}}
{${Component(foo: "baz")}}
</main>
HTML;
Expected behavior:
The HTML should be formatted.
<?php
function Component($foo) {
echo <<<HTML
<div
data-this-should-break
data-bruh
data-intersection
>
foo: $foo
</div>
HTML;
}
echo <<<HTML
<main>
{${Component(foo: "bar")}}
{${Component(foo: "baz")}}
</main>
HTML;
- 主要言語
- PHP
- スター
- 1.9k
- フォーク
- 139
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
prettier/plugin-php のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
prettier/plugin-php#2416 · コメント 2 件 · リアクション 6 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
prettier/plugin-php#2498 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
prettier/plugin-php#2495 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
prettier/plugin-php#2494 · コメント 1 件 ·
-
strange format issue オープン
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
prettier/plugin-php#2490 ·
prettier/plugin-php の issue をすべて見る
似ている issue
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
-
Перевод устарел
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100