Skip to content

Addup is a whitespace-dependent HTML template language. This is an implementation off its interpreter.

License

Notifications You must be signed in to change notification settings

fourpoints/addup

Repository files navigation

Setup

Import treebuilder : infile_path -> xml from addup.treebuilder and htmlprinter : outfile_path , xml -> None from addup.treeprinter.

Syntax

Example file

+doctype(html)
+html:
  +head:
    +title: Ipsum lorem
    +meta(charset = "utf-8")

  +body: //comment
    +Section:
      +h3: heading
      +p:
        sample text sample text sample
        sample text sample +b(text sample
        text) sample text
      +br
      +ul:
        +li: +a(href = "example.com"):(link name)
        +li: +a(href = "example.com"):(link name)
<!doctype html>
<html>
<head>
  <title>Ipsum lorem</title>
  <meta charset="utf-8">
</head>
<body><!--comment-->
  <div class="section">
    <h3>heading</h3>
    <p>
      sample text sample text sample
      sample text sample <b>text sample
      text</b> sample text
    </p>
    <br>
    <ul>
      <li><a href="example.com">link name</a></li>
      <li><a href="example.com">link name</a></li>
    </ul>
</body>
</html>

+tag

+tag(attribute="value"):(content) creates opening and closing tags around the indented block. Note that + tag will be ignored by the interpreter. The tag must be followed by a space/newline (" ", "\n") or an opening bracket ("(").

+div: text
  text
text
<div>text
  text
<div>
text

attributes

+tag(attribute="value") are comma-separated entries. This will be converted to <tag attribute="value"></tag>.

.class and #id

+span.hello#world Multiple classes and ids may be added by using CSS selector style syntax. This will be converted to <span class="hello" id="world"></span>. This is equivalent to writing +span(class="hello", id="world), however combining the two ways of writing classes and ids may result in overwriting.

inline vs block

the following addup text

+div:
  all text in the indented block will be wrapped in <div></div> tags.
  +span:(all text inside brackets will be wrapped in  <span></span> tags)

will be converted to

<div>
  all text in the indented block will be wrapped in <div></div> tags.
  <span>all text inside brackets will be wrapped in  <span></span> tags</span>
</div>

//comment

//comment creates an inline comment. (Multi-line comments are not supported.)

//this is a comment
<!--this is a comment-->

\escape_char

\escape_char escapes the next character

text \+div \//
text +div //

This is particularly useful for writing links as text; https:/\/github.com. Link in attributes are unaffected by this.

Code

`(lang) content` is highlighted with pygments, where lang is a language such as py or cpp. The first argument must be the language, the second can be block or numbering. The code will automatically be a block if there are newlines in the code.

Math

$(format) math$ is converted to an aligned mathml, where format can be dropped (along with brackets), or align for aligned math, or numbering for equation numbering (will number every line). Simple and complex math may also be used $x+y$, and will be rendered in MathML using mumath. The syntax is latex-like, with some minor quirks (read: bugs features).

+now

+now(format="%Y-%m-%d") will make a <time> element containing the date in the given format. The syntax may change in the future, to avoid exclusion of xml elements with the same name.

+style and +script will escape all addup-syntax

So you don't have to worry about your JavaScript-comments becoming HTML-styled. You can also use +css and +js to directly write the content of the css and js files to the html file.

+read(file = "name.ext")

+read(file = "file.extension") will start reading from another file, allowing you to easily combine multiple files into a single output file. The syntax may change in the future, to avoid exclusion of xml elements with the same name. file.txt:

ipsum lorem

addup file:

+div:
  +read(file="file.txt", tag="span")

HTML output:

<div>
  <span>ipsum lorem</span>
</div>

The content will be enclosed by a tag of choice or <div></div> if none are specified.

Conventions

  • tabs <> spaces
  • underscore_case > camelCase
  • green > blue

About

Addup is a whitespace-dependent HTML template language. This is an implementation off its interpreter.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages