Add csvmark component for CSV ↔ Markdown table conversion#16
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/yoshuawuyts/components/sessions/527ba64a-58da-4b68-8960-9f9260c5894d Co-authored-by: yoshuawuyts <2467194+yoshuawuyts@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add csv to markdown table conversion functionality
Add csvmark component for CSV ↔ Markdown table conversion
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Implementation (
components/csvmark/src/lib.rs)csvcrate parses input; first record becomes the markdown header, ragged rows are padded to the widest row.pulldown-cmark(withENABLE_TABLES) walks events to extract the first table;Soft/HardBreakinside cells collapse to spaces.tablemark:|→\|, line breaks → space;md-to-csvreverses the pipe escape and letscsv::Writerhandle CSV-side quoting.Tests
11 unit tests in
lib.rscovering 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: addedcargo build -p csvmarktobuild;csvmarkadded topublishandversionsrecipes..github/workflows/publish.yml:csvmarkadded to thetargetchoice list, included in thepublish-componentjob guard, and given a description.README.md: row added to the components table.Notes
edition = "2018", and emptytests/test.rsintentionally mirrortablemark/wordmarkfor consistency.crate-typeis["cdylib", "rlib"](vs.tablemark'scdylib-only) so unit tests can link against the lib on the host target; the wasm artifact is unaffected.