forked from genewildish/Mainline
Major changes: - Pipeline architecture with capability-based dependency resolution - Effects plugin system with performance monitoring - Display abstraction with multiple backends (terminal, null, websocket) - Camera system for viewport scrolling - Sensor framework for real-time input - Command-and-control system via ntfy - WebSocket display backend for browser clients - Comprehensive test suite and documentation Issue #48: ADR for preset scripting language included This commit consolidates 110 individual commits into a single feature integration that can be reviewed and tested before further refinement.
50 lines
1.1 KiB
Python
50 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Render Mermaid diagrams in markdown files to ASCII art."""
|
|
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def extract_mermaid_blocks(content: str) -> list[str]:
|
|
"""Extract mermaid blocks from markdown."""
|
|
return re.findall(r"```mermaid\n(.*?)\n```", content, re.DOTALL)
|
|
|
|
|
|
def render_diagram(block: str) -> str:
|
|
"""Render a single mermaid block to ASCII."""
|
|
result = subprocess.run(
|
|
["mermaid-ascii", "-f", "-"],
|
|
input=block,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
if result.returncode != 0:
|
|
return f"ERROR: {result.stderr}"
|
|
return result.stdout
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) < 2:
|
|
print("Usage: render-diagrams.py <markdown-file>")
|
|
sys.exit(1)
|
|
|
|
filename = sys.argv[1]
|
|
content = open(filename).read()
|
|
blocks = extract_mermaid_blocks(content)
|
|
|
|
print(f"Found {len(blocks)} mermaid diagram(s) in {filename}")
|
|
print()
|
|
|
|
for i, block in enumerate(blocks):
|
|
# Skip if empty
|
|
if not block.strip():
|
|
continue
|
|
|
|
print(f"=== Diagram {i + 1} ===")
|
|
print(render_diagram(block))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|