escape-html - Escape string for use in HTML.
Escape string for use in HTML
This module exports a single function, escapeHtml, that is used to escape a string of content such that it can be interpolated in HTML content.
This module will escape the following characters: ", ', &, <, and >.
Note that the escaped value is only suitable for being interpolated into HTML as the text content of elements in
which the tag does not have different escaping mechanisms (it cannot be placed inside <style>
or <script>
,
for example, as those content bodies are not HTML, but CSS and JavaScript, respectively; these are known as
"raw text elements" in the HTML standard).
Note when using the escaped value within a tag, it is only suitable as the value of an attribute, where the value is quoted with either a double quote character (") or a single quote character (').
$ sbt clean publish-local
Before running the tests the first time, you must ensure the npm packages are installed:
$ npm install
Then you can run the tests:
$ sbt test
import io.scalajs.npm.escapehtml._
EscapeHtml("foo & bar") // "foo & bar"
To add the EscapeHtml
binding to your project, add the following to your build.sbt:
libraryDependencies += "io.scalajs.npm" %%% "escape-html" % "0.5.0"
Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")