4.0.0 • Published 1 year ago

html-elm v4.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

html-elm Build Status

Convert HTML and SVG to Elm code

Install

$ npm install html-elm

Usage

import htmlElm from 'html-elm'

const htmlString = '<div class="wrapper"><h1 id="title">Hello World</h1></div>'

// htmlElm returns a Promise
htmlElm(htmlString, {
  indent: 2,
  htmlAlias: 'Html',
  htmlAttributeAlias: 'H',
  svgAlias: 'Svg',
  svgAttributeAlias: 'S',
  imports: true,
}).then(console.log)

// Result will be a string with valid Elm code:
//
// import Html
// import Html.Attributes as H
//
// Html.div
//   [ H.class "wrapper" ]
//   [ Html.h1
//     [ H.id "title" ]
//     [ Html.text "Hello World" ]
//   ]

// All options are optional
htmlElm(html)

CLI

Install it globally

$ npm install -g html-elm

Usage:

$ html-elm '<div class="container"><h1>Hello all</h1><p>Lorem ipsum dolor</p></div>'

div
    [ class "container" ]
    [ h1
        []
        [ text "Hello all" ]
    , p
        []
        [ text "Lorem ipsum dolor" ]
    ]

To see all available options use:

$ html-elm -h

License

MIT

4.0.0

1 year ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.1.1

4 years ago

2.0.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago