Skip to content

Conversation

jp-knj
Copy link

@jp-knj jp-knj commented Aug 6, 2025

Closes: #171

Overview

This PR implements table serialization support for the mdast_util_to_markdown crate, bringing it to feature parity with the JavaScript https://github.com/syntax-tree/mdast-util-gfm-table package. Previously, attempting to serialize ASTs containing GFM table nodes would result in an "unexpected-node" error.

Testing

Added comprehensive test coverage in tests/table.rs

  • Basic table structures
  • Column alignment variations
  • Unicode content handling
  • Pipe escaping scenarios
  • Empty cells and edge cases
  • Complex inline elements
  • Error conditions

Run tests with:

# Build with the feature
cargo build --features unicode-width

# Run tests with the feature
cargo test --features unicode-width

Uses conditional compilation to:

  • Default: Character count (.chars().count()), no dependency needed
  • With feature: Unicode display width, proper CJK/emoji alignment

@wooorm
Copy link
Owner

wooorm commented Aug 6, 2025

unicodewith seems like a step way from the upstream. And, a dependency.
Why not make it optional, configurable?

@jp-knj
Copy link
Author

jp-knj commented Aug 7, 2025

You're right, I'll do that

@jp-knj jp-knj marked this pull request as ready for review August 7, 2025 23:27
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.

Add support for non-CommonMark extensions in mdast_util_to_markdown
2 participants