项目作者: dmjio

项目描述 :
Lex, parse and pretty print HTML as Miso View syntax
高级语言: Haskell
项目地址: git://github.com/dmjio/miso-from-html.git
创建时间: 2020-02-22T11:18:29Z
项目社区:https://github.com/dmjio/miso-from-html

开源协议:BSD 3-Clause "New" or "Revised" License

下载


miso-from-html

Hackage
Haskell Programming Language
BSD3 LICENSE
Build Status

Convert HTML into miso View syntax.

Features

  • Strips comments
  • Pretty prints style tags as a Haskell Map from Data.Map

Usage

Given some HTML

  1. <nav class="navbar" role="navigation">
  2. <div class="navbar-brand">
  3. <a class="navbar-item" href="https://bulma.io">
  4. <img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
  5. <a>ok<p>hey</p></a>
  6. </a>
  7. </div>
  8. </nav>

Convert it to miso View syntax.

  1. $ cabal run miso-from-html < index.html

Result

  1. nav_
  2. [ class_ "navbar"
  3. , role_ "navigation"
  4. ]
  5. [ div_ [ class_ "navbar-brand" ]
  6. [ a_
  7. [ class_ "navbar-item"
  8. , href_ "https://bulma.io"
  9. ]
  10. [ img_
  11. [ src_ "https://bulma.io/images/bulma-logo.png"
  12. , width_ "112"
  13. , height_ "28"
  14. ]
  15. , a_ []
  16. [ "ok"
  17. , p_ [][ "hey" ]
  18. ]
  19. ]
  20. ]
  21. ]

Test

  1. $ nix-shell --run 'runghc Main.hs < index.html'