| 28 | """ |
| 29 | |
| 30 | def _process_code_block(match): |
| 31 | # Extract the code block content |
| 32 | code_block_content = match.group(1).strip() |
| 33 | |
| 34 | # Remove lines starting with '#' |
| 35 | modified_code_block = "\n".join( |
| 36 | line |
| 37 | for line in code_block_content.splitlines() |
| 38 | if (not line.lstrip().startswith("# ")) and line.strip() != "#" |
| 39 | ) |
| 40 | |
| 41 | # Return the modified code block wrapped in triple backticks |
| 42 | return f"```rust\n{modified_code_block}\n```" |
| 43 | |
| 44 | # Replace all Rust code blocks using the _process_code_block function |
| 45 | return RUST_CODE_BLOCK_PATTERN.sub(_process_code_block, markdown_content) |