# HypertextLiteral Overview
This package provides a Julia macro, `@htl`, that constructs an object
which could be rendered to `MIME"text/html"` displays. This macro
supports string interpolation sensible to the needs of HTML generation.
using HypertextLiteral
v = "<1 Brown \"M&M's\"!";
@htl "$v"
#-> <1 Brown "M&M's"!
An equivalent non-standard string literal, `htl`, is also provided.
v = "<1 Brown \"M&M's\"!";
htl"$v"
#-> <1 Brown "M&M's"!
Interpolation can use the full expressive power of Julia.
books = ["Who Gets What & Why", "Switch", "Governing The Commons"]
@htl "
$(map(books) do b @htl("- $b") end)
"
#=>
- Who Gets What & Why
- Switch
- Governing The Commons
=#
## Translation Contexts
How a Julia expression is translated depends upon where it is used.
| | **Native Julia** | **Translation** |
|:------------------- |:-------------------------|:------------------ |
| **Element Content** | `"\"M&M\"'s"` | `M&M's` |
| | `:name` | `name` |
| | `[1, 2]` *or* `(1, 2)` | `12` |
| | `nothing` | *omitted* |
| | `missing` | `missing` |
| | `(a = 1, b = 2)` | `(a = 1, b = 2)` |
| | `Dict(:a => 1, :b => 2)` | `Dict(:a => 1, :b => 2)` |
| **Attribute Value** | `"\"M&M\"'s"` | `M&M's` |
| | `:name` | `name` |
| | `[1, 2]` *or* `(1, 2)` | `1 2` |
| | `nothing` | *omitted* |
| | `missing` | `missing` |
| | `(a = 1, b = 2)` | `a: 1; b: 2;` |
| | `Dict(:a => 1, :b => 2)` | `a: 1; b: 2;` |
| **Script Tag** | `"\"M&M\"'s"` | `"\"M&M\"'s"` |
| | `:name` | `name` |
| | `[1, 2]` *or* `(1, 2)` | `[1, 2]` |
| | `nothing` | `undefined` |
| | `missing` | `null` |
| | `Inf` | `Infinity` |
| | `NaN` | `NaN` |
| | `(a = 1, b = 2)` | `{"a": 1, "b": 2}` |
| | `Dict(:a => 1, :b => 2)` | `{"a": 1, "b": 2}` |
If any of these translations are inconvenient:
* `coalesce()` can be used to provide an alternative for `missing`;
* `something()` provides a substitution for `nothing`;
* `string()` will use the string translation instead; and
* `HTML()` can be used to bypass escaping within element content.
## Table of Contents
```@contents
Pages = ["content.md", "attribute.md", "script.md"]
Depth = 3
```
```@contents
Pages = ["design.md", "notation.md", "primitives.md", "reference.md"]
Depth = 1
```