add: improve syntax
This commit is contained in:
parent
55130db04a
commit
149025f9e4
7 changed files with 52 additions and 34 deletions
22
README.md
22
README.md
|
@ -5,21 +5,21 @@ 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
|
||||
(text "<!DOCTYPE html>") ; using a raw string for the doctype is fine
|
||||
(html
|
||||
(head
|
||||
; everything that belongs in the head element
|
||||
(title'"Document")
|
||||
(title (text "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"))
|
||||
(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" "#")))
|
||||
(link ("rel" "stylesheet") ("href" "#")))
|
||||
|
||||
(body
|
||||
; the actual body only starts here
|
||||
(span (: "style" "color: red") ('"Hello, world!"))))
|
||||
(span ("style" "color: red") (text "Hello, world!"))))
|
||||
```
|
||||
|
||||
This yields:
|
||||
|
@ -45,9 +45,11 @@ This yields:
|
|||
|
||||
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!")`
|
||||
- You can create raw HTML elements using `(text "...")` or `(tag' "...")`
|
||||
- You can add attributes using `(attr "key" "value")` or `("key" "value")`
|
||||
- Whitespace is ignored (except for in parenthesis), so you can format however you'd like
|
||||
- The only formatting rule is there must be a space after tag names, and everything must be in parenthesis!
|
||||
- Parenthesis and strings must also be properly closed
|
||||
|
||||
# License
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue