55 lines
1.5 KiB
Markdown
55 lines
1.5 KiB
Markdown
|
# 🫐 bberry
|
||
|
|
||
|
Super simple parser and "compiler" for turning a lisp-like DSL into HTML.
|
||
|
|
||
|
Here's a small example:
|
||
|
|
||
|
```lisp
|
||
|
('"<!DOCTYPE html>") ; using a raw string for the doctype is fine
|
||
|
(html
|
||
|
(head
|
||
|
; everything that belongs in the head element
|
||
|
(title'"Document")
|
||
|
|
||
|
(meta (: "charset" "UTF-8"))
|
||
|
(meta (: "name" "viewport") (: "content" "width=device-width, initial-scale=1.0"))
|
||
|
(meta (: "http-equiv" "X-UA-Compatible") (: "content" "ie=edge"))
|
||
|
|
||
|
(link (: "rel" "stylesheet") (: "href" "#")))
|
||
|
|
||
|
(body
|
||
|
; the actual body only starts here
|
||
|
(span (: "style" "color: red") ('"Hello, world!"))))
|
||
|
```
|
||
|
|
||
|
This yields:
|
||
|
|
||
|
```html
|
||
|
<!-- formatted to for viewing ease... this comment is also not included -->
|
||
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Document</title>
|
||
|
<meta charset="UTF-8" />
|
||
|
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||
|
<meta content="ie=edge" http-equiv="X-UA-Compatible" />
|
||
|
<link rel="stylesheet" href="#" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<span style="color: red">Hello, world!</span>
|
||
|
</body>
|
||
|
</html>
|
||
|
```
|
||
|
|
||
|
# Syntax
|
||
|
|
||
|
bberry has some super simple syntax helpers:
|
||
|
|
||
|
- You can create raw HTML elements using `(text "...")` or `(' "...")`
|
||
|
- You can add attributes using `(attr "key" "value")` or `(: "key" "value")`
|
||
|
- You can quickly add text to an element by adding an apostrophe at the end of its tag (if it has no children) like `(h1'"Hello, world!")`
|
||
|
|
||
|
# License
|
||
|
|
||
|
bberry is licensed under the [AGPL-3.0](./LICENSE).
|