in2lambda.filters.markdown.image_directoriesΒΆ

in2lambda.filters.markdown.image_directories(tex_file: str) list[str][source]ΒΆ

Determines the image directories referenced by graphicspath in a given TeX document.

Parameters:

tex_file – The absolute path to a TeX file

Returns:

The exact contents of graphicspath, regardless of whether the directories are absolute or relative.

Examples

>>> from in2lambda.filters.markdown import image_directories
>>> import tempfile
>>> import os
>>> # Example TeX file with a graphicspath
>>> temp_dir = tempfile.mkdtemp()
>>> tex_file = os.path.join(temp_dir, 'test.tex')
>>> with open(tex_file, 'w') as f:
...     f.write("\\graphicspath{{subdir1/}{subdir2/}{subdir3/}}")
45
>>> image_directories(tex_file)
['subdir1/', 'subdir2/', 'subdir3/']
>>> with open(tex_file, 'w') as f:
...    f.write("\\graphicspath{ { subdir1/ }, { subdir2/ }, { subdir3/ } }")
57
>>> image_directories.cache_clear()
>>> image_directories(tex_file)
['subdir1/', 'subdir2/', 'subdir3/']
>>> with open(tex_file, 'w') as f:
...    f.write("No image directory")
18
>>> image_directories.cache_clear()
>>> image_directories(tex_file)
[]