Coder Social home page Coder Social logo

demonstrandum / seam Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 110 KB

Symbolic Expressions As Markup

License: GNU General Public License v3.0

Rust 98.88% HTML 1.12%
lisp symbolic-expressions sexp macros text-processing markup html sgml xml json

seam's Introduction

SEAM

Symbolic Expressions As Markup.

Why

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.

Try it out

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.

Current Formats

  • XML
  • HTML
  • CSS

Installation

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.

Using The Binary

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>
#   <!-- Generated by SEAM. -->
#   </body>
#   </html>
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>
#   <!-- Generated by SEAM. -->

TODO

  • Rewrite lexer to only insert whitespace before and after {(, )} and next to string-literals. Whitespace should then be added between between symbols after macro expansion, since a macro could expand to any literal. Variadic macros should preserve whitespace in its arguments entirely (no stripping).
  • %list macro which expands from (p (%list a b c)) to (p a b c). This is essentially an anonymous macro definition, i.e (%define L a b c), then %L is the same as (%list a b c).
  • %for-loop macro, iterating over %lists.
  • %glob which returns a list of files/directories matching a glob.
  • %markdown renders markdown given to it.
  • %html, %xml, %css, etc. macros which goes into the specific rendering mode.
  • Add variadic and keyword macro arguments.
  • Caching or checking time-stamps as to not regenerate unmodified source files.
  • HTML object style="..." object should handle s-expressions well, (e.g. (p :style (:color red :border none) Hello World))
  • HTML <style> tag should allow for normal CSS syntax if just given a string.
  • Allow for, and handle special @ syntax in CSS, such as @import and @media.
  • Add more supported formats (JSON, JS, TOML, &c.).
  • Add more helpful/generic macros (e.g. (%include ...), which already exists).
  • Allow for arbitrary embedding of code, that can be run by a LISP interpreter (or any other langauge), for example. (e.g. (%chez (+ 1 2)) executes (+ 1 2) with Chez-Scheme LISP, and places the result in the source (i.e. 3).

seam's People

Contributors

demonstrandum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.