Skip to content

Snippet trimleft option does not handle newlines well #11330

@Lucan11

Description

@Lucan11

Describe the bug
The trimleft option for the \snippet command does not work well with newlines and stripped spaces. Specifically, it requires that the newlines have the same indentation (e.g. 4 spaces) as the rest of the code. However, newlines typically have a indentation of 0 due to the fact that all trailing spaces are stripped by auto-formatters.

Screenshots
See the output of the attached project:
{3B902DB2-0FFD-4EAD-9963-7740E3C418E1}

To Reproduce
See the attached project:
doxygen_snippet_trimleft_example.zip

Tested with Doxygen 1.13.0 downloaded from the website. The config used is generated with doxygen.exe -g and adjusted the following two settings:
EXAMPLE_PATH = .
EXAMPLE_RECURSIVE = YES

Expected behavior
I expect the trimleft option to ignore newlines (lines with only whitespaces and line termination characters), such that code snippets with newlines are trimmed correctly.

Version
Tested with Doxygen 1.13.0 downloaded from the website on Windows 11 64 bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions