Skip to content

Commit

Permalink
Add emptyln constant
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Sustrik <[email protected]>
  • Loading branch information
sustrik committed Mar 31, 2019
1 parent 22d78f8 commit 22b6691
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,27 @@ triangle;

Given that standard tile literals cut off the surrounding whitespace from the
tile we need to use a different construct when we actually want the surrounding
whitespace to appear in the tile. `t%` can be used to achive that.
whitespace to appear in the tile.

The most common use case is when there's a need to add an empty line to a tile.
`emptyln` is a tile containing only a single empty line:

```python
tile = t/"Hello" | emptyln | t/"world"
println(tile)

```

Prints:

```
Hello
world
```

`emtyln` is really just a shortcut for `t%""` where `t%` is similar to `t/`
except that it doesn't cut off the whitespace.

(In the example below ␣ stands for space.)

Expand Down
1 change: 1 addition & 0 deletions tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ def __str__(self):

t = _tile([])

emptyln = t%""

0 comments on commit 22b6691

Please sign in to comment.