Skip to content

tailwind/mdbook-bookimport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mdbook-bookimport

Build status

Import code/text from other files into your mdbook - without the link rot.

Background / Initial Motivation

mdbook-bookimport started as an issue in mdbook #879.

At this time the default #include preprocessor in mdbook only supports importing smaller sections of a file by specifying line numbers - so if you're including pieces of files that are actively maintained/changed you end up forgetting to update the line numbers of your imports as your files change.

mdbook-bookimport allows you to import pieces of files based on text in the file - so that are you modify the file you continue to import the code that you expected to.

Quickstart

cargo install mdbook-bookimport
# In your book.toml
[preprocessor.bookimport]
<!-- Your markdown file before processing -->

{{#bookimport ../path/to/file.foo@some-tag-name-here}}
// Some file named "file.foo"
fn main () {
  let not_imported = "This will NOT be imported!";

  // @book start some-tag-name-here

  // ...
  let imported = "This will be imported!"
  let also_imported = "Everyting between start/end gets imported."
  // ...

  // @book end some-tag-name-here
}
<!-- Your markdown file after processing -->


  // ...
  let imported = "This will be imported!"
  let also_imported = "Everyting between start/end gets imported."
  // ...

The mdbook-bookimport guide

API

Troubleshooting

If for some reason something ever went wrong for any reason..:

RUST_LOG=debug mdbook build would give more information.

To Test

./test.sh

See Also

License

Apache 2.0 / MIT

About

Import code/text from other files into your mdbook - without the link rot.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages