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

Add -m arg to watch/serve to only watch .md files #831

Closed
wants to merge 1 commit into from

Conversation

9999years
Copy link

Sometimes, a change to a garbage file (in my case, Vim swap files) in the source directory will cause a book rebuild, which is unnecessary, particularly in serve mode where it triggers a visually noisy page refresh.

This PR adds a -m / --markdown-only switch to the watch and serve subcommands, which causes the file-watcher to ignore changes in files that don't end in .md.

Sometimes, a change to a garbage file (like a Vim swap file) in the
source directory will cause a book rebuild, which is bothersome and
unecessary. An -m / --markdown-only switch is added to the watch and
serve subcommands to ignore changes in all files that don't end in
`.md`.
@9999years
Copy link
Author

This might close or partially close #383. We could also consider using a user-supplied regex for files to watch.

@Michael-F-Bryan
Copy link
Contributor

Michael-F-Bryan commented Nov 25, 2018

Instead of using a command-line flag (which you have to remember every time you run mdbook) that only whitelists markdown files, I imagine people would want a more flexible solution where you can provide your own glob patterns to ignore. It'd be annoying if you were {{#include ...}}-ing a *.rs file in your document (which lots of tutorial-style documents do) and mdbook didn't rebuild when it changes.

For example,

[build]
# provide a list of globs to ignore
ignored = [
  "*.tmp",
  "*~",
]

# or use your gitignore file (e.g. with https://crates.io/crates/ignore)

[build]
ignored = "gitignore"

Also, should this alter just the behaviour of file watcher in mdbook watch and mdbook serve, or could it also be used to prevent things from accidentally being copied to the book/ output directory?

@9999years
Copy link
Author

I would be fine with either of those, although I feel like ignoring editor-dependent things like swap files should be an end-user task, not bundled with the repository; I feel the same way about putting .*.swp in a .gitignore; they belong, in my opinion, in a global .gitignore.

I only have a narrow need here: excluding my Vim swap files. Any solution that can accomplish that is fine by me. If you’d like to decide on a more flexible system, I’ll see what I can do to help implement it.

@ehuss
Copy link
Contributor

ehuss commented May 29, 2021

I'm going to close as this is somewhat outdated. Support for .gitignore has been added, and there is more discussion at #1187 and #1440 to configure what to ignore. Thanks for the PR, though!

@ehuss ehuss closed this May 29, 2021
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

Successfully merging this pull request may close these issues.

3 participants