https://github.com/annacrombie/altprintf
a string template language
https://github.com/annacrombie/altprintf
c formatting
Last synced: over 1 year ago
JSON representation
a string template language
- Host: GitHub
- URL: https://github.com/annacrombie/altprintf
- Owner: annacrombie
- License: mit
- Created: 2019-08-07T17:31:13.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-02T15:30:18.000Z (over 3 years ago)
- Last Synced: 2025-03-22T11:46:08.208Z (over 1 year ago)
- Topics: c, formatting
- Language: C
- Homepage:
- Size: 378 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# altprintf
[](https://builds.sr.ht/~lattis?search=altprintf)
altprintf is a string template language. It was designed with a very specific
goal in mind: allowing users to customize a program's functionality through the
use of format strings.
## Features
+ Cool format specifiers, like conditionals.
+ UTF-8 character width sensitive alignment
+ Nesting expressions
+ Robust
- the library makes no memory allocations
- an advanced error reporting system
- fuzz testing based on the grammar in the docs
+ Template strings are compiled into a custom binary format
- this saves resources when reusing the same template
Note that altprintf is not designed to replace printf. It is designed with the
specific use case of providing user-specified templates to customize output.
## Example
Here is an example format string to build a statusline for something like
[swaybar](https://github.com/swaywm/sway/wiki#swaybar-configuration).
```
{win} {fetching?⇄ }{locked?閉 }{mail?〒{mail} }{cpu:> 3}% {temp}c {bat} {time}
```
Which could result in a string like:
```
mochiro.moe -- Mozilla Firefox 〒4 3% 49c 45 08:56
```
## Building
You need a compatible `meson` implementation. If you want man pages, you also need `scdoc`.
Example:
```sh
$meson setup build
$ninja -C build
```
## Docs
See the man pages