Skip to content

Optionally show the name of the file above the included file #13

@szabgab

Description

@szabgab

When I use my book for a presentation sometimes I need to jump to the source of the embedded file. For this having the name of the file above each (or most) embedded files would be nice. As I have several books with more than 10,000 embedded files, adding such snippets would be a lot of work and writing an external program to do that just sounds wrong.

It would be nice if I could set a global flag in the book.toml file to instruct embedify to show the name of the file above each file included using {% embed include file="" %}

Even better would be if the field could be used to describe what to show above each file. (e.g. using fields such as the

[preprocessor.embedify]
include.display_filename = "[{file}](https://github.com/szabgab/python.code-maven.com/tree/main/books/python-async/{file})"

Where the {file} is replaced by the valued in the "file" attribute of the "embed include" entries.

It should default to not showing anything at all.


Extra request:

I include both code-files (e.g .rs or .py extensions), but in many cases I also have files where I saved the output of a command and I include those files as well. So I have

{% embed include file="src/examples/async/src/demo.rs" %}

{% embed include file="src/examples/async/demo.out" %}

In this case I'd like to show the filenames only for the .rs files and not the .out files.
So maybe there could be a way to select (based on extension?) to which files the include.display_filename even applies.

e.g.

include.display_filename_filter = ["*.rs", "*.py"]

It might default to all the files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions