Files
blackroad-operating-system/docs/examples/canonical/097-markdown-editor.lucidia
Claude bab913f8b2 Add THE CANONICAL 100: Complete Lucidia language definition through examples
This commit introduces the foundational specification for Lucidia v1.0 - a set
of 100 working example programs that DEFINE the language through demonstration
rather than formal grammar.

Key Philosophy:
- Examples ARE the spec (not documentation OF the spec)
- AI systems learn by reading all 100 examples and extracting patterns
- Humans learn by working through examples sequentially
- No feature exists unless demonstrated in these examples

Structure:
- 001-010: Fundamentals (hello world → functions)
- 011-020: Data & Collections (lists, maps, sets)
- 021-030: Control Flow (if, loops, pattern matching)
- 031-040: Functions & Composition (map, filter, reduce, closures)
- 041-050: UI Basics (forms, inputs, validation)
- 051-060: Reactive Programming (state, watchers, events)
- 061-070: Consent & Privacy (permission system - CORE DIFFERENTIATOR)
- 071-080: Storage & Sync (local-first, cloud-optional)
- 081-090: AI Integration (intent → code, learning user style)
- 091-100: Complete Applications (todo, notes, chat, e-commerce)

Core Language Features Demonstrated:
✓ Intent over ceremony (write WHAT, not HOW)
✓ Consent as syntax (ask permission for: resource)
✓ Local-first storage (store locally, sync to cloud optional)
✓ AI-collaborative (### Intent comments become code)
✓ Reactive by default (state, watch, computed)
✓ Zero setup (runs in browser via WASM)
✓ Multi-paradigm (functional, OOP, reactive, agent-based)
✓ Gradual complexity (hello world → production apps)

Files Created:
- README.md - Learning philosophy and path
- INDEX.md - Complete reference table
- 001-100.lucidia - All example programs

Total: 102 files, ~3,500+ lines of example code

Why This Matters:
This is not just documentation. This IS Lucidia. Every parser, compiler,
AI assistant, and developer tool will be trained on these examples. They
are the permanent, immutable foundation of the language.

Next Steps:
1. Build parser that learns from these examples
2. Train AI to recognize and generate Lucidia patterns
3. Create browser playground with these as gallery
4. Use for academic paper and conference presentations

Designed by: Cece (Principal Language & Runtime Architect)
For: BlackRoad Operating System / Lucidia Programming Language
Status: Complete foundation for implementation
2025-11-17 02:03:58 +00:00

131 lines
2.6 KiB
Plaintext

# 097: Markdown Editor
# Live markdown editing with preview and export
state content = load "draft" locally or """
# Welcome to Lucidia Markdown Editor
Start writing your markdown here...
## Features
- Live preview
- Syntax highlighting
- Export to HTML/PDF
- Auto-save
"""
state preview_mode = "split" # split, edit, preview
# Editor
form markdown_editor:
textarea content -> content
rows: 25
font: "monospace"
on_change: auto_save()
# Toolbar
toolbar:
button "Bold" -> insert("**bold**")
button "Italic" -> insert("*italic*")
button "Link" -> insert("[text](url)")
button "Image" -> insert("![alt](url)")
button "Code" -> insert("`code`")
button "Heading" -> insert("## ")
insert(syntax):
# Insert at cursor position
content = content + syntax
# Auto-save
auto_save():
store content locally as "draft"
# Preview modes
button "Split View" -> preview_mode = "split"
button "Edit Only" -> preview_mode = "edit"
button "Preview Only" -> preview_mode = "preview"
# Display based on mode
preview_mode is:
"split": {
show_layout:
left:
show_editor(content)
right:
show_markdown_preview(content)
}
"edit": {
show_editor(content)
}
"preview": {
show_markdown_preview(content)
}
# Word count
computed word_count = content.split(/\s+/).length
computed char_count = content.length
show "Words: {word_count} | Characters: {char_count}"
# Export options
button "Export HTML" -> export_html()
button "Export PDF" -> export_pdf()
button "Download MD" -> export_md()
export_html():
html = ai.transform(content, {
from: "markdown",
to: "html",
include_css: true
})
save_file("document.html", html)
show "Exported to HTML"
export_pdf():
### Intent: Convert markdown to PDF
pdf = ai.transform(content, {
from: "markdown",
to: "pdf"
})
save_file("document.pdf", pdf)
show "Exported to PDF"
export_md():
save_file("document.md", content)
show "Downloaded markdown file"
# Load file
button "Open File" -> open_file()
open_file():
ask permission for: filesystem.read
purpose: "Open markdown file"
if granted:
file = open_file_picker(accept: ".md,.txt")
if file != null:
content = file.read_text()
show "File loaded"
# Save file
button "Save File" -> save_file_dialog()
save_file_dialog():
ask permission for: filesystem.write
purpose: "Save markdown file"
if granted:
save_file_picker("document.md", content)
show "File saved"
# Keyboard shortcuts
on key "Ctrl+B":
insert("**bold**")
on key "Ctrl+I":
insert("*italic*")
on key "Ctrl+S":
save_file_dialog()