Skip to content
HTML to Scalatags converter
HTML Scala
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
.gitignore
LICENSE.LGPL
README.md
build.sbt

README.md

HTML to Scalatags converter

Online version: https://scf37.me/tools/html-to-scalatags-converter

Converts any, even invalid, HTML to format accepted by Li Haoyi's Scalatags library.

Features:

  • Accepts even invalid HTML
  • Properly handles HTML and Scala escaping, including unicode and multiline strings
  • Properly handles <pre> tags and spaces for inline flow
  • Keeps comments
  • Smart pretty print

As an example, it can convert this:

<h1>Dude &amp; Dude</h1>
<!-- the form -->
<form>
  <div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" aria-describedby="emailHelp" placeholder="Enter email">
    <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
  </div>
  <pre>
      first line
      second line
  </pre>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

to that:

Seq(
  h1("Dude & Dude"), 
  // the form 
  form(
    div(cls := "form-group", 
      label(`for` := "exampleInputEmail1", "Email address"), 
      input(tpe := "email", cls := "form-control", aria.describedby := "emailHelp", placeholder := "Enter email"), 
      small(id := "emailHelp", cls := "form-text text-muted", 
        "We'll never share your email with anyone else."
      )
    ), 
    pre(
      """
      first line
      second line
  """
    ), 
    button(tpe := "submit", cls := "btn btn-primary", "Submit")
  )
)

License: LGPLv3

You can’t perform that action at this time.