Skip to content

Easily include a file setting the syntax highlighting and also showing the name of the file #2663

@szabgab

Description

@szabgab

Problem

Right now if I would like to include a source file I need to use something like this: {{#include file.rs}} I also need to wrap it with

```rust
```

I would also like to add the name of the file above the included file
And maybe even make it a link to the file in my github repository.

Proposed Solution

It would be nice to be able to write something like:

{% include file.rs %}

That would be expanded to something like this:

    ```rust
    [**examples/intro/hello/src/main.rs**](https://github.com/szabgab/rust.code-maven.com/blob/main/slides/rust/examples/intro/hello/src/main.rs)
    {{#include examples/intro/hello/src/main.rs }}
    ```

The programming language would be deducted from the file-extension.

It would be nice if mdbook had all kinds of extension like this using the liquid-like format, but for quicker solution it might be a preprocessors. Maybe it could be added to embedify.
What do you think @MR-Addict ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement or feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions