Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow String Utils

From Leeroopedia
Knowledge Sources
Domains Text_Processing, Utilities
Last Updated 2026-02-12 06:00 GMT

Overview

Concrete tool for string cleaning including redundant whitespace removal and Markdown code block stripping provided by the RAGFlow common library.

Description

The string_utils module provides remove_redundant_spaces which removes excess whitespace around punctuation marks using regex patterns, and clean_markdown_block which strips Markdown code fence syntax (```markdown...```) from text while preserving the inner content.

Usage

Import these utilities when post-processing LLM-generated text or user input that may contain irregular spacing or unwanted Markdown formatting.

Code Reference

Source Location

Signature

def remove_redundant_spaces(txt: str) -> str:
    """Remove spaces around punctuation marks using regex."""

def clean_markdown_block(text: str) -> str:
    """Remove Markdown code block syntax, preserving inner content."""

Import

from common.string_utils import remove_redundant_spaces, clean_markdown_block

I/O Contract

Inputs

Name Type Required Description
txt str Yes Text with redundant spaces
text str Yes Text possibly containing Markdown blocks

Outputs

Name Type Description
remove_redundant_spaces() returns str Cleaned text with normalized spacing
clean_markdown_block() returns str Text with code fences removed

Usage Examples

from common.string_utils import remove_redundant_spaces, clean_markdown_block

cleaned = remove_redundant_spaces("Hello ,  world !")  # "Hello, world!"
plain = clean_markdown_block("```markdown\nSome content\n```")  # "Some content"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment