The first Markdown renderer built entirely in MicroPython for the HP Prime graphing calculator.
Read beautifully formatted Markdown documents right on your calculator's 320×240 display — no PC required.
- Headers — H1 through H6 with distinct sizing and color
- Bold, italic,
strikethrough, andinline codeformatting - Links rendered in a distinct color
- Blockquotes with accent bar (supports nesting)
- Bullet lists and numbered lists with nesting support
- Task lists —
- [x]and- [ ]checkboxes - Horizontal rules (
---,***,___) - Tables with header styling and alternating row colors (warns if too wide)
- Embedded images via base64-encoded raw pixel data or image files (PNG, etc.)\n- Math formula rendering — fenced code blocks tagged
math,formula, orcasrender CAS expressions in pretty-print via the HP Prime CAS engine - Word wrapping that fits the 320px-wide screen
- Smooth scrolling with Up/Down keys or touch drag
- Scroll position indicator — thin scrollbar on the right edge
- Built-in file browser to pick
.mdfiles from calculator storage - Favorites / pinned files — tap the yellow \u2605 star on any row to pin it; favorites sort to the top
- Recently opened files — quick access to your last 10 opened files
- Sortable column headers — tap \u2605, Name, or Size headers to sort; tap again to reverse
- File size display — each file’s size is shown in its own column
- Folder-prefix display — files named
prefix_name.mddisplay asprefix/name.mdfor visual organization - Back navigation — press ESC to return to file browser without exiting
- Search — press F1 to find text, F2 for next match, with highlighting
- Light / Dark theme — press F6 to toggle, works in browser and viewer
- Multiple bookmarks per file — long-press to add, red indicators on scrollbar
- Bookmark manager — tap Marks to view, jump to, or delete bookmarks
- Auto-save — last opened file and scroll position remembered
md_demo.mp4
- An HP Prime graphing calculator (hardware or virtual/emulator)
- Firmware that supports MicroPython / Python apps
- Connect your HP Prime to your computer.
- Copy the entire
MarkdownViewer.hpappdirfolder into the calculator's app directory. - The app will appear as MarkdownViewer in your application list.
Place any .md files in the app's storage folder on the calculator. The built-in file browser will list them automatically.
- Launch MarkdownViewer from the app menu.
- Use Up / Down to highlight a
.mdfile, then press Enter to open it. - Scroll through the rendered document with Up / Down or by dragging on the touchscreen.
- Press ON (or trigger a
KeyboardInterrupt) to return to the file browser or exit.
| Key | Action |
|---|---|
| Up / Down | Navigate file list |
| Enter / Tap | Open selected file |
| Tap column header | Sort by \u2605, Name, or Size |
| Tap \u2605 star | Pin / unpin a file |
| Recent (F1) | Show recently opened files |
| Theme (F6) | Toggle light / dark theme |
| ON | Exit app |
| Key | Action |
|---|---|
| Up / Down | Scroll line by line |
| + / - | Scroll page by page |
| Backspace | Jump to start |
| LOG | Jump to end |
| ESC | Back to file browser |
| Find (F1) | Search for text |
| Next (F2) | Jump to next search match |
| Marks | Open bookmark manager |
| Theme (F6) | Toggle light / dark theme |
| Long press | Add bookmark at current position |
| Touch drag | Drag to scroll document |
| ON | Exit app |
| Element | Syntax |
|---|---|
| Headings | # H1 through ###### H6 |
| Bold | **bold** |
| Italic | *italic* |
| Strikethrough | ~~deleted~~ |
| Inline code | `code` |
| Links | [text](url) |
| Blockquotes | > quote (nest with >>) |
| Bullet list | - item or * item (indent for nesting) |
| Ordered list | 1. item (indent for nesting) |
| Task list | - [ ] todo or - [x] done |
| Horizontal rule | ---, ***, or ___ |
| Tables | | col1 | col2 | (up to 5 columns) |
| Images |  or  |
Note: Images can be loaded directly from files (PNG, etc.) placed in the app folder using
. Alternatively, images can use a custom raw format — the first 4 bytes encode width and height (2 bytes each, big-endian), followed by RGB pixel triplets, all base64-encoded. File-based images that exceed the display width are automatically scaled down.
MarkdownViewer.hpappdir/
├── main.py # Entry point — viewer loop + app-specific logic
├── browser.py # Column-based file picker with sortable headers
├── ui.py # Reusable UI: menu bar, input bar, context menu, list manager
├── input_helpers.py # Reusable keyboard and touch input helpers
├── markdown_viewer.py # MarkdownViewer, MarkdownRenderer & MarkdownDocument classes
├── graphics.py # Drawing primitives (text, rectangles, images)
├── constants.py # Colors, font sizes, layout constants
├── theme.py # Light/dark theme palettes and toggle
├── bookmarks.py # Multi-bookmark storage per file
├── file_prefs.py # Favorites, recent files, and sort preferences
├── file_ops.py # File listing via HP Prime AFiles()
├── keycodes.py # Key code constants for GETKEY
├── utils.py # Misc helpers (color math, text measurement)
├── time.py # Simple tick-based timer
├── help.md # Sample Markdown file bundled with the app
├── MarkdownViewer.hpapp # HP Prime app descriptor
├── MarkdownViewer.hpappnote # App notes
└── MarkdownViewer.hpappprgm # App program metadata
A minimal example showing how the viewer is used in main.py:
from constants import GR_AFF
from markdown_viewer import MarkdownViewer
# Create viewer targeting the display buffer
viewer = MarkdownViewer(GR_AFF)
# Load and render a Markdown file
viewer.load_markdown_file("help.md")
viewer.render()
# Scroll through the document
viewer.scroll_down() # scroll by 20px
viewer.render()
viewer.scroll_by(50) # scroll by arbitrary pixel amount
viewer.render()main.pyboots the app, scans for.mdfiles viafile_ops.list_files(), and presents a scrollable file browser.- When a file is selected, a
MarkdownViewerinstance loads and parses the Markdown content. MarkdownRendererwalks each line, identifies block-level elements (headers, lists, rules, images), then renders them with word-wrapping and inline formatting to the HP Prime's graphics buffer usingTEXTOUT_PandFILLRECTPPL commands exposed through thehpprimeMicroPython module.- Scrolling adjusts a vertical offset and re-renders the visible portion of the document.
- Tables wider than 5 columns display a warning instead of rendering
- Code fences (
```) are recognized but the enclosed block is rendered as plain text (no syntax highlighting) - Links are displayed in color but cannot be opened on the calculator
- Images must be in the custom base64-encoded raw RGB format described above, or loaded from image files in the app folder
- Search highlights matches in paragraphs, lists, and blockquotes (not in headers, tables, or code fences)
- Bold is simulated via 1px-offset double-draw (no true bold font on HP Prime)
- Italic is rendered as a distinct color (no slanted font available)
Contributions are welcome! Feel free to open issues or submit pull requests.
Some ideas for future improvements:
- Syntax highlighting in code fences
- Horizontal scrolling for wide tables and code blocks
- Draggable scrollbar for fast navigation
- Font size selector
- Search result count and navigation
This project is provided as-is for educational and personal use.
Andrea Baccin
Built with ❤️ for the HP Prime community.