feat: Add Markdown plain text projection - #12
Merged
Conversation
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.
Summary
This PR ports the TypeScript FFM Markdown parser to Rust and provides a search-oriented plain-text projection from the parsed AST. The projection is independent from Tantivy: the parser exposes text, while the search backend owns schema, tokenizer, field boosting, storage, and snippets.
to_plain_text()The Rust crate now exports:
The implementation performs one direct AST traversal. It keeps visible text, heading/paragraph/list/table/blockquote content, inline and fenced code, link labels, hard breaks, and FFM item titles/bodies. It omits Markdown presentation markers, link destinations, CSS class/style metadata, and structural thematic-break markers.
HTML and CSS are deliberately not parsed or sanitized by this API. When the parser represents them as text, they remain ordinary text and are returned unchanged. A canonical regression case covers a CSS
<style>element. The function does not render HTML, strip tags, or depend on Tantivy.Shared fixtures
fixtures/markdown.jsonandfixtures/ffm.jsonnow includeplain_textexpectations for the standard Markdown and FFM cases. The shared cases cover headings, inline/fenced code, links, raw HTML/CSS text, tables, lists, hard breaks, FFM quote/accordion/chain/slide nodes, Unicode domains, and nesting behavior. TypeScript exposes a matchingtoPlainTextreference implementation, and both language runners consume the same expected values.Validation
pnpm --filter @fuyeor/markdown-parser typecheck— passedpnpm --filter @fuyeor/markdown-parser test— 38 passedpnpm --filter @fuyeor/linkify test— 20 passedcargo fmt --all -- --check— passedcargo check --workspace --all-targets --all-features— passedcargo clippy --workspace --all-targets --all-features -- -D warnings— passedcargo test --workspace --all-targets --all-features— 2 thin runners passedThe existing CommonMark/GFM compatibility harness remains separate because it has its own filtered corpus and skip rules. The canonical cross-language suite is the source of truth for Rust/TypeScript plain-text parity.