Skip to content

Add csvmark component for CSV ↔ Markdown table conversion#16

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-csv-to-markdown-conversion
Draft

Add csvmark component for CSV ↔ Markdown table conversion#16
Copilot wants to merge 2 commits into
mainfrom
copilot/add-csv-to-markdown-conversion

Conversation

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor

New Wasm component that converts between CSV documents and GitHub-flavored Markdown tables, with correct escaping for embedded commas, quotes, pipes, newlines, and UTF-8.

WIT

package yoshuawuyts:csvmark;

world csvmark {
    export csv-to-md: func(input: string) -> result<string, string>;
    export md-to-csv: func(input: string) -> result<string, string>;
}

Implementation (components/csvmark/src/lib.rs)

  • csv crate parses input; first record becomes the markdown header, ragged rows are padded to the widest row.
  • pulldown-cmark (with ENABLE_TABLES) walks events to extract the first table; Soft/HardBreak inside cells collapse to spaces.
  • Cell escaping mirrors tablemark: |\|, line breaks → space; md-to-csv reverses the pipe escape and lets csv::Writer handle CSV-side quoting.

Tests

11 unit tests in lib.rs covering simple conversion, embedded commas + escaped quotes, pipe/newline escaping, UTF-8 (Cyrillic), empty input, ragged-row padding, CSV quoting of special fields, pipe unescaping, and a CSV → MD → CSV round trip.

Wiring

  • justfile: added cargo build -p csvmark to build; csvmark added to publish and versions recipes.
  • .github/workflows/publish.yml: csvmark added to the target choice list, included in the publish-component job guard, and given a description.
  • README.md: row added to the components table.

Notes

  • Crate layout, edition = "2018", and empty tests/test.rs intentionally mirror tablemark/wordmark for consistency.
  • crate-type is ["cdylib", "rlib"] (vs. tablemark's cdylib-only) so unit tests can link against the lib on the host target; the wasm artifact is unaffected.

Copilot AI changed the title [WIP] Add csv to markdown table conversion functionality Add csvmark component for CSV ↔ Markdown table conversion May 1, 2026
Copilot AI requested a review from yoshuawuyts May 1, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[component] csvmark — CSV/TSV ↔ Markdown tables

2 participants