Toolvist

Conversor de HTML a Pug

Convierte marcado HTML en sintaxis de plantilla Pug (Jade) limpia e indentada. Conversor HTML a Pug online con abreviaturas de atributos y salida instantánea.

Conversor de HTML a Pug gratuito

El Conversor de HTML a Pug convierte el marcado HTML en sintaxis de plantilla Pug (antes Jade) limpia e indentada. Las abreviaturas de clase e id, los atributos y el anidamiento se manejan por ti.

The indentation-sensitive output pairs with the HTML Formatter & Beautifier, and the JSX equivalent is produced by the HTML to JSX Converter. To strip the markup entirely rather than convert it, Strip HTML Tags is the tool.

Cómo usar HTML a Pug

  1. 1 Paste your HTML.
  2. 2 Convert. Tags become indentation, attributes move into parentheses, and ids and classes take the shorthand notation.
  3. 3 Check the output for elements where optional closing tags changed the nesting.
  4. 4 Copy the Pug template.

Cómo usarlo

Pega tu HTML y haz clic en Convertir. El equivalente Pug aparece a la derecha, correctamente indentado y listo para pegar en una plantilla.

  • class e id usan las abreviaturas . y #
  • Los elementos anidados se indentan automáticamente
  • Los atributos se muestran como (nombre="valor")
  • Los elementos vacíos se convierten en etiquetas autocontenidas
  • Se ejecuta enteramente en tu navegador

¿Por qué Pug?

Pug elimina las etiquetas de cierre y los corchetes angulares, lo que hace las plantillas más cortas y fáciles de escanear. El espacio en blanco es significativo, así que este conversor indenta cada nivel de forma consistente por ti.

Preguntas frecuentes

What makes Pug worth the indentation sensitivity?

It removes most of the punctuation. A div with a class and an id becomes a single short token, and there are no closing tags at all, which eliminates a whole class of error. The cost is that indentation carries meaning, so a mis-indented line changes the structure rather than merely looking untidy.

How does Pug handle text content?

Inline text follows the tag on the same line if short. Longer content goes in a piped block, where each line is prefixed to mark it as text, or in a block without parsing so that it is emitted literally. Which form to use depends on whether the text contains markup that should be interpreted.

Why did my whitespace change?

Because Pug treats indentation as structure, so whitespace that HTML would have collapsed may be significant or insignificant differently. In particular, inline elements that were adjacent in the HTML can gain or lose a space depending on how the template is written. Pug has explicit constructs for controlling this.

Herramientas para desarrolladores relacionadas

Ver todo en Herramientas para desarrolladores →

También te puede interesar

Herramientas de otras categorías que suelen combinarse con HTML a Pug:

Explorar el directorio completo →