diff --git a/tests/test_llms_txt.py b/tests/test_llms_txt.py index 412da2c..51e1b25 100644 --- a/tests/test_llms_txt.py +++ b/tests/test_llms_txt.py @@ -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