Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/izolate/html2pug
Converts HTML to Pug :dog:
https://github.com/izolate/html2pug
converter html parser pug pug-template-engine
Last synced: about 3 hours ago
JSON representation
Converts HTML to Pug :dog:
- Host: GitHub
- URL: https://github.com/izolate/html2pug
- Owner: izolate
- License: mit
- Created: 2016-02-16T16:36:23.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2023-04-01T02:28:06.000Z (over 1 year ago)
- Last Synced: 2024-10-30T02:28:21.979Z (14 days ago)
- Topics: converter, html, parser, pug, pug-template-engine
- Language: JavaScript
- Homepage: https://html2pug.com
- Size: 582 KB
- Stars: 147
- Watchers: 7
- Forks: 41
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
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
Hello World!
Hello World!
```
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 'foo
' | 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 = '
Hello World!
'
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 `` and `` tags if false