GithubHelp home page GithubHelp logo

anikethsaha / posthtml-beautify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from posthtml/posthtml-beautify

0.0 1.0 0.0 6.1 MB

A posthtml plugin to beautify you html files. Online service -

Home Page: https://posthtml.github.io/posthtml-beautify/

License: MIT License

JavaScript 12.45% HTML 87.55%

posthtml-beautify's Introduction

posthtml-beautify

A posthtml plugin to beautify you html files

Travis Build Statusnodenpm versionDependency StatusXO code styleCoveralls status

npm downloadsnpmPackage Quality

Why?

Format your html and inline css markup according to the HTML5 syntax Style Guide, Code Guide. Full list of supported options:

  • Transform lower case element names
  • Transform lower case attribute names
  • Only double quotes
  • Close all html elements
  • Removing trailing slash in self-closing
  • Removes spaces at the equal sign
  • Add blank lines to separate large or logical code blocks
  • Add 2 spaces of indentation. Do not use TAB.
  • Add language attribute
  • Add character encoding
  • Attribute order
  • Boolean attributes
  • Creates file from the inline styles
  • Create scoped class name (use css-modules) instead inline styles
  • validate elements and attributes name
  • parses Internet Explorer Conditional Comments (not support Downlevel-revealed and valid version, htmlparse2 invalid parses)

Install

npm i -S posthtml posthtml-beautify

Note: This project is compatible with node v10+

Usage

import {readFileSync, writeFileSync} from 'fs';
import posthtml from 'posthtml';
import beautify from 'posthtml-beautify';

const html = readFileSync('input.html', 'utf8');

posthtml()
  .use(beautify({rules: {indent: 4}}))
  .process(html)
  .then(result => {
    writeFileSync('output.html', result.html);
  });

Returns html-formatted according to rules based on the use HTML5 syntax Style Guide, Code Guide with custom settings indent: 4

Options

rules

Type: Object
Default:

  • Indent
    Type: Number|String(only tab)
    Default: 2
    Description: A numeric value indicates specifies the number of spaces. The string value only tab

  • blankLines
    Type: String|Boolean(only false)
    Default: '\n'
    Description: Add or remove blank lines to separate large or logical code blocks

  • eol (end of line)
    Type: String
    Default: '\n'
    Description: As value is a string symbol which is added to the end of the row

  • eof (end of file)
    Type: String|Boolean
    Default: '\n'
    Description: As value is a string symbol which is added to the end of the file and will not adds if you specify a boolean value of false

  • maxlen
    Type: Number
    Default: '80'
    Description: checks for the max length of the content, indents the whole content to a new line

  • sortAttr
    Type: Boolean
    Default: false
    Description: Sort the order of attributes in elements

  • lang
    Type: String | Boolean(only false)
    Default: false
    Description: Add a lang attribute in elements, eg: { lang: 'fr' }

mini

Type: Object
Default:

  • removeAttribute
    Type: String|Boolean
    Default: false
    Description: Removes attributes that do not matter. The string value only empty

jsBeautifyOptions

Type: Object
Default: All options as per package js-beautify except, indent_level because calculated and set according to context

Related

posthtml-beautify's People

Contributors

scrum avatar greenkeeperio-bot avatar anikethsaha avatar greenkeeper[bot] avatar markplewis avatar btkostner avatar nilsboy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.