Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including other files between some start and end string #879

Closed
chinedufn opened this issue Feb 23, 2019 · 4 comments
Closed

Including other files between some start and end string #879

chinedufn opened this issue Feb 23, 2019 · 4 comments

Comments

@chinedufn
Copy link

chinedufn commented Feb 23, 2019

Right now you can include the contents of a file in between two line numbers.


This has been useful - but can lead to some rot if you modify a file and forget to update your mdbook.


That rot has led me to sometimes split some code into another file - not because I wanted to or thought that it made sense - but because I wanted to be able to include it into an mdbook without forgetting to update the include statement.


I'm thinking that it would be useful to be able to include between some start and end sequence

Here's a rough sketch:

fn main () {
  // Include this in the book
 let hello = "68656c6c6f";
 let world = "776f726c64";
 // Ok, all done!
}
{{ #include /path/to/file.rs:"Include this in":"Ok, all done!" }}

Could certainly be done in a third-party plugin - but I'm thinking that something like this might be useful enough to include in core...?

Rough ideas above so.. any thoughts are appreciated!

@chinedufn
Copy link
Author

Another thing that would be useful is being able to start from some string and then end at some offset number of lines.

{{ #include /path/to/file.rs:"Include this in":+10 }}

So this would start at the first line that contained "Include this in" and end at that line number +10 (or end of file if there aren't 10 more lines)

@chinedufn
Copy link
Author

chinedufn commented Mar 27, 2019

Made a preprocessor for this mdbook-bookimport https://github.com/tailwind/mdbook-bookimport

@CBenoit
Copy link
Contributor

CBenoit commented Apr 4, 2019

An issue and a pull request are already open: #851 and #811
But your mdbook-bookimport is a great replacement while we wait for a new maintainer! 👍

@chinedufn
Copy link
Author

Ohhhh awesome thanks for the links!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants