render_hwp_equation_svg
Converts OWPML equation scripts into SVG format for use in HWP documents, supporting custom font size and color.
Instructions
Render an OWPML equation script (e.g. 'TIMES LEFT ( {a} over {b} RIGHT )') to SVG. Args: script, font_size (HWP units, default 1300), color (default 0).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | ||
| font_size | No | ||
| color | No |
Implementation Reference
- src/tools/render-extra.ts:46-59 (handler)The actual handler function that renders an OWPML equation script to SVG. Initializes the rhwp WASM runtime, creates an empty document, and calls doc.renderEquationPreview().
export async function renderHwpEquationSvg(args: RenderEqArgs): Promise<string> { await initRhwp(); const { HwpDocument } = await import("@rhwp/core"); const doc = HwpDocument.createEmpty(); try { const fontSize = args.font_size ?? 1300; const color = args.color ?? 0; return doc.renderEquationPreview(args.script, fontSize, color); } catch (e) { return `수식 렌더 오류 (equation render error): ${(e as Error).message}`; } finally { doc.free(); } } - src/tools/render-extra.ts:40-44 (schema)Type definition for the equation render arguments (script, optional font_size, optional color).
export interface RenderEqArgs { script: string; font_size?: number; color?: number; } - src/server.ts:480-483 (registration)Tool registration in the TOOLS array with name, description, and JSON Schema input validation.
{ name: "render_hwp_equation_svg", description: "Render an OWPML equation script (e.g. 'TIMES LEFT ( {a} over {b} RIGHT )') to SVG. Args: script, font_size (HWP units, default 1300), color (default 0).", - src/server.ts:543-543 (registration)Mapping from tool name to handler function in the HANDLERS record.
render_hwp_equation_svg: renderHwpEquationSvg, - src/server.ts:36-36 (registration)Import of the renderHwpEquationSvg function from the render-extra module.
import { renderHwpHtml, renderHwpEquationSvg } from "./tools/render-extra.js";