diff options
| -rw-r--r-- | src/bin/r2md-fence.rs | 1 | ||||
| -rw-r--r-- | src/fence_wrapper.rs | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/r2md-fence.rs b/src/bin/r2md-fence.rs index bfaf8d5..cced391 100644 --- a/src/bin/r2md-fence.rs +++ b/src/bin/r2md-fence.rs @@ -3,6 +3,7 @@ use std::io; use clap::Parser; use repo2markdown::fence_wrapper::wrap_in_fence; +/// Wrap stdin in a Markdown fenced code block. #[derive(Debug, Parser)] #[command(version, about, long_about = None)] struct Cli { diff --git a/src/fence_wrapper.rs b/src/fence_wrapper.rs index fc8f1c2..565f848 100644 --- a/src/fence_wrapper.rs +++ b/src/fence_wrapper.rs @@ -1,7 +1,18 @@ +//! Utilities for wrapping arbitrary input in a Markdown fenced code block. + use std::io::{Read, Write}; use crate::util::fence::generate_outer_backticks; +/// Reads all input, wraps it in a Markdown fenced code block, and writes it to output. +/// +/// The opening fence includes the supplied language tag. If `lang` is empty, the fence is emitted +/// without a language identifier. +/// +/// The fence length is chosen so that any backtick runs inside the input do not accidentally close +/// the outer fence. +/// +/// This function intentionally writes a blank line before the closing fence. pub fn wrap_in_fence<R: Read, W: Write>( mut input: R, mut output: W, |
