dsh-plugin-mermaid-gb-svg: Converts Mermaid Flowcharts to GB/T 1526 National Standard SVG

Introduction

Common approaches for asking models to draw flowcharts in DeepSeek Harness (DSH) involve outputting Mermaid source code or generic SVGs. If the deliverable needs to comply with China’s National Standard for flowchart symbols (GB/T 1526-1989, equivalent to ISO 5807:1985), one must manually cross-reference symbol tables to adjust shapes, orthogonal routing, and branching habits—a labor-intensive process prone to missing details.

The community plugin dsh-plugin-mermaid-gb-svg (maintainer: sandyyst) addresses this. It registers a tool within the Harness that converts Mermaid flowcharts directly into SVGs compliant with GB/T 1526-1989, with optional automatic pagination for A4/A3 paper sizes.

What is this

dsh-plugin-mermaid-gb-svg is a DSH plugin published on npm (current package version 0.1.4, MIT License). It exposes the tool mermaid_to_gb_svg to the model. It takes Mermaid flowcharts (as strings or files) as input and outputs SVG files featuring national standard symbols and orthogonal arrow connections.

The plugin is categorized under “Network Tools” in the SkillHub directory. Source code and documentation are available at the GitHub Repository, with a directory listing at skillhub.cn/plugins/sandyyst/dsh-plugin-mermaid-gb-svg. Note that the DSH community directory is an independent site and has no official affiliation with DeepSeek or High-Flyer.

Core Features

Symbol and Mermaid Syntax Mapping

The plugin draws symbols according to GB/T 1526-1989, including Start/End, Process, Decision, Data, Preparation, Predefined Process, Direct Access Storage, Manual Input/Operation, Document, Connector, and Off-page Connector. The mapping between common Mermaid node syntax and national standard meanings is as follows (excerpt):

Meaning Mermaid Example
Start/End (Rounded Rectangle) A([x]), A((x)), A(x)
Process (Rectangle) A[x]
Decision (Diamond) A{x}
Data (Parallelogram) A[/x/], A[\x\]
Preparation (Hexagon) A{{x}}
Predefined Process (Double-bordered Rectangle) A[[x]]
Off-page Connector (Pentagon) A@{ shape: off-page, label: "B" }

Extended shapes can be specified via A@{ shape: ..., label: "..." }; shape supports Mermaid v11 English names as well as Chinese names (e.g., 处理, 起止, 判断, 换页连接符). The examples/ directory in the repository contains comparable .mmd files and generated SVGs.

Drawing Conventions

  • Flow direction is left-to-right or top-to-bottom; flowlines are orthogonal (right-angled) polylines with solid arrowheads.
  • Decision nodes: “Yes” branches downwards from the bottom vertex; “No” branches rightwards from the right vertex, then turns.
  • Incoming lines connect vertically to the top center of the symbol.
  • Each flowline has at most 3 bends; routing attempts follow a 0→1→2→3 bend sequence, prioritizing paths that do not intersect symbols.
  • A geometric self-check is performed after generation (checking for overlaps, lines crossing symbols, etc.), with results written to the warnings field in the tool’s return value.

Pagination (Optional)

By default (paper: none), the plugin outputs a single large SVG. When set to a4, a4l, a3, a3l, or auto, if the drawing exceeds the paper size, it splits at gaps between layers and columns without cutting through symbols. Each page SVG uses real millimeter dimensions (e.g., A4 is 210mm × 297mm) and includes a border frame, binding margins, and (page n/N) annotations. Flowlines spanning pages are connected using Off-page Connectors (pentagons) at corresponding positions and labels on adjacent pages.

Sandbox and Writing

File writing utilizes the Harness ctx.fs interface and is subject to session sandbox policies. Similar to the built-in write tool, permission escalation can be requested via a one-time sandbox_permissions and justification parameter for retry.

Installation and Activation

The plugin requires Node.js >= 20. To install to a specific profile (using web as an example in the README):

dsh plugin --profile web add dsh-plugin-mermaid-gb-svg

After installation, the loader must be configured to load the plugin. Append a snippet similar to the following in $DSH_HOME/profiles/web/cordis.patch.yml:

- insert:
    - id: mermaid-gb-svg
      name: dsh-plugin-mermaid-gb-svg
      # config:
      #   fontSize: 14
      #   paper: none

For local development, the package path can be changed to a source directory, for example:

dsh plugin --profile web add /path/to/dsh-plugin-mermaid-gb-svg

Plugin-level configuration options (settable in the patch’s config):

Key Default Value Meaning
font SimSun, '宋体', 'Microsoft YaHei', sans-serif Font family
fontSize 14 Body font size (px)
stroke 1.6 Line width
paper none Default paper mode

Tool mermaid_to_gb_svg Usage

Models or scripts invoke the conversion logic via this tool. Key parameters are as follows:

Parameter Type Description
out string, Required Output path; if ending with .svg, treated as filename (appends -1/-2 for multiple diagrams), otherwise treated as directory or prefix
source string Mermaid source code (mutually exclusive with path)
path string .mmd/.mermaid file, or .md containing ```mermaid code blocks (extracts all blocks; the nearest heading above a block serves as the caption)
title string Diagram caption
dir td|lr|bt|rl Force flow direction
paper none|auto|a4|a4l|a3|a3l Paper size and pagination
font_size integer Body font size (px, 14 is approx. 10.5pt)
font_tu boolean Use GB/T 14691 technical drawing font (FangSong, etc.)
caption boolean Whether to draw the diagram caption (default true)

Return fields include files, diagrams, pages, summary, and warnings, facilitating the verification of output files and geometric warnings.

Typical invocation flow: In a conversation, ask the model to write Mermaid based on a business description, then call mermaid_to_gb_svg with source or path and out; set paper: a4 or a3 when print dimensions are required.

Use Cases and Notes

Who it is for: Developers needing to produce national standard flowchart SVGs directly within DSH agent workflows; scenarios involving documentation, design specifications, or compliance reviews requiring GB/T 1526 symbols and routing habits; scenarios with large diagrams requiring automatic A4/A3 pagination with off-page connectors.

Please note before use:

  1. The plugin runs under the current dsh process permissions and writes SVGs to sandbox-allowed paths. You should review the source code and MIT License before installation to ensure the origin and behavior align with your security policies.
  2. National standard nuances may still be subject to deviation; the maintainer welcomes symbol corrections via Issues (use the dedicated template and cite standard clauses/figure numbers), along with Mermaid source code, warnings, and plugin version.
  3. If the tool returns geometric warnings, the output usually contains an issue tracking link; feedback in this case is most helpful for correction.

Conclusion

dsh-plugin-mermaid-gb-svg consolidates “Mermaid diagramming” and “GB/T 1526-1989 SVG delivery” into a single step within the Harness, supporting orthogonal routing, decision branching conventions, and optional pagination. For further details and example images, see the GitHub README, and for directory access, see the SkillHub Plugin Page.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye