Crates.io | seam |
lib.rs | seam |
version | |
source | src |
created_at | 2020-10-10 19:22:48.261707 |
updated_at | 2024-11-23 20:49:30.533337 |
description | Symbolic Expressions As Markup. |
homepage | https://git.knutsen.co/seam |
repository | |
max_upload_size | |
id | 298141 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Symbolic Expressions As Markup.
Because all markup is terrible, especially XML/SGML and derivatives.
But mainly, for easier static markup code generation, such as with macros, code includes and such.
This may be used as a library, such as from within a server,
generating HTML (or any other supported markup) before it is served to the
client. Personally, I am currently just using the seam
binary to statically
generate some personal and project websites.
Read the USAGE.md file for code examples and documentation.
--xml
; including: SVG, MathML)--html
; SGML)--css
)--sexp
; S-expression, basically a macro expansion utility)--text
; renders escaped strings to text)You may clone the repo, then build and install
git clone git://git.knutsen.co/seam
cd seam
cargo build --release
cargo install --path .
Or install it from crates.io
cargo install seam
Either way, you'll need the Rust (nightly) compiler and along
with it, comes cargo
.
You may use it by doing
seam test.sex --html > test.html
test.sex
contains your symbolic-expressions, which is used to generate
HTML, saved in test.html
.
Likewise, you may read from STDIN
seam --html < example.sex > example.html
# Which is the same as
cat example.sex | seam --html > example.html
You may also very well use here-strings and here-docs, if your shell supports it.
seam --html <<< "(p Hello World)"
#stdout:
# <!DOCTYPE html>
# <html>
# <head></head>
# <body>
# <p>Hello World</p>
# </body>
# </html>
seam --html --nodocument <<< "(p Hello World)"
#stdout:
# <p>Hello World</p>
seam --xml <<< '(para Today is a day in (%date "%B, year %Y").)'
#stdout:
# <?xml version="1.0" encoding="UTF-8" ?>
# <para>Today is a day in November, year 2020.</para>
seam --sexp <<< '(hello (%define subject world) %subject)'
#stdout:
# (hello world)
(%os/env ENV_VAR)
environment variable macro.(%to-string ...)
, (%join ...)
, (%map ...)
, (%filter ...)
macros.\%
.(%format "{}")
macro with Rust's format
syntax. e.g. (%format "Hello {}, age {age:0>2}" "Sam" :age 9)
(%raw ...)
macro which takes a string and leaves it unchanged in the final output. Can also take any othe source code, for which it just embeds the expanded code (plain-text formatter).(%formatter/html ...)
etc. which call the respective available formatters.(%embed "/path")
macro, like %include
, but just returns the file contents as a string.&rest
syntax.%(...)
syntax.
[ ] For example %(f x y)
is the same as (%f x y)
, so you can have (%define uneval f x)
and then write %(%uneval y)
.%list
macro which expands from (p (%list a b c))
to (p a b c)
.
Defined as such:
(%define (list &rest) rest)
%for
-loop macro, iterating over %list
s.%glob
which returns a list of files/directories matching a glob.%markdown
renders Markdown given to it as html.%html
, %xml
, %css
, etc. macros which goes into the specific rendering mode.style="..."
object should handle s-expressions well, (e.g. (p :style (:color red :border none) Hello World)
)JSON
, JS
, TOML
, &c.).(let x 2)
(let (y 1) (z 1))
(const f (=> (a b) (+ a b))
((. console log) (== (f y z) x))
(%include ...)
, which already exists).(%chez (+ 1 2))
executes
(+ 1 2)
with Chez-Scheme LISP, and places the result in the source
(i.e. 3
).