# html2jade

> HTML to Jade conversion tool

Latest version **0.8.6** (published 2016-10-31) · BSD license · 0 weekly downloads

## Install

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

Provides the command `html2jade`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.6 |
| Published | 2016-10-31 |
| First published | 2011-10-28 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1173 |
| Author | Don Park |
| Maintainers | aichholzer, donpark |

## Links

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

## Dependencies (3)

- [he](https://npm.io/package/he.md) ^0.4.1
- [commander](https://npm.io/package/commander.md) *
- [jsdom-little](https://npm.io/package/jsdom-little.md) ^0.10.5

## Recent versions

- 0.8.6 (latest) — 2016-10-31
- 0.8.5 — 2016-09-22
- 0.8.4 — 2015-05-15
- 0.8.3 — 2015-02-13
- 0.8.2 — 2015-02-06
- 0.8.1 — 2014-11-06
- 0.8.0 — 2014-09-30
- 0.7.8 — 2014-07-31
- 0.7.7 — 2014-06-05
- 0.7.6 — 2014-05-31
- 0.7.5 — 2014-05-28
- 0.7.1 — 2014-05-22
- 0.7.0 — 2014-05-21
- 0.6.5 — 2014-05-14
- 0.6.4 — 2014-05-14
- … 35 more at https://npm.io/package/html2jade/versions

## README

# html2jade #
[![Build Status](https://travis-ci.org/donpark/html2jade.png?branch=master)](https://travis-ci.org/donpark/html2jade)

`html2jade` converts HTML into [Jade](https://github.com/visionmedia/jade) format.

This module is now maintained by [@aichholzer](https://github.com/aichholzer)


## Status ##

Mostly usable but sometimes requires fixing up, usually involving conditionals and scripts indentation.

While converting a fairly complicated theme package with ~20 HTML files, I had to hand-edit just twice.

Compatible with Node.js 4.0+ (verified with v4.2.4) but likely **NOT** with Node.js 0.11.x, 0.12.x, and io.js.


## Requirements

`html2jade` version prior to 0.7 support OS X and Linux only.

`html2jade` version 0.7+ should support OS X, Windows, and Linux.

## Install ##

    npm install -g html2jade

## Command-line Usage ##

Outputs to stdout if input is URL

    html2jade http://twitter.com

    html2jade http://twitter.com > twitter.jade

Outputs to file if input is file

    html2jade mywebpage.html # outputs mywebpage.jade
    html2jade public/*.html  # converts all .html files to .jade

Convert HTML from `stdin`

    cat mywebpage.html | html2jade -

To generate [Scalate](http://scalate.fusesource.org/) compatible output:

    html2jade --scalate http://twitter.com
    html2jade --scalate http://twitter.com > twitter.jade
    html2jade --scalate mywebpage.html
    html2jade --scalate public/*.html

### Command-line Options ###

* `-d, --double` - use double quotes for attributes
* `-o, --outdir <dir>` - path to output generated jade file(s) to
* `-n, --nspaces <n>` - the number of spaces to indent generated files with. Default is 2 spaces
* `-t, --tabs` - use tabs instead of spaces
* `--donotencode` - do not html encode characters. This is useful for template files which may contain expressions like {{username}}
* `--bodyless` - do not output enveloping html and body tags
* `--numeric` - use numeric character entities
* `-s, --scalate` - generate [Scalate](http://scalate.fusesource.org/) variant of jade syntax
* `--noattrcomma` - omit attribute separating commas
* `--noemptypipe` - omit lines with only pipe ('|') printable character

## Programmatic Usage (>= 0.0.7)

To convert raw HTML into Jade:

    var html2jade = require('html2jade');
    var html = "<html><body>Hello World</body></html>";
    html2jade.convertHtml(html, {}, function (err, jade) {
      // do your thing
    });

To convert DOM document into Jade (client-side):

    // assumes html2jade.js file has been loaded
    Html2Jade.convertDocument(document, {}, function (err, jade) {
      // do your thing
    });
    
## Converting Mustache/Handlebars Templates

Jade is commonly used to generate HTML with embedded Mustache or Handlebars templates.

Be sure to use version 0.8+ if you use template expressions in element IDs or CSS class names
to avoid generating invalid Jade files.

## Tools using `html2jade` ##

### Web version ###

There is a [web version](http://html2jade.aaron-powell.com/) of `html2jade`,
kindly provided by [@aaronpowell](https://github.com/aaronpowell).

Pascal Garber's [jade2html2jade](https://github.com/JumpLink/jade2html2jade) does roundtrip from jade to HTML and back. [Online demo](http://jumplink.github.io/jade2html2jade/).

### Linux tray app ###

[Miniclip](http://myguidingstar.github.com/miniclip/) is a Linux tray app that quickly converts
HTML to Jade, CSS to Stylus and JS to Coffee from clipboard.

## Testing ##

As of version 0.4, there is a simple unit test that converts HTML files in `test/data` directory
and compare them against Jade files in the same directory. Unit test harness requires `coffee-script`
and `mocha` to be installed globally. Run the tests with command `npm test`.


## Useful forks ##

If you're having issues with `br` line-breaks which apparently Jade has some problems with,
try [@smaudet](https://github.com/smaudet)'s
[`fix-breaklines`](https://github.com/smaudet/html2jade/tree/fix-breaklines) branch.

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