PHPackages                             tetrode/chalkmark - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. tetrode/chalkmark

ActiveLibrary[CLI &amp; Console](/categories/cli)

tetrode/chalkmark
=================

Render Markdown right in your terminal / CLI — headings, colors, lists, code blocks

v1.0.3(5mo ago)02MITPHPPHP &gt;=8.2

Since Nov 23Pushed 1mo agoCompare

[ Source](https://github.com/tetrode/chalkmark)[ Packagist](https://packagist.org/packages/tetrode/chalkmark)[ RSS](/packages/tetrode-chalkmark/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Chalkmark
=========

[](#chalkmark)

[![Chalkmark](images/chalkmark.png)](images/chalkmark.png)

---

Render Markdown right in your terminal — headings, colors, lists, code blocks

---

Chalkmark supports
------------------

[](#chalkmark-supports)

Chalkmark is a small PHP library that renders a large subset of Markdown to plain-text suitable for CLI output, with optional ANSI colors. It is designed to be lightweight and dependency-free. An example of the terminal output is shown at the end of this README.

### Rationale

[](#rationale)

Embedding Chalkmark into your PHP Docker image turns the container into a self‑documenting, self‑supporting product. Operators can quickly discover how to use the image, read the full `README.md` directly in the terminal (with clear formatting and optional colors), and run the app without leaving the CLI. This reduces support tickets and misconfigurations, while improving developer experience and adoption.

Chalkmark supports:

- Headings `#` ... `######` (levels 1–6)
- Horizontal rules as 40+ underscores on a line
- Unordered lists using `-`, `*`, or `+` (with indentation)
- Ordered lists like `1.` or nested `1)` … (with indentation)
- Paragraphs with inline formatting:
    - code using backticks: ``code``
    - *italic*: `*text*` or `_text_`
    - **bold**: `**text**` or `__text__`
    - ***bold+italic***: `***text***` or `___text___`
- Code blocks fenced by backticks: ````code````
- Blockquotes using a pipe-prefix syntax: `| quote` with nesting like `| | nested`
- Tables using pipe syntax (GitHub-style). Table blocks are normalized: column widths are computed, cells are padded, and alignment markers (`:---`, `:---:`, `---:`) control left/center/right alignment.

Notes on header background bars (reversed theme):

- When using the `reversed` theme, heading lines (h1–h6) are rendered with a colored background.
- The colored background extends to the terminal width when Chalkmark can determine it via the `COLUMNS` environment variable.
- If the terminal width is unknown, Chalkmark pads the colored bar to `max(60, visible heading length)` characters.
- This background fill applies only when the active heading style actually includes a background color and colors are enabled; other themes are unaffected.

Rendered output ends with a trailing newline and ensures there is a blank line at the end.

Requirements
------------

[](#requirements)

- PHP version: PHP 8.2+
- Package manager: Composer
- Test framework: PHPUnit 11
- Autoloading: PSR-4
- Demo scripts:
    - `tests/show-fixture-markdown.php`
    - `tests/show-own-readme.php`
    - `tests/show-themes.php`

Installation
------------

[](#installation)

This package is a Composer library. From a project that uses Composer, you can install it with:

```
composer require tetrode/chalkmark

```

Usage
-----

[](#usage)

Minimal example rendering a file and printing to STDOUT:

```
