rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.84k stars 1.62k forks source link

Add predefined reference files for compilation #2422

Open victor-vb opened 1 month ago

victor-vb commented 1 month ago

Problem

Hello, I have some scenarios here. Currently, mdbook has certain functions that are great. For example: {{#include file}}, but I want to use this function to reference some definition links of other files to facilitate the management of some special definition content without having to define a link in a single file each time. Here is a scenario I use

The following is my src directory structure

.
├── SUMMARY.md
├── chapter_1.md
├── customize
│   └── something.md
└── definds.md

2 directories, 4 files

Now let's focus on the definds.md file first, which defines some links

[something]:./customize/something.md

The something link points to the contents of a customize/something.md file

In the chapter_1.md file, I used the unique include command provided by the mdbook program to include definds.md, and used the content defined in definds.md to act on something

{{#include definds.md}}
# Chapter 1

related to [something][something]

ok, in this case, it will be convenient for me to manage this kind of external definition file in a unified way without adding it to the SUMMARY.md index.

Let's try to run mdbook serve, when I open the website, and navigate to chapter_1, when I bring you something, something bad happens, the link is broken, it tells me that the content link cannot be found

In the book/customize under the compilation directory, I found that the external link defined in definds.md was not recognized and compiled it. Moreover, I found that the link in chapter_1.md was also incorrect.

Proposed Solution

Same feature request

1802,#2408,#702 ,#830

We hope to support this kind of external link link detection and compile it into an html file in parallel, so that it does not have to be defined in the SUMMARY.md file.

Notes

No response