Skip to content

leading whitespace when including file snippets #1430

Open
@jadamcrain

Description

@jadamcrain

We would like to construct our documentation for multi-language libraries Rust -> C FFI -> Java, C#, etc using
mdbook. One issue that is kind of a deal-breaker for us is that when including snippets from source files, leading white-space is preserved:

    runtime_config_t runtime_config =
    {
        .num_core_threads = 4,
    };
    runtime_t* runtime = runtime_new(&runtime_config);

Ideally, leading white-space could normalized such that the level of indentation is dropped such that the line in the snippet containing the least white-space now contains no white-space:

runtime_config_t runtime_config =
{
    .num_core_threads = 4,
};
runtime_t* runtime = runtime_new(&runtime_config);

I would think that only pretty trivial examples have code snippets with no leading white-space and that if we do a PR it would be valuable to others.

Looking at the codebase, it seems we would be working in links preprocessor, correct?

Questions:

  1. If we do a PR, will it be considered?
  2. If so, should the behavior be configurable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-link-preprocessorArea: Link preprocessor, #{{include}}, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions