From f59e0b17f63232ab594862300e217b150e39817b Mon Sep 17 00:00:00 2001 From: Leynos Date: Sat, 2 Aug 2025 00:13:06 +0100 Subject: [PATCH 1/3] Simplify strong detection and group tokenize exports --- src/wrap.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wrap.rs b/src/wrap.rs index 430e4be9..0efd05a3 100644 --- a/src/wrap.rs +++ b/src/wrap.rs @@ -15,10 +15,8 @@ mod tokenize; /// /// Re-export this so callers of [`crate::textproc`] can implement custom /// transformations without depending on internal modules. -pub use tokenize::Token; -/// Convenience re-export of [`tokenize::tokenize_markdown`]. #[doc(inline)] -pub use tokenize::tokenize_markdown; +pub use tokenize::{Token, tokenize_markdown}; static FENCE_RE: std::sync::LazyLock = std::sync::LazyLock::new(|| Regex::new(r"^\s*(```|~~~).*").unwrap()); From b26acaf131fce525368adc148dc4bf324ff9ee8e Mon Sep 17 00:00:00 2001 From: Leynos Date: Sat, 2 Aug 2025 00:45:00 +0100 Subject: [PATCH 2/3] Remove redundant token comment --- src/html.rs | 4 +++- src/io.rs | 4 +++- src/wrap.rs | 8 +++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/html.rs b/src/html.rs index c3372881..254fd724 100644 --- a/src/html.rs +++ b/src/html.rs @@ -84,7 +84,9 @@ fn is_element(handle: &Handle, tag: &str) -> bool { } /// Returns `true` if `handle` represents a `` or `` element. -fn is_table_cell(handle: &Handle) -> bool { is_element(handle, "td") || is_element(handle, "th") } +fn is_table_cell(handle: &Handle) -> bool { + is_element(handle, "td") || is_element(handle, "th") +} /// Walks the DOM tree collecting `` nodes under `handle`. fn collect_tables(handle: &Handle, tables: &mut Vec) { diff --git a/src/io.rs b/src/io.rs index cb30bea4..e9bd9c17 100644 --- a/src/io.rs +++ b/src/io.rs @@ -30,7 +30,9 @@ where /// /// # Errors /// Returns an error if reading or writing the file fails. -pub fn rewrite(path: &Path) -> std::io::Result<()> { rewrite_with(path, process_stream) } +pub fn rewrite(path: &Path) -> std::io::Result<()> { + rewrite_with(path, process_stream) +} /// Rewrite a file in place without wrapping text. /// diff --git a/src/wrap.rs b/src/wrap.rs index 0efd05a3..b3dc9798 100644 --- a/src/wrap.rs +++ b/src/wrap.rs @@ -11,10 +11,6 @@ use regex::Regex; mod tokenize; -/// Token emitted by [`tokenize::segment_inline`] and used by higher-level wrappers. -/// -/// Re-export this so callers of [`crate::textproc`] can implement custom -/// transformations without depending on internal modules. #[doc(inline)] pub use tokenize::{Token, tokenize_markdown}; @@ -161,7 +157,9 @@ fn wrap_preserving_code(text: &str, width: usize) -> Vec { } #[doc(hidden)] -pub fn is_fence(line: &str) -> bool { FENCE_RE.is_match(line) } +pub fn is_fence(line: &str) -> bool { + FENCE_RE.is_match(line) +} pub(crate) fn is_markdownlint_directive(line: &str) -> bool { MARKDOWNLINT_DIRECTIVE_RE.is_match(line) From cfdc8058a29a0099a917d1b16695edc6759d121d Mon Sep 17 00:00:00 2001 From: Payton McIntosh Date: Sat, 2 Aug 2025 00:52:58 +0100 Subject: [PATCH 3/3] Reformat per rust-fmt --- src/html.rs | 4 +--- src/io.rs | 4 +--- src/wrap.rs | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/html.rs b/src/html.rs index 254fd724..c3372881 100644 --- a/src/html.rs +++ b/src/html.rs @@ -84,9 +84,7 @@ fn is_element(handle: &Handle, tag: &str) -> bool { } /// Returns `true` if `handle` represents a `
` or `` element. -fn is_table_cell(handle: &Handle) -> bool { - is_element(handle, "td") || is_element(handle, "th") -} +fn is_table_cell(handle: &Handle) -> bool { is_element(handle, "td") || is_element(handle, "th") } /// Walks the DOM tree collecting `` nodes under `handle`. fn collect_tables(handle: &Handle, tables: &mut Vec) { diff --git a/src/io.rs b/src/io.rs index e9bd9c17..cb30bea4 100644 --- a/src/io.rs +++ b/src/io.rs @@ -30,9 +30,7 @@ where /// /// # Errors /// Returns an error if reading or writing the file fails. -pub fn rewrite(path: &Path) -> std::io::Result<()> { - rewrite_with(path, process_stream) -} +pub fn rewrite(path: &Path) -> std::io::Result<()> { rewrite_with(path, process_stream) } /// Rewrite a file in place without wrapping text. /// diff --git a/src/wrap.rs b/src/wrap.rs index b3dc9798..5037a5a7 100644 --- a/src/wrap.rs +++ b/src/wrap.rs @@ -157,9 +157,7 @@ fn wrap_preserving_code(text: &str, width: usize) -> Vec { } #[doc(hidden)] -pub fn is_fence(line: &str) -> bool { - FENCE_RE.is_match(line) -} +pub fn is_fence(line: &str) -> bool { FENCE_RE.is_match(line) } pub(crate) fn is_markdownlint_directive(line: &str) -> bool { MARKDOWNLINT_DIRECTIVE_RE.is_match(line)