# Doccy
Doccy is a simple brace based markup language, an alternative to writing HTML for people who enjoy the power and flexibility but do not enjoy writing it.
## Syntax
### Paragraphs
Any text contained within specific contexts will be treated as one or more paragraphs if separated by two or more line breaks and it contains only inline elements.
#### Document body
```doccy
This is a paragraph.
{h1: This is a header.}
And this is another.
```
Renders as:
```html
<p>This is a paragraph.</p>
<h1>This is a header.</h1>
<p>And this is another.</p>
```
#### Special elements
The following elements also automatically wrap paragraphs: `article`, `aside`, `blockquote`, `div`, `fieldset`, `footer`, `form`, `header`, `hgroup`, `main` and `section`.
```doccy
{blockquote: This is a paragraph.
And this is another.}
```
Renders as:
```html
<blockquote>
<p>This is a paragraph.</p>
<p>And this is another.</p>
</blockquote>
```
### Elements
Anything between two curley-braces is considered an element if:
- Immediately following the opening brace, a valid element name is found,
- followed by whitespace or attributes,
- and finaly a colon (`:`).
For example, the following are all valid:
```doccy
{h1:Top-level heading}
{p : A paragraph}
```
There is one exception to this rule, line breaks (`<br>`) can be written as:
```doccy
{br}
```
### Attributes
Anything between the opening curley-brace and colon is considered an attribute if:
- It begins with one of `@`, `#`, `%`, `.`,
- followed by a valid identifier (`[a-zA-Z][a-zA-Z0-9]*`)
- and optionally a value.
#### Named Attributes
A named attribute with a value looks like:
```doccy
{h1 @class main header: Header}
```
Renders as:
```html
<h1 class="main header">Header</h1>
```
Without a value:
```doccy
{input @required}
```
Renders as:
```html
<input required>
```
Values containing special characters must be escaped:
```doccy
{h1 @test Bad characters\: \@\#\%\.\{\}: ...}
```
Renders as:
```html
<h1 test="Bad characters: @#%.{}">...</h1>
```
#### Data Attributes
A shorthand for `data-` attributes:
```doccy
{pre %lang html: ...}
{pre %html: ...}
```
Renders as:
```html
<pre data-lang="html">...</pre>
<pre data-html>...</pre>
```
As with named attributes, special characters must be escaped.
#### Class Attributes
A shorthand for `class="..."` attributes:
```doccy
{h1.main.header: Header}
```
Renders as:
```html
<h1 class="main header">Header</h1>
```
#### Id Attributes
A shorthand for `id="..."` attributes:
```doccy
{h1#main: Header}
```
Renders as:
```html
<h1 id="main">Header</h1>
```
## Usage
### Rust
```rust
extern crate doccy;
use doccy::doccy_to_html;
fn main() {
match doccy_to_html("your document here") {
Ok(html) => println!("{:?}", html), // <p>your document here</p>
Err(error) => {}
};
}
```