GitHub - sadreck/ThermalMarky · GitHub

Source: original

🖨️ ThermalMarky - Markdown Thermal Printer

Did you ever buy a thermal receipt printer "to do cool stuff" which is now collecting dust? No? Me neither.

But if you have a friend that did, ThermalMarky is here to help by supporting basic Markdown features and a basic WebUI to go with it.

Features

Quick Start

Printer Installation

Unfortunately due to the different types of thermal printers out there, you will need to make sure your printer works before trying to use ThermalMarky.

This project has only been tested with MUNBYN Thermal Printer / ITPP047UE-WH-UK.

Configuration

Rename .env.example to .env and fill in the required information.

Printer Setup

Printer Connection: usb or network

MARKY_TYPE=usb

USB, get this information by running lsusb while your printer is connected. You should see something like this:

Bus 001 Device 094: ID 04b8:0e20 Seiko Epson Corp. TM-m30-ii

MARKY_VENDOR_ID=0x04b8 MARKY_PRODUCT_ID=0x0e20

Network, how you get this information depends on which printer you have.

MARKY_IP=192.168.1.100 MARKY_PORT=9100

Configuration Setup

Number of lines to print before truncating output to avoid printing out LOTR.

MARKY_MAX_LINES=30

Max line width supported by the printer for text-wrapping.

MARKY_LINE_WIDTH=48

ESC/POS text font. Try a or b. b is commonly the smaller text font.

MARKY_FONT=a

Configuration in Text

You can also override configuration via the contents of the data to be printed, by enclosing it in <!-- -->.

Hello World!

This will be printed in font 'b' and max line width will be 64!

Running with Docker (Recommended)

Docker is the easiest way to get ThermalMarky up and running, especially for managing USB permissions.

Build and Start:

docker compose up --build

Access the UI: Open https://localhost:8000 in your browser. (Note: Uses self-signed certificates incerts/ for secure transport)

Running Locally

If you prefer to run it bare-metal, follow these steps:

Prerequisites

sudo apt install libusb-1.0-0-dev libjpeg-dev zlib1g-dev libcups2-dev python3-dev gcc

Setup

Install Dependencies:

python3 -m venv .venv pip install -r requirements.txt . .venv/bin/activate

Launch the Web Server:

python3 main.py

Usage

You can print files directly without the web interface:

Print a file

python print.py my_list.md

Pipe content directly

echo "# Hello World" | python print.py

HTTP request

curl --insecure -X POST "https://127.0.0.1:8000/print" -d "markdown=$(cat my-message.md)"

or

curl --insecure -X POST "https://127.0.0.1:8000/print" --data-urlencode "markdown@my-message.md"

Markdown Support

Beyond standard Markdown, ThermalMarky supports special tags:

Tag | Description

**word** | Bold __word__ | Underline # | H1 ## | H2 [align=center] | Center-align the following text (also left, right) [qr=https://...] | Generate and print a QR code [effect=line--] | Print a horizontal line of dashes [effect=line-*] | Print a horizontal line of asterisks

Example

[align=center]# Thermal Marky

This is very important but this not so much.

[align=right]This is on the right

[effect=line--]

[align=center][qr=https://github.com/sadreck/ThermalMarky]

Printer UI

Result

Printer Sample

Troubleshooting