pub struct CodeBlockUtils;Expand description
Utility functions for detecting and handling code blocks in Markdown
Implementations§
Source§impl CodeBlockUtils
impl CodeBlockUtils
Sourcepub fn detect_code_blocks(content: &str) -> Vec<(usize, usize)>
pub fn detect_code_blocks(content: &str) -> Vec<(usize, usize)>
Detect all code blocks in the content (NOT including inline code spans)
Uses pulldown-cmark for spec-compliant CommonMark parsing. This correctly handles:
- Fenced code blocks (``` and ~~~)
- Indented code blocks (4 spaces or tab)
- Code blocks inside lists, blockquotes, and other containers
- Edge cases like backticks in info strings (which invalidate the fence)
Returns a sorted vector of (start, end) byte offset tuples.
Sourcepub fn is_in_code_block_or_span(blocks: &[(usize, usize)], pos: usize) -> bool
pub fn is_in_code_block_or_span(blocks: &[(usize, usize)], pos: usize) -> bool
Check if a position is within a code block (for compatibility)
Sourcepub fn is_in_code_block(blocks: &[(usize, usize)], pos: usize) -> bool
pub fn is_in_code_block(blocks: &[(usize, usize)], pos: usize) -> bool
Check if a position is within a code block (NOT including inline code spans)
Sourcepub fn analyze_code_block_context(
lines: &[LineInfo],
line_idx: usize,
min_continuation_indent: usize,
) -> CodeBlockContext
pub fn analyze_code_block_context( lines: &[LineInfo], line_idx: usize, min_continuation_indent: usize, ) -> CodeBlockContext
Analyze code block context relative to list parsing This is the core function implementing Design #3’s three-tier classification
Auto Trait Implementations§
impl Freeze for CodeBlockUtils
impl RefUnwindSafe for CodeBlockUtils
impl Send for CodeBlockUtils
impl Sync for CodeBlockUtils
impl Unpin for CodeBlockUtils
impl UnwindSafe for CodeBlockUtils
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more