https://github.com/detectivekaktus/belformat
Formatting tools for the terminal output in C
https://github.com/detectivekaktus/belformat
ansi c formatting library markdown output styling syntax-highlighting terminal
Last synced: 23 days ago
JSON representation
Formatting tools for the terminal output in C
- Host: GitHub
- URL: https://github.com/detectivekaktus/belformat
- Owner: detectivekaktus
- License: mit
- Created: 2024-03-15T19:54:24.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-30T20:43:56.000Z (about 1 year ago)
- Last Synced: 2025-03-24T04:43:41.208Z (about 1 month ago)
- Topics: ansi, c, formatting, library, markdown, output, styling, syntax-highlighting, terminal
- Language: C
- Homepage:
- Size: 471 KB
- Stars: 19
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# belformat
Belformat is a simple and convenient tool for styling and formatting output in C. Use a syntax similar to HTML and add originality to your project. Belformat operates around the standard output functions in C from `stdio.h`, as well as ANSI escape codes.The library is written in the C programming language and does not require additional dependencies to function. You can use this tool as either a statically generated library or as a dynamic library depending on your needs.
The project is open to everyone, and anyone familiar with [CONTRIBUTING.md](https://github.com/Artiom-Astashonak/belformat/blob/master/CONTRIBUTING.md) can suggest their own changes to the repository to make Belformat better and more convenient.
## Examples
If you prefer not to read all the detailed examples of the library usage below, compile a single example file and run it by executing:```sh
$ make examples
$ ./exam
```
### Formatting
Belformat provides all the standard formatting methods available to ANSI users with a simpler and more understandable syntax.#### Bold
Use the `` tag (for `b`old) before the start of the text block you want to make bold, and close the tag with `>` at the end f the block to reset all styles added before it.`>` is universal for every single tag, as it appends clear sequence that deletes all styling.
#### Italic
To achieve italic text, use the `` tag (for `i`talic) and close it with `>` at the very end, resulting in a similar outcome:
#### Underlined
Underline text with the `` tag (for `u`nderlined), which like all tags, must be closed with `>` to remove its effect for all subsequent characters.
#### Strikethrough
To get strikethrough text, use the combination of `` tag (for `s`trikethrough) and `>` as in previous cases.
#### Dim
Dim color is relative to the current text color and depends on your terminal settings. Use a combination of `` tag (for `d`im) and `>` to achieve the desired result.
#### Reversed
Reversed color swaps the text color and the background color. Use `` (for `r`eversed) along with `>`.
#### Blinking
This type may not be available for your terminal. Wrap the text in `` (for b`l`inking) and close it with `>`.#### Private
You can hide the output values using `` (for `p`rivate) and close it with `>`.
### Styling
In addition to formatting using standard ANSI, you can also style text using terminal-dependent colors. Available colors are: black, red, green, blue, yellow, magenta, cyan and white.The general syntax for adding colors works as follows: ``. For example:
To add color exclusively without formatting, use the `` (for `c`olor) tag.
If you wish to have your own colors, you can add them with HEX color notation like so:
### Utility
The project also has several utilities for logging output (`bellog()` function), information (`belinfo()` function), warnings (`belwarn()` function), and errors (`belerror()` function).
## Compilation
Belformat assumes you have a C compiler (either GCC or clang) installed, as well as GNU make for building the library.To generate a dynamic library, follow the instructions for your operating system below:
### POSIX
```sh
$ make psx_belformat
```### Windows
```sh
$ make win_belformat
```Otherwise, generate a static library with the following command:
```sh
$ make static_belformat
```