prettier / prettier/plugin-php
Support formatting of heredoc with HTML (& potentially other embedded languages)
Nessuno ha ancora preso questa issue.
- Lingua principale
- PHP
- Stelle
- 1.9k
- Fork
- 139
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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;
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l’esempio PHP heredoc fornito nel Prettier PHP playground e confronta l’output attuale con la formattazione HTML prevista. Traccia come viene analizzato e stampato il contenuto heredoc, quindi definisci il completamento come la formattazione dell’HTML incorporato preservando l’interpolazione PHP e la sintassi heredoc; il supporto per altri linguaggi incorporati rimane nell’ambito più ampio di un lavoro successivo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100