Home / Function/ test_markdown_code_splitter() — langchain Function Reference

test_markdown_code_splitter() — langchain Function Reference

Architecture documentation for the test_markdown_code_splitter() function in test_text_splitters.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  9efa4e92_f831_cb03_dc20_321a0ee4825c["test_markdown_code_splitter()"]
  6d6b8ad4_1cfe_fbb0_e58e_76a50487c135["test_text_splitters.py"]
  9efa4e92_f831_cb03_dc20_321a0ee4825c -->|defined in| 6d6b8ad4_1cfe_fbb0_e58e_76a50487c135
  style 9efa4e92_f831_cb03_dc20_321a0ee4825c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/tests/unit_tests/test_text_splitters.py lines 1147–1209

def test_markdown_code_splitter() -> None:
    splitter = RecursiveCharacterTextSplitter.from_language(
        Language.MARKDOWN, chunk_size=CHUNK_SIZE, chunk_overlap=0
    )
    code = """
# Sample Document

## Section

This is the content of the section.

## Lists

- Item 1
- Item 2
- Item 3

### Horizontal lines

***********
____________
-------------------

#### Code blocks
```
This is a code block

# sample code
a = 1
b = 2
```
    """
    chunks = splitter.split_text(code)
    assert chunks == [
        "# Sample",
        "Document",
        "## Section",
        "This is the",
        "content of the",
        "section.",
        "## Lists",
        "- Item 1",
        "- Item 2",
        "- Item 3",
        "### Horizontal",
        "lines",
        "***********",
        "____________",
        "---------------",
        "----",
        "#### Code",
        "blocks",
        "```",
        "This is a code",
        "block",
        "# sample code",
        "a = 1\nb = 2",
        "```",
    ]
    # Special test for special characters
    code = "harry\n***\nbabylon is"
    chunks = splitter.split_text(code)
    assert chunks == ["harry", "***\nbabylon is"]

Domain

Subdomains

Frequently Asked Questions

What does test_markdown_code_splitter() do?
test_markdown_code_splitter() is a function in the langchain codebase, defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py.
Where is test_markdown_code_splitter() defined?
test_markdown_code_splitter() is defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py at line 1147.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free