-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor wrap prefixes and doc fix #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c0c79f
1fddf48
bfa0e22
28908d7
ce4519a
bcad468
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,7 @@ macro_rules! lines_vec { | |||||
| /// | ||||||
| /// Example: | ||||||
| /// ``` | ||||||
| /// let input: Vec<String> = include_lines!("data/bold_header_input.txt"); | ||||||
| /// let input: Vec<String> = include_lines!("data/bold_header_input.txt"); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Remove trailing whitespace from documentation example. The added trailing space serves no functional purpose and may trigger linting warnings. -/// let input: Vec<String> = include_lines!("data/bold_header_input.txt");
+/// let input: Vec<String> = include_lines!("data/bold_header_input.txt");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| /// ``` | ||||||
| #[expect(unused_macros, reason = "macros are optional helpers across modules")] | ||||||
| macro_rules! include_lines { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| use mdtablefix::wrap::wrap_text; | ||
|
|
||
| #[test] | ||
| fn wrap_text_preserves_hyphenated_words() { | ||
| let input = vec!["A word that is very-long-word indeed".to_string()]; | ||
| let wrapped = wrap_text(&input, 20); | ||
| assert_eq!( | ||
| wrapped, | ||
| vec![ | ||
| "A word that is".to_string(), | ||
| "very-long-word".to_string(), | ||
| "indeed".to_string(), | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn wrap_text_does_not_insert_spaces_in_hyphenated_words() { | ||
| let input = vec![ | ||
| concat!( | ||
| "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt ", | ||
| "elit-sed fermentum congue. Vivamus dictum nulla sed consectetur ", | ||
| "volutpat." | ||
| ) | ||
| .to_string(), | ||
| ]; | ||
| let wrapped = wrap_text(&input, 80); | ||
| assert_eq!( | ||
| wrapped, | ||
| vec![ | ||
| "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt".to_string(), | ||
| "elit-sed fermentum congue. Vivamus dictum nulla sed consectetur volutpat.".to_string(), | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn wrap_text_preserves_code_spans() { | ||
| let input = vec![ | ||
| "with their own escaping rules. On Windows, scripts default to `powershell -Command` \ | ||
| unless the manifest's `interpreter` field overrides the setting." | ||
| .to_string(), | ||
| ]; | ||
| let wrapped = wrap_text(&input, 60); | ||
| assert_eq!( | ||
| wrapped, | ||
| vec![ | ||
| "with their own escaping rules. On Windows, scripts default".to_string(), | ||
| "to `powershell -Command` unless the manifest's".to_string(), | ||
| "`interpreter` field overrides the setting.".to_string(), | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn wrap_text_multiple_code_spans() { | ||
| let input = vec!["combine `foo bar` and `baz qux` in one line".to_string()]; | ||
| let wrapped = wrap_text(&input, 25); | ||
| assert_eq!( | ||
| wrapped, | ||
| vec![ | ||
| "combine `foo bar` and".to_string(), | ||
| "`baz qux` in one line".to_string(), | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn wrap_text_nested_backticks() { | ||
| let input = vec!["Use `` `code` `` to quote backticks".to_string()]; | ||
| let wrapped = wrap_text(&input, 20); | ||
| assert_eq!( | ||
| wrapped, | ||
| vec![ | ||
| "Use `` `code` `` to".to_string(), | ||
| "quote backticks".to_string() | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn wrap_text_unmatched_backticks() { | ||
| let input = vec!["This has a `dangling code span.".to_string()]; | ||
| let wrapped = wrap_text(&input, 20); | ||
| assert_eq!( | ||
| wrapped, | ||
| vec!["This has a".to_string(), "`dangling code span.".to_string()] | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn wrap_text_preserves_links() { | ||
| let input = vec web framework. It adds a structured".to_string(), | ||
| "approach to asynchronous WebSocket routing and background worker integration.".to_string(), | ||
| ]; | ||
| let wrapped = wrap_text(&input, 80); | ||
| let joined = wrapped.join("\n"); | ||
| assert_eq!(joined.matches("https://").count(), 1); | ||
| assert!( | ||
| wrapped | ||
| .iter() | ||
| .any(|l| l.contains("https://falcon.readthedocs.io")) | ||
| ); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate fence detection code.
The file has duplicate fence detection logic. Remove the local
FENCE_REandis_fencefunction, and use the one from thetokenizemodule instead.Apply this diff:
Also applies to: 213-213
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai new GitHub issue, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@leynos I'll create a new GitHub issue for the duplicate fence detection code.
🏁 Script executed:
Length of output: 927
@leynos I've successfully created GitHub issue #177 for removing the duplicate fence detection code in
src/wrap.rs.Issue URL: #177
The issue has been assigned to you and includes:
🧬 Code Graph Analysis Results
Relevant snippets from
src/wrap/tokenize.rslines 71-120:scan_while,collect_range, andparse_link_or_image(not shown).[or![.Relevant snippet from
src/wrap/tokenize.rslines 158-192:Tokenenums.in_fencestate and emittingToken::Fence.tokenize_inlineto tokenize inline elements.Token::Newlinetokens between lines except after the last line.super::is_fenceto detect fenced code block delimiters.These two snippets are directly relevant because
src/wrap.rspublicly re-exportstokenize::Tokenandtokenize::tokenize_markdown, and internally usestokenize::segment_inlinein thewrap_preserving_codefunction to split text into tokens for wrapping while preserving inline code spans and links.No other snippets from the provided files appear directly relevant to understanding or addressing the contents of
src/wrap.rs.