离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser
CSV 转 Markdown 表格——离线、可批量、不上传CSV to Markdown table offline, in batches, no upload
写文档时最常见的一步,是把一份 CSV 贴成能读的表格。用「按逗号切一行」的脚本做这件事,会在第一个带引号的逗号上翻车;把换行塞进格子更是直接破坏表结构。这条路由先把 CSV 交给 SheetJS 的解析器读成一张 HTML 表格,再由 Markdown 的表格规则写成管道表:首行给出表头分隔线,格子里的竖线写成 `\|`,列数按最宽的一行补齐。值仍按文件里的字符呈现——不做类型推断,所以 `00123` 不会变成 `123`。Pasting a CSV into a document is one of the most common conversions there is, and the quick script that splits each line on commas fails at the first quoted comma — a newline inside a field breaks the table outright. This route first reads the CSV with SheetJS’s parser into an HTML table, then writes it as a pipe table: the first row supplies the header rule, a pipe in a cell is emitted as `\|`, and rows are padded to the widest one. Values stay the file’s own characters, so `00123` does not become `123`.
这条链路怎么走How the route runs
CSVCSV HTMLHTML MarkdownMarkdown
共 2 步,由扩展的路径搜索自动选出,中间产物不落盘。2 steps, chosen by the extension's own path search; intermediate results never touch the disk.
会保留什么What carries over
- 带引号的逗号、字段内的换行、成对的引号转义,都按 CSV 的语法解析成一个单元格,而不是按逗号切字符串Quoted commas, newlines inside a field and doubled quote escapes all parse into one cell under CSV’s grammar, rather than a string split on commas
- 管道表的结构完整:首行紧跟一行 `---` 分隔线,其余每行一条记录,列数按最宽的一行补齐,短行不会把整张表挤歪The pipe table keeps its shape: the first row is followed by a `---` rule, every other row is a record, and rows are padded to the widest one so a short row cannot skew the table
- 单元格里的竖线写成 `\|`、反斜杠成对写,所以内容本身不会把表撑破A pipe in a cell is written as `\|` and a backslash is doubled, so the content itself cannot break the table apart
- 编码不是前提:先按 BOM 与 NUL 分布嗅探 UTF-16,再依次尝试 UTF-8 → GB18030 → GBK,老编辑器导出的 GBK 文件也读得进来The encoding is not a precondition: UTF-16 is sniffed first from the BOM and the NUL pattern, then UTF-8 → GB18030 → GBK are tried, so a GBK file from an older editor still reads
如实说明的限制What it does not do
- 结果就是一张表:CSV 没有标题层级,也没有段落,所以 Markdown 里不会多出说明文字——想要前后有正文,先在 Markdown 里自己写The result is one table and nothing else: a CSV has no heading hierarchy and no prose, so no explanatory text appears around it — write that in the Markdown yourself
- 单元格里的换行与连续空白折成一个空格:管道表不能跨行,文字还在,版式没了Newlines and runs of whitespace inside a cell collapse to one space: a pipe table cannot span lines, so the words survive and the layout does not
- 格子里的行内格式不保留:那一格取的是纯文字,所以加粗与链接地址消失、链接只剩锚文本;图片没有文字可取,那一格就成了空的Inline formatting inside a cell is not carried over: the cell contributes plain text, so bold and link addresses disappear and a link keeps only its anchor text, while an image has no text to give — that cell comes out empty
- 数值不会被「翻译」:`00123` 还是 `00123`,`1-5` 还是 `1-5`——好处是不被改错,代价是它不替你做类型化Nothing is “translated”: `00123` stays `00123` and `1-5` stays `1-5` — the benefit is not being misread, the cost is no typing
- 一张表最多读 50 万格、整个工作簿最多 100 万格,超过直接报错;四种编码都读不出文本时也报错,不会给你一份乱码文档At most 500,000 cells per sheet and 1,000,000 per workbook are read, and past that it fails; if none of the four encodings yields text it fails too, rather than shipping mojibake
实操提示Working with it
- 一批最多 200 个文件,单个文件上限 100 MB;多个 .csv 一起转逐个产出各自的 .md,想一次拿走就打成一个 ZIPUp to 200 files per batch and 100 MB per file; several .csv files yield one .md each, and the set can be taken as a single ZIP
- 转好的表格还能回转:Markdown 转 CSV、转 JSON、转 Excel 走的都是同一条链,其中经 JSON 的那几步会把首行当列名用掉The table goes back the other way: Markdown to CSV, to JSON and to Excel all sit in the same chain, and the steps that pass through JSON spend the first row on column names
- 格子里必须有换行或行内格式的话,走 CSV 转 HTML 或转 Word——管道表表达不了这些,那两条不需要先把它压平If a cell must keep a line break or inline formatting, take CSV to HTML or to Word — a pipe table cannot express those, and neither route has to flatten the cell first
常见问题Questions people actually ask
格子里有竖线,会把表格撑破吗?A pipe inside a cell — will it break the table?
不会。写管道表时每个格子都做转义:竖线写成 `\|`,反斜杠成对写。读回来还是原来那个值。No. Every cell is escaped on the way out: a pipe becomes `\|` and a backslash is doubled. Read back, it is the same value you started with.
第一行数据会变成表头还是照常保留?Does the first row become the header, or is it kept as data?
照常保留。它同时充当管道表的表头行(下面紧跟 `---` 分隔线),但不会被「消耗」掉——不像 CSV 转 JSON 那样用首行当键名。It is kept. It doubles as the pipe table’s header row, with the `---` rule beneath it, but it is not spent the way CSV to JSON spends row one on key names.
单元格里换行了,结果会怎样?What happens to a cell that wrapped onto several lines?
折成一个空格。管道表一行就是一行,跨行需要别的格式;文字一个不少,但你原来在格子里排的版式没了。要留版式就走 CSV 转 HTML。It collapses to a single space. One pipe-table row is one line, and spanning lines needs a different format — every word is still there, only the layout you built inside the cell is gone.
报表数据会离开这台电脑吗?Does the report data ever leave this machine?
不会。解析 CSV、建表格、写 Markdown 全在扩展自己的标签页里完成,只申请 storage 权限、没有 host 权限,产物里也没有把远端资源当代码执行的路径。No. Parsing the CSV, building the table and writing the Markdown all happen inside the extension’s own tab: the storage permission only, no host permissions, and no path in the bundle that executes remotely hosted code.
不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.
从 Chrome 应用商店安装Install from the Chrome Web Store 安装步骤Install steps GitHub 源码Source on GitHub