FAQ

Frequently answered questions

How does eno treat indentation and whitespace in general

In general (and with only a single exception), all whitespace before, between and after any token is stripped away:

# section
field: a field's value
list:
- item

> ... produces the same result as would ...

  #       section
  
    field   :   a field's value
    
    list:
    
        -    item

The only exception to this is the inside (= the value) of a multiline field:

-- my_field
The Value
-- my_field

> ... produces the same result ("The Value") as would ...

  --   my_field
The Value
  --   my_field
  
> ... but the following would yield a different result ("  The Value") ...

  -- my_field
  The Value
  -- my_field

> ... because all whitespace (leading/trailing, empty lines) inside a multiline field is always kept.

The absence of indented multiline values whose leading whitespace can be stripped is a design decision of the language based around the notion that editing multiline content against an "invisible left margin" is error-prone and fragile in productive use, which would work against eno's design goal of greatest possible ease of authoring and reliability and predicability of results.

How can I express a value with leading/trailing or only whitespace?

Use a multiline field - a multiline field's value is retained verbatim, all newlines and whitespace are conserved:

-- my_block

  my content  

-- my_block

In the rare case where a document needs to contain a high number of single-line values that include leading/trailing or even only whitespace you can also consider using a custom type syntax and loader to better express this concept in your application, for instance:

> In our eno documents we use our own custom type syntax for
> expressing a whitespace-only value (in this example 3 spaces)

my_value: "   "
// In our application code we define and utilize a
// reusable loader for loading our own custom type
enolib.register({ whitespace: value => value.replace(/^"|"$/, '') });

// ...

document.field('my_value').requiredWhitespaceValue();  // returns '   '

Can a key include leading/trailing or only whitespace?

This works similar to the example previously given for values:

> In our eno documents we use our own custom type syntax for
> expressing a whitespace-only key (in this example 3 spaces)

"   ": tough readbility
// In our application code we define and utilize a
// reusable loader for loading our own custom type
enolib.register({ whitespace: value => value.replace(/^"|"$/, '') });

// ...

const myValue = document.element().whitespaceKey();  // returns '   '

Note that using eno's escaping does not allow you to express leading/trailing or purely whitespace, the outer spacing in an escape sequence allows to express an ambiguous case of escaping an escape sequence but is always trimmed away:

`` my_name ``: my value 
`` `my_name` ``: my value 

Here the resulting key is 'my_name' in the first and '`my_name`' in the second example.