Support formatting of heredoc with HTML (& potentially other embedded languages)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza reproduciendo el ejemplo de PHP heredoc proporcionado en el Prettier PHP playground y compara la salida actual con el formato HTML esperado. Traza cómo se analizan y se imprimen los contenidos heredoc, y define la finalización como el formateo del HTML incrustado mientras se preservan la interpolación de PHP y la sintaxis heredoc; la compatibilidad con otros lenguajes incrustados queda fuera del alcance inmediato y se abordará posteriormente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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;
- Lenguaje dominante
- PHP
- Estrellas
- 1.9k
- Forks
- 139
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de prettier/plugin-php
-
PHP 8.3 not allowed in options? Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
prettier/plugin-php#2416 · 2 comentarios · 6 reacciones ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
prettier/plugin-php#2498 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
prettier/plugin-php#2495 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
prettier/plugin-php#2494 · 1 comentario ·
-
strange format issue Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
prettier/plugin-php#2490 ·
Todos los issues de prettier/plugin-php
Issues similares
-
jira-created
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
nunomaduro/phpinsights#745 ·
-
status/awaiting_triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
WordPress/plugin-check#1486 ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
az-digital/az_quickstart#6019 ·