An open API service indexing awesome lists of open source software.

https://github.com/foxfriends/htms

Full scripting abilities using the super simple syntax of HTML
https://github.com/foxfriends/htms

esoteric html language xml

Last synced: over 1 year ago
JSON representation

Full scripting abilities using the super simple syntax of HTML

Awesome Lists containing this project

README

          

# HTMS

Everyone knows HTML, but new programmers are often intimidated by JavaScript and
its code-looking syntax. Unfortunately, HTML does not have scripting abilities
of its own. Until now!

HyperText Markup Script provides a way to express computations using just HTML.
It even provides full interoperability with JavaScript code for a smooth
transition when you feel ready to use a "real" language.

## How to use HTMS:

1. Include the `htms.min.js` script on the page
2. Create your root `` element
3. Write your code!

## Syntax

The formal syntax of the language is exactly the same as HTML, though the tags
have slightly different meanings.

## Nodes (Tags)

#### ``

The root HTMS node defines where to start running your HTMS code. All exported
values will be placed in a global JavaScript object with the name given by the
`name` attribute. (i.e. `some_name`, or `window.some_name`).

The final value of the `` node is automatically exported with the name
`default`.

```html

```

#### ``

Provides no special purpose other than to execute its children in order. It can
be used to turn variables into strings and numbers (see `` and ``).
```html



```

#### ``

Assigns the final value of its children to the variable given by the name
attribute. This variable can then be referenced later by its name.

Note that there are a few built in identifiers which cannot be used as variable
names, namely `true`, `false`, and `$_`. These correspond to the Boolean true
and false values, and the "previous value".

`$_` is often used internally, and so you should not need to reference it, but
you can. `$_` always holds the value of the previously executed node in the
current block. When no nodes have yet been run in the current block, the value
of `$_` is `null`. This is the only way to obtain the `null` value, which may be
useful at times.

```html

Hello world



string

```

#### ``

Turns its final value into a string. If it is a text node, the text is used
literally. Otherwise, it is the return value of evaluating the final element.

```html
3
Hello world
x
x
```

#### ``

Similar to `` but for numbers.

```html
5
3
x
x
```

#### ``

Similar to `` but for Booleans.

```html
0
3
0
false
true
false
x
x
```

#### ``

Negates its final value as a Boolean. Note that this is an operator, and not a
type constructor, so untyped values are evaluated as variables automatically and
do not require being nested in a ``.

```html
false
true
3
false
x
x
```

#### ``

Produces the sum of all the elements in its final value, which must be an array
of numbers or strings. With strings, it performs concatenation.

```html



  1. 3

  2. 4

  3. 5




  1. 3

  2. 4

  3. 5



```

#### ``

Similar to ``, but performs subtraction. Does not work on strings.
```html


  1. 3

  2. 4

  3. 5

```

#### `

`

Similar to ``, but performs division.
```html



  1. 10

  2. 2

  3. 5



```

#### ``

Similar to `

`, but performs multiplication.
```html



  1. 10

  2. 2

  3. 5



```

#### ``

Raises `$_` to the power of its final value. Both must be numbers.

```html

32
```

#### ``

Performs a less than comparison between `$_` and its final value.

```html

35

53
```

#### ``

Performs an equality comparison between `$_` and its final value. Types of both
arguments must be the same for this to evaluate to true.

```html

33

53
```

#### `

    ...
  1. `

    Creates an array, where each array element is the final value of each `


  2. `

    ```html


    1. 3

    2. Hi



      1. 5




    ```

    #### `

    ...
    ...

    `

    Creates a dictionary where each key, denoted by `


    `, corresponds to the value
    of the following `

    `. The children of `

    ` must start with `
    ` and then
    alternate `




    `

    ```html



    first_name

    John

    last_name

    Smith

    age

    15


    ```

    #### ``

    Perform the subscript operation to extract the values of an array or object. The
    final value of the `` is the key to extract.

    ```html


    first_name

    John

    last_name

    Smith

    age

    15



    objfirst_name


    1. 3

    2. Hi



      1. 5





    arr1
    ```

    #### ``

    Defines a function. User-defined functions can take only one argument. If you
    need more arguments, consider currying or passing an array or dictionary
    instead.

    The contents of the `` tag define the body of the function. To
    reference the argument, use the variable `argument`. The final value is used as
    the return value.

    The function can be later referenced by its name, given by the name attribute.

    ```html

    ```

    #### ``

    Performs a function call, passing its final value to the function referred to
    by the previous value (`$_`). This node evaluates to the return value of the
    function.

    ```html


    hello world

    fnhello world
    ```

    #### ` ... ... ... `

    The if-else block. If the final value of the (required) `` tag is
    `true`, the (optional) `` block is run. If it is false, the (optional)
    `` block is run. The return value of the `` is the final value
    of whichever block was run. If the block to run did not exist, the previous
    value of `$_` is returned instead.

    For those experienced with programming who are used to the `else if` clause,
    there is none, and you must instead nest `` to achieve this effect.

    #### ``

    Obtains the native, global, JavaScript object `window[identifier]`, where the
    identifier is the final value of its children. Notice that the types of native
    objects are not the same as HTMS types, so if you wish to use it as a HTMS
    number or string, you must use the respective `` or `` to perform the
    conversion. You can, however, pass HTMS values to these functions as they will
    be converted automatically.

    ```html


    Mathmin


    1. 3

    2. 7




    ```

    #### ``

    Performs a function call, but instead of passing its final value as the
    argument, its final value must be an array whose elements are passed as multiple
    arguments to the function. This is most useful for interacting with native
    JavaScript code, as user-defined functions can only have one argument.

    ```html


    Mathmin


    1. 3

    2. 7




    ```

    #### ``

    Exports a HTMS value to the host program with the name given by the name
    attribute.

    ```html

    3

    ```