Don't process includes within code blocks

Fixes #57
This commit is contained in:
Kayce Basques
2025-12-07 09:32:09 -08:00
parent 3a4ccca5bb
commit af34e0f293
+22
View File
@@ -198,6 +198,28 @@ def test_process_includes(tmp_path):
assert processed_content == expected_content
def test_process_includes_in_code_block(tmp_path):
"""Test that an include directive within a code block is not processed."""
# Create a processor
config = {"llms_txt_directives": []}
processor = DocumentProcessor(config)
# Create a source file that includes the test file
source_content = (
".. code-block:: rst\n\n .. include:: foo.txt"
)
source_file = tmp_path / "source.txt"
with open(source_file, "w", encoding="utf-8") as f:
f.write(source_content)
# Process the include directive
processed_content = processor._process_includes(source_content, source_file)
# Check that the include directive was replaced with the content
expected_content = source_content
assert processed_content == expected_content
def test_process_includes_with_relative_paths(tmp_path):
"""Test that include directives with relative paths are processed correctly."""
# Create a processor