Table Image To Markdown
Overview
Turn a table image into a single Markdown text block that the user can paste directly into a knowledge-point content box. The target renderer is marked.js (gfm:true) for tables, KaTeX for math, and function-plot for function graphs, with images drawn inside table cells. The output must be valid Markdown only — no surrounding explanation — so it can be copied wholesale.
Basic Rules
- Use GitHub-flavored Markdown tables:
| 表头1 | 表头2 | | --- | --- | | 内容 | 内容 | - Faithfully reproduce every row, column, and header from the image, in the same order, with no cell omitted.
- Render all formulas, symbols, and variables with KaTeX as inline
$...$— e.g.$x^2$,$\frac{a}{b}$,$\Delta=b^2-4ac$. - Inside a cell, separate line breaks / multiple items with
<br>. Escape any literal pipe that is part of the cell content as\|.
Images Inside Cells (critical)
Detect, for each image-bearing cell, which of three cases applies and render accordingly.
Case A — Function graph / math curve → draw it inside the cell
Write a single inline <div>. Put each graph config key on its own line separated by <br> (no real line breaks / no code block — that would break the table):
<div>fn = x^2<br>xMin = -3<br>xMax = 3<br>yMin = -1<br>yMax = 9</div>
Rules:
- The whole <div>...</div> must be on one line of the source (use <br> only; never a real carriage return).
- Must include fn = <expression> and at least one of xMin / xMax / yMin / yMax, or the system will not render a graph.
- Write the expression in JavaScript math syntax: multiplication as * (e.g. 2*x), power as ^ (e.g. x^2), square root as sqrt(x).
- Multiple curves → multiple fn lines, e.g. fn = x^2<br>fn = 2*x<br>xMin = ....
- Optional title = 图名 (e.g. title = 抛物线).
- Never use a ```graph code block inside a cell — it does not fit in a table cell and fails.
Case B — Real image / geometry diagram / photo that cannot be reproduced by a function
Use an inline image placeholder; do not invent a URL or base64:
<img src="待替换" alt="直角三角形 ∠C=90°">
- Always set
src="待替换". - Put a clear description of the figure in
altso the user can manually replace it later.
Case C — Simple figure expressible in text/symbols
Express it directly with $...$ or plain text inside the cell. No placeholder needed.
Output Requirements
- Output only the Markdown text itself — no extra explanation, so it can be copied directly.
- If the image has a title above the table, put it on its own bold line before the table:
**标题**. - Where the image is unclear, mark it
[存疑]and give the best guess.
Full Output Example
**常见函数图像对比**
| 函数 | 图像 | 单调性 |
| --- | --- | --- |
| $y=x^2$ | <div>fn = x^2<br>xMin = -3<br>xMax = 3<br>yMin = -1<br>yMax = 9<br>title = y=x²</div> | 先减后增 |
| $y=x^3$ | <div>fn = x^3<br>xMin = -3<br>xMax = 3<br>yMin = -9<br>yMax = 9<br>title = y=x³</div> | 单调递增 |
| 直角三角形 | <img src="待替换" alt="直角三角形 ∠C=90°"> | / |
```