summaryrefslogtreecommitdiff
path: root/src/util/fence.rs
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-06-20 13:11:29 +0300
committerA Farzat <a@farzat.xyz>2026-06-20 13:11:29 +0300
commit7ae5e1146684e6daeaf6522cb83a47bbcfefe87e (patch)
tree667144c2451c5595ba8e3ab6af4b6b7e2a768843 /src/util/fence.rs
parent8412c6d66eb243d5772f6ac7586e3f265c380f1e (diff)
downloadrepo2markdown-7ae5e1146684e6daeaf6522cb83a47bbcfefe87e.tar.gz
repo2markdown-7ae5e1146684e6daeaf6522cb83a47bbcfefe87e.zip
Add module/function docs to fence utils
Diffstat (limited to 'src/util/fence.rs')
-rw-r--r--src/util/fence.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/util/fence.rs b/src/util/fence.rs
index 16f398a..8856336 100644
--- a/src/util/fence.rs
+++ b/src/util/fence.rs
@@ -1,8 +1,13 @@
+//! Markdown fence helpers.
+
+/// Returns a backtick fence long enough to wrap `contents` safely.
+///
+/// The returned fence is at least three backticks long. If `contents` contains a run of `n`
+/// consecutive backticks where `n >= 3`, the returned fence has length `n + 1`.
pub fn generate_outer_backticks(contents: impl AsRef<[u8]>) -> String {
- let bytes = contents.as_ref();
let mut max_ticks = 0;
let mut current_count = 0;
- for &byte in bytes {
+ for &byte in contents.as_ref() {
if byte == b'`' {
current_count += 1;
if current_count > max_ticks {