Download the PHP package tetrode/chalkmark without Composer
On this page you can find all versions of the php package tetrode/chalkmark. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package chalkmark
Chalkmark
Render Markdown right in your terminal — headings, colors, lists, code blocks
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
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 nested1)… (with indentation) - Paragraphs with inline formatting:
- code using backticks:
`code` - italic:
*text*or_text_ - bold:
**text**or__text__ - bold+italic:
***text***or___text___
- code using backticks:
- Code blocks fenced by backticks:
- Blockquotes using a pipe-prefix syntax:
| quotewith 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
reversedtheme, 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
COLUMNSenvironment 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
- PHP version: PHP 8.2+
- Package manager: Composer
- Test framework: PHPUnit 11
- Autoloading: PSR-4
- Demo scripts:
tests/show-fixture-markdown.phptests/show-own-readme.phptests/show-themes.php
Installation
This package is a Composer library. From a project that uses Composer, you can install it with:
Usage
Minimal example rendering a file and printing to STDOUT:
Customizing colors or disabling them:
Theming
Chalkmark supports themes. A theme is a simple associative array mapping style keys to ANSI escape sequences. The default theme mirrors the legacy built-in colors.
- Built-in themes:
default— classic Chalkmark palettemonochrome— disables all colorsreversed— headers with bright white on colored backgrounds (full‑width bars)banner— strong background bars for headers (like reversed, different aesthetic)nord— cool, subdued blues/cyans; calm aestheticdracula— vibrant magenta/green/yellow with cyan accents; strong contrastgruvbox-dark— warm earthy yellow/orange/aqua tones; developer friendlysolarized-dark— classic blue/cyan/green/yellow; balanced contrast (16‑color)pastel-light— soft rose/peach/mint/sky tones for light terminals
- Select a theme via the second constructor argument:
Theme Gallery (quick preview):
Notes on 256‑color usage:
- Some themes (e.g., nord, dracula, gruvbox-dark, pastel-light) use 256‑color SGR codes (
38;5;NN). Most modern terminals support these; if your terminal does not, switch todefault,monochrome, orsolarized-darkfor maximum portability.
You can also provide your own theme:
1) Register at runtime:
2) Load from a PHP file that returns an array:
Override precedence: built-in theme < registered/file theme < per-run $colors overrides. Setting an override value to '', false, or null disables that style.
Command-line demo
This repository includes a tiny demo script you can run locally after installing dependencies:
Table example
Input:
Output (no colors):
Running tests
PHPUnit is configured as a dev dependency. After composer install you can run:
Tests include both behavior assertions and a demonstration that writes rendered output to the CLI.
Versioning
v1.0.3
- Remove deprecated test script for PHP containers, update README structure, add example script and README for demo usage.
- Add new built-in themes: nord, dracula, gruvbox-dark, solarized-dark, pastel-light, and banner with corresponding tests and README updates
- Add theming support with built-in themes, overrides, and tests Added Table tests
v1.0.1
- First public release
License
Chalkmark is made available under the MIT License (MIT). Please see License File for more information.