$ show donatj/CsvToMarkdownTable
This repository provides a robust, well-tested JavaScript/TypeScript library and CLI tool for converting CSV strings into Markdown table format. The core function `csvToMarkdown` accepts a CSV string, delimiter, header flag, and optional configuration (enclosure, escape, newline replacement, cell filter, pretty-print). It leverages the `csv-walker` library for CSV parsing and outputs a properly formatted Markdown table with aligned columns. The package is distributed in UMD, ESM, and CommonJS formats, making it usable in browsers, Node.js, and bundlers. The codebase demonstrates high craftsmanship: clean TypeScript with strict options, comprehensive test coverage (including CLI, type declarations, and edge cases), automated CI/CD with linting and formatting, and a well-structured build pipeline using Rollup. The CLI tool reads from stdin and supports various delimiters and header options. The repository is actively maintained with recent commits, up-to-date dependencies, and zero open issues.
The LLM identified 3 files worth highlighting for reuse:
The core library function that converts CSV strings to Markdown tables. It is self-contained, well-typed with TypeScript, and exposes a clean API with optional configuration for enclosure, escape, newline replacement, cell filtering, and pretty-printing. The implementation handles edge cases like quoted fields, escaped characters, and newlines within fields. It is reusable as a standalone module and demonstrates non-obvious skill in CSV parsing and Markdown formatting.
A CLI entry point that reads CSV from stdin and outputs a Markdown table. It handles argument parsing for delimiter (with special named delimiters like :tab, :comma, :semicolon), headers flag, and help. The script is cleanly separated from the core library, making it easy to maintain and test. It demonstrates a good pattern for building CLI tools around a library.
A comprehensive test suite covering the core library function with over 30 test cases, including edge cases like empty input, quoted fields, newlines, special characters, custom options, and type validation. It also tests the CommonJS build and CLI tool. The tests are well-organized, use parameterized tests, and demonstrate thorough coverage of the library's functionality. This test file is a model for testing a string transformation library.