summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 {