# html2pug

> Converts HTML to Pug

Latest version **4.0.0** (published 2019-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install html2pug
pnpm add html2pug
yarn add html2pug
bun add html2pug
```

Provides the command `html2pug`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2019-05-14 |
| First published | 2016-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 18.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 149 |
| Author | izolate |
| Maintainers | izolate |
| Keywords | html, pug, jade, convert, templates |

## Links

- npm: https://www.npmjs.com/package/html2pug
- Repository: https://github.com/izolate/html2pug
- Homepage: https://github.com/izolate/html2pug#readme
- Issues: https://github.com/izolate/html2pug/issues
- npm.io page: https://npm.io/package/html2pug

## Dependencies (4)

- [parse5](https://npm.io/package/parse5.md) ^5.1.0
- [has-flag](https://npm.io/package/has-flag.md) ^4.0.0
- [get-stdin](https://npm.io/package/get-stdin.md) ^6.0.0
- [html-minifier](https://npm.io/package/html-minifier.md) ^4.0.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2019-05-14
- 3.0.0 — 2019-04-10
- 2.0.1 — 2017-08-13
- 2.0.0 — 2017-08-12
- 1.0.0 — 2017-07-09
- 0.0.1 — 2016-06-08
- 0.0.0 — 2016-02-16

## README

# html2pug [![Build Status](https://travis-ci.org/izolate/html2pug.svg?branch=master)](https://travis-ci.org/izolate/html2pug)

Converts **HTML** to **Pug** templating language (_formerly Jade_).  
Requires Node.js version `7.6` or higher.

Turns this :unamused:
```html
<!doctype html>
<html lang="en">
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <div id="content">
      <h1 class="title">Hello World!</h1>
    </div>
  </body>
</html>
```

Into this :tada:
```pug
doctype html
html(lang='en')
  head
    title Hello World!
   body
    #content
      h1.title Hello World!
```

## Install

Get it on [npm](https://www.npmjs.com/package/html2pug):

```bash
npm install -g html2pug
```

## Usage

### CLI
Accept input from a file or stdin and write to stdout:

```bash
# choose a file
html2pug < example.html

# use pipe
echo '<h1>foo</h1>' | html2pug -f
```

Write output to a file:
```bash
html2pug < example.html > example.pug
```

See `html2pug --help` for more information.

### Programmatically

```js
const html2pug = require('html2pug')

const html = '<header><h1 class="title">Hello World!</h1></header>'
const pug = html2pug(html, { tabs: true })
```

### Options

Name | Type | Default | Description
--- | --- | --- | ---
`tabs` | `Boolean` | `false` | Use tabs instead of spaces for indentation
`commas` | `Boolean` | `true` | Use commas to separate node attributes
`doubleQuotes` | `Boolean` | `false` | Use double quotes instead of single quotes for attribute values
`fragment` | `Boolean` | `false` | Wraps result in enclosing `<html>` and `<body>` tags if false

---
_Source: https://npm.io/package/html2pug · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
