Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ fn main() -> std::io::Result<()> {
wrap: true,
ellipsis: true,
fences: true,
footnotes: false,
};
let fixed = process_stream_opts(&lines, opts);
println!("{}", fixed.join("\n"));
Expand All @@ -133,7 +134,7 @@ fn main() -> std::io::Result<()> {

- `process_stream_opts(lines: &[String], opts: Options) -> Vec<String>`
rewrites tables in memory. The options enable paragraph wrapping, ellipsis
substitution and fence normalization.
substitution, fence normalization and footnote conversion.

- `rewrite(path: &Path) -> std::io::Result<()>` modifies a Markdown file on
disk in-place.
Expand Down
10 changes: 9 additions & 1 deletion src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ use crate::{
};

/// Processing options controlling the behaviour of `process_stream_inner`.
#[expect(
clippy::struct_excessive_bools,
reason = "Options map directly to CLI flags"
)]
#[derive(Clone, Copy)]
pub struct Options {
/// Enable paragraph wrapping
Expand All @@ -18,6 +22,8 @@ pub struct Options {
pub ellipsis: bool,
/// Normalise code block fences
pub fences: bool,
/// Convert bare numeric references to footnotes
pub footnotes: bool,
}

#[must_use]
Expand Down Expand Up @@ -94,7 +100,7 @@ pub fn process_stream_inner(lines: &[String], opts: Options) -> Vec<String> {
if opts.ellipsis {
out = replace_ellipsis(&out);
}
if footnotes {
if opts.footnotes {
out = convert_footnotes(&out);
}
out
Expand All @@ -108,6 +114,7 @@ pub fn process_stream(lines: &[String]) -> Vec<String> {
wrap: true,
ellipsis: false,
fences: false,
footnotes: false,
},
)
}
Expand All @@ -120,6 +127,7 @@ pub fn process_stream_no_wrap(lines: &[String]) -> Vec<String> {
wrap: false,
ellipsis: false,
fences: false,
footnotes: false,
},
)
}
Expand Down