pintora

repository·master·Indexed 23 days ago

https://github.com/hikerpig/pintora

An extensible JavaScript text-to-diagram library for browser and Node.js environments. It enables the generation of visual diagrams—including Sequence, ER, Component, Activity, Mind Map, and Gantt diagrams—from text descriptions. The project includes @pintora/standalone for pre-bundled implementations, @pintora/cli for transforming DSL files into PNG, JPG, or SVG images, and a development kit for creating custom diagram types via a modular plugin system.

Tokens
46.7K
Snippets
153
Records
273
Agent score
79%

What's inside pintora

  1. What is Pintora

    master

    Pintora is a JavaScript text-to-diagrams library designed to work in both browser and Node.js environments. It allows you to create diagrams using intuitive text syntax, heavily inspired by Mermaid.js and PlantUML.

    Key Capabilities

    • Browser Support: Renders diagrams as SVG or Canvas.
    • Node.js Support: Renders diagrams as PNG, JPG, or SVG files.
    • Modular Architecture: The core is lightweight; specific diagram implementations are loaded only when needed.
    • Extensibility: Includes a plugin system for developers to create and distribute custom diagram types.
  2. Overview of Pintora

    master

    Pintora is an extensible JavaScript text-to-diagrams library designed to work in both browser and Node.js environments. It allows users to create various diagrams using intuitive text syntax, drawing inspiration from Mermaid.js and PlantUML.

    Key capabilities include:

    • Browser Support: Outputs diagrams as SVG or Canvas.
    • Node.js Support: Outputs diagrams as PNG, JPG, or SVG files.
    • Clean Outputs: Generated diagrams are self-contained and do not pollute the host page with global styles.
    • Extensibility: Features a modular plugin system that allows developers to write and distribute their own diagram types.
  3. Overview of @pintora/target-wintercg

    master

    The @pintora/target-wintercg package is designed to bundle Pintora and its dependencies, along with necessary Node.js module polyfills, into a single large JavaScript file. This allows Pintora to run within WinterCG-compliant or other lightweight JavaScript runtimes.

    Note: This package is currently in a very early stage of development.

  4. Use @pintora/standalone for pre-bundled diagrams

    master

    The @pintora/standalone package is a version of Pintora that comes with all diagram implementations pre-bundled. This makes it the easiest way to get started if you want to support multiple diagram types without manually loading individual implementations.

    Pintora is a text-to-diagrams library that works in both the browser and Node.js. It is inspired by Mermaid.js and PlantUML.

  5. Process review decisions with apply-review

    master

    The apply-review command is the explicit handoff step in the pipeline. It consumes summary.json and review.json to produce review-decision.json. This decision file is used by orchestration to determine the next action.

    Decision Mapping Rules

    When apply-review is run, it maps the verdict or recommended_action.type from review.json to a next_step.type in the decision file. recommended_action takes priority over verdict if present.

    Source in review.jsonnext_step.type in review-decision.json
    verdict: acceptaccept
    verdict: rejectrepair
    verdict: needs_human_reviewescalate
    verdict: inconclusiveescalate
    recommended_action.type: acceptaccept
    recommended_action.type: rejectrepair
    recommended_action.type: repairrepair
    recommended_action.type: rerunrerun
    recommended_action.type: escalateescalate
  6. Understand the pintora-harness artifact structure

    master

    The harness produces several types of artifacts organized by the stage of the pipeline:

    Render & Inspect

    • render.svg: The generated diagram.
    • metrics.json: Quantitative data from the render.
    • findings.json: Issues identified during inspection.

    Browser Capture

    • browser.png: Screenshot of the diagram in a browser.
    • dom.html: The HTML structure used for the capture.

    Summary

    • summary.json: A machine-readable rollup of the artifact directory. It includes the run ID, case metadata, status, next action, score block, top findings, and judge inputs. Note: summarize-case only packages existing artifacts; it does not recompute diagram rules.

    Review

    • review.json: The output of review-case containing the adapter's verdict.
    • review-pack/payload.json & review-pack/README.md: Files generated when using the manual-review-pack adapter.

    Review Decision

    • review-decision.json: The stable orchestration input produced by apply-review that tells the pipeline the next step.
  7. How diagram events work in Pintora

    master

    Pintora uses a multi-stage event propagation system to transform low-level DOM/Canvas interactions into high-level diagram logic events. The flow is as follows:

    1. DOM Event: Captured by @antv/g (the underlying canvas library).
    2. IGraphicEvent: The IRenderer relates the canvas shape to a Pintora mark and emits this event.
    3. IDiagramEvent: The IDiagram performs 'recognition', mapping the graphic mark to specific logic data (e.g., an entity in an ER diagram).
    4. Listener: The event is finally delivered to your registered callback via pintora.diagramEventManager or local eventsHandlers.

    This allows you to respond to interactions with domain-specific data (like an entity's name) rather than just raw coordinates or canvas shapes.

  8. Structure a Pintora diagram definition

    master

    Every Pintora diagram must begin with a declaration of the diagram type. This declaration is followed by the specific definitions of the diagram elements and their relationships. The diagram type determines which DSL (Domain Specific Language) rules are applied to the content that follows.

    componentDiagram
      [Pintora] --> [DiagramRegistry] : Get diagram by type
  9. Define Relationship Cardinality in ER Diagrams

    master

    Cardinality defines the numerical attributes of the relationship between two entities. In Pintora, cardinality markers consist of two characters: the outermost character represents the maximum value, and the innermost character represents the minimum value.

    Marker (Left)Marker (Right)Meaning
    |oo|Zero or one
    ||||Exactly one
    }oo{Zero or more (no upper limit)
    }||{One or more (no upper limit)
  10. How Pintora's diagram processing workflow works

    master

    Pintora uses a layered abstraction model to transform textual DSL (Domain Specific Language) into visual diagrams. The workflow follows this pipeline:

    1. Input Text: The raw diagram description.
    2. IDiagramParser: Converts the text into a DiagramIR (Intermediate Representation).
    3. DiagramIR: A logical data structure representing the specific diagram type (e.g., entities in an ER diagram).
    4. IDiagramArtist: Converts the DiagramIR into a GraphicsIR.
    5. GraphicsIR: A visual representation format containing geometric primitives (marks).
    6. IRenderer: Converts the GraphicsIR into the final output (e.g., SVG or Canvas).
    Input Text
        |
        |  () IDiagramParser
        v
     DiagramIR
        |
        |  () IDiagramArtist
        v
     GraphicsIR
        |
        |  IRenderer
        v
      Output