Browser Example MVP Plan
Goal
Get to a usable MVP as fast as possible:
- Type a URL in an address field.
- Fetch the page HTML.
- Parse HTML with libxml2.
- Render readable plain text blocks (no tags, no CSS, no JS).
Everything else is explicitly deferred until after this works.
MVP Scope (Must-Have)
- One browser window.
- One address input.
- One load action (Enter key in address field).
- Async fetch via Orion HTTP.
- HTML to plain text-block conversion via libxml2.
- Text output area with basic wrapping/scroll.
MVP Phase 1: Minimal Skeleton
- Add
examples/browser/with one main window proc. - Keep state minimal:
current_urlloadingflagrequest_idhtml_rawbufferrender_textbuffer
- Create window and child controls:
- top address
win_textedit - content view area for rendered text
- top address
Note: for MVP speed, create controls directly as child windows. Do not block on extending WINDOW_TOOLBAR item types first.
MVP Phase 2: URL Entry and Fetch
- On Enter in address field:
- normalize URL (prepend
https://if missing scheme) - set
loading = true - call
http_request_async
- normalize URL (prepend
- On
evHttpDone:- store response body in
html_raw - clear
loading - trigger parse step
- store response body in
MVP Phase 3: libxml2 Parse to Text Blocks
- Parse with
htmlReadMemory. - Traverse DOM and emit plain text only:
- text nodes -> append normalized text
- block elements (
p,div,li,h1..h6, etc.) -> add\n\n br-> add\n
- Drop scripts/styles entirely.
- Output goes to
render_text.
Definition of done for parser MVP:
- Visible text is readable.
- No raw tags shown.
- Paragraphs are separated as text blocks.
MVP Phase 4: Paint and Scroll
- Render
render_textwith existing small-font draw APIs. - Basic line-wrap to viewport width.
- Use built-in vertical scroll support for long pages.
- Show a simple loading message while request is in flight.
MVP Build and Dependency
- Wire libxml2 only for the browser example target (prefer
pkg-config --cflags --libs libxml-2.0). - If libxml2 is missing:
- browser example fails with clear message
- rest of project still builds.
Post-MVP (Deferred)
- Back/forward history.
- Link extraction and clickable links.
- Opening links in new windows.
- Toolbar integration via
WINDOW_TOOLBARitem extensions. - Relative URL resolution.
- Any styling beyond plain text.
Fast Validation Checklist
- Launch browser example.
- Type URL and press Enter.
- Request completes without crash.
- Content area shows parsed text blocks (not HTML tags).
- Long pages can be scrolled.