3099 Commits

Author SHA1 Message Date
Eric Huss
24c7ffcd62 Fix mdbook-core book tests
These tests were moved in https://github.com/rust-lang/mdBook/pull/2766,
but the `mod tests` was missing. This fixes this missing `mod`, and
updates the tests so that they pass.
2025-08-22 17:04:21 -07:00
Eric Huss
ec436adca2 Merge pull request #2810 from ehuss/smart-punctuation-default
Enable smart-punctuation by default
2025-08-22 23:58:42 +00:00
Eric Huss
b8ad85c16f Enable smart-punctuation by default
This enables the smart-punctuation setting by default. The long term
plan is to continue to enable more markdown extensions by default across
semver breaking releases.
2025-08-22 16:52:08 -07:00
Eric Huss
6be8e526d6 Merge pull request #2809 from ehuss/markdown-options
Introduce options struct for markdown rendering
2025-08-22 23:23:58 +00:00
Eric Huss
f4012757a7 Introduce options struct for markdown rendering
This adds `MarkdownOptions` for creating the pulldown-cmark parser, and
`HtmlRenderOptions` for converting markdown to HTML. These types should
help make it easier to extend the rendering options while remaining
semver compatible. It should also help with just general ergonomics of
using these functions.
2025-08-22 16:17:41 -07:00
Eric Huss
0722d81295 Merge pull request #2808 from ehuss/mdbook-id
Change all HTML IDs to have a prefix
2025-08-20 02:45:29 +00:00
Eric Huss
402d11414c Change all HTML IDs to have a prefix
This changes all HTML IDs so that they have the `mdbook-` prefix. This
should help avoid ID conflicts between internal IDs and IDs from user
content such as section headers.

This is a relatively disruptive change and has a high risk of breaking
something. However, I think I have covered everything, and if anything
is missed, hopefully it will get detected.

I did not change class names since the chance of a collision is much
smaller than with IDs. However, that is something that could be
considered in the future.

Closes https://github.com/rust-lang/mdBook/issues/880
2025-08-19 19:38:22 -07:00
Eric Huss
988ed9b5bc Merge pull request #2807 from ehuss/footnotes-in-a-row
Test and add a fix for multiple footnotes in a row
2025-08-19 00:18:40 +00:00
Eric Huss
4a47b3d18a Add space between consecutive footnotes
This fixes it so that consecutive footnotes have a little space between
them so they aren't jammed together.
2025-08-18 17:11:18 -07:00
Eric Huss
82a457b548 Add a test for multiple footnotes in a row
These were previously broken in older versions of pulldown-cmark.
2025-08-18 16:38:34 -07:00
Eric Huss
54a5d749fc Merge pull request #2806 from ehuss/dest-dir-relative
Change CLI dest-dir to be relative to the current directory
2025-08-18 23:35:34 +00:00
Eric Huss
c177081104 Change CLI dest-dir to be relative to the current directory
This changes the `--dest-dir` flag so that it is relative to the current
directory, not the book root. This has been a source of confusion for
several people.

Fixes https://github.com/rust-lang/mdBook/issues/698
2025-08-18 16:28:08 -07:00
Eric Huss
1b00525574 Add test for relative dest-dir 2025-08-18 16:28:08 -07:00
Eric Huss
dbb51d32db Merge pull request #2805 from ehuss/remove-test-dest-dir
Remove `test --dest-dir`
2025-08-18 23:21:34 +00:00
Eric Huss
b4641d2830 Remove test --dest-dir
This removes the `--dest-dir` flag from the `mdbook test` subcommand
because it is unused. The test command does not generate output, so it
doesn't need an output directory.
2025-08-18 16:15:18 -07:00
Eric Huss
03f2806cae Merge pull request #2804 from ehuss/remove-external-gui-test
Remove external website tests
2025-08-18 21:01:48 +00:00
Eric Huss
4498739095 Remove external website tests
These tests have been flaky, and in general it was probably unwise to
try to rely on an external site like this. I was unable to determine
exactly why the test is failing. The page loads, and then puppeteer
throws an error.

I don't know if it is really feasible to bring these back in some form.
It's probably more effort than it is worth.

Closes https://github.com/rust-lang/mdBook/issues/2765
2025-08-18 13:55:45 -07:00
Eric Huss
29ae40c3ec Merge pull request #2801 from HollowMan6/btreemap
Keep preprocessors/backends execution order deterministic
2025-08-18 19:06:03 +00:00
Eric Huss
6746df7ce9 Add tests for preprocessor/output default sort order 2025-08-18 11:59:15 -07:00
Hollow Man
a0a01ecd60 Keep preprocessors/backends execution order deterministic
There's a regression caused by recent refactor work, as it used to execute preprocessors/backends in a deterministic way, but now this is not the case, which causes trouble when some backends implicitly depend on the result from another backend and happen to work (e.g. mdbook-pdf). The root cause is that a HashMap has no order, so this PR switches this into `BTreeMap` instead.

Signed-off-by: Hollow Man <hollowman@opensuse.org>
2025-08-18 11:58:23 -07:00
Eric Huss
21f2435182 Merge pull request #2802 from ehuss/with-replace
Change with_renderer/with_preprocessor to overwrite
2025-08-18 18:25:35 +00:00
Eric Huss
338a9b424e Change with_renderer/with_preprocessor to overwrite
This changes `with_renderer` and `with_preprocessor` to replace any
extensions of the same name instead of just appending to the list. This
is necessary for rust-lang's build process, because we replace the
preprocessors with local ones. Previously, mdbook would just print an
error, but continue working. With the change that preprocessors are no
longer optional by default, it is now required that we have a way to
replace the existing entries.
2025-08-18 11:18:31 -07:00
Eric Huss
25c47ed0bc Add tests for with_renderer and with_preprocessor collisions
This adds tests with with_renderer and with_preprocessor are used with
extensions that have the same name.
2025-08-18 11:18:30 -07:00
Eric Huss
0f0d1f3377 Merge pull request #2800 from ehuss/no-default-src
Don't serialize the default for `book.src`
2025-08-16 22:27:53 +00:00
Eric Huss
ae1a8c362c Don't serialize the default for book.src
This changes the serialization so that `book.src` is not serialized if
it is the default. This removes the somewhat pointless `src = "src"`
which shows up in the default `mdbook init` output. Deserialization
should still default to `"src"`.
2025-08-16 15:21:46 -07:00
Eric Huss
0043043bb3 Merge pull request #2799 from ehuss/guide-case
Use consistent sentence case for section headers
2025-08-16 22:05:24 +00:00
Eric Huss
e9e3bb6ddd Use consistent sentence case for section headers
There was a mix of different capitalization here, so I'm just going to
pick the one we use most often.
2025-08-16 14:59:05 -07:00
Eric Huss
03ba7d9089 Merge pull request #2797 from ehuss/optional-preprocessor
Add `optional` field for preprocessors
2025-08-16 20:46:36 +00:00
Eric Huss
d7892f5601 Add optional field for preprocessors
This adds the `optional` field to the preprocessor configuration to
mirror the same option for the `output` table. Missing preprocessors are
now an error unless the `optional` field is set. This should help with
inadvertently building a book when a missing preprocessor that you
expect to be installed.
2025-08-16 13:39:54 -07:00
Eric Huss
0a29ba6eb6 Add a test for a missing preprocessor 2025-08-16 13:33:38 -07:00
Eric Huss
4d9095b603 Change PreProcessor::supports_renderer to return a Result
This changes `PreProcessor::supports_renderer` to return a `Result` in
preparation to allow preprocessors to be optional when the command
fails.
2025-08-16 13:26:01 -07:00
Eric Huss
235c1f87f0 Factor out handle_render_command_error
This moves `handle_render_command_error` out to the crate root so that
it can later be shared with `CmdPreprocessor`.
2025-08-16 13:23:18 -07:00
Eric Huss
5d44ef91dc Merge pull request #2796 from ehuss/relative-cmd-preprocessor
Change CmdPreprocessor to use paths relative to the book root
2025-08-16 19:33:00 +00:00
Eric Huss
e7084e5548 Change CmdPreprocessor to use paths relative to the book root
This changes preprocessors so that:

- Relative paths in the `command` value are relative to the book root.
- The process current directory is the book root.

This makes it so that it isn't dependent on the directory where `mdbook`
is executed.

Fixes https://github.com/rust-lang/mdBook/issues/1424
2025-08-16 12:25:54 -07:00
Eric Huss
4637d5f5d1 Add a test for a relative preprocessor path 2025-08-16 12:17:50 -07:00
Eric Huss
4bac54883b Merge pull request #1330 from notriddle/embed-svg
Use embedded SVG instead of fonts for icons, font-awesome 6.2
2025-08-15 03:26:53 +00:00
Michael Howell
2dc8c5e686 Use embedded SVG instead of fonts for icons
The [downsides of icon fonts] are well-documented, and also, why ship all of
the icons when it only uses 14?

[downsides of icon fonts]: https://speakerdeck.com/ninjanails/death-to-icon-fonts
2025-08-14 20:14:55 -07:00
Eric Huss
7b3e6973be Merge pull request #2795 from ehuss/remove-theme-option
Remove theme_option
2025-08-14 02:48:39 +00:00
Eric Huss
9fce4ad74c Remove theme_option
This helper is no longer used.
2025-08-13 19:43:00 -07:00
Eric Huss
76c5b6967a Remove default_theme comment
I don't remember why I added this comment. The default_theme is
definitely still used.
2025-08-13 19:41:44 -07:00
Eric Huss
04ff12a206 Fix copy/paste error in resource error message 2025-08-13 19:41:44 -07:00
Eric Huss
3236ec0aea Merge pull request #2794 from ehuss/nav-helper
Replace navigation helpers with objects
2025-08-14 01:02:55 +00:00
Eric Huss
ff5e85af51 Replace navigation helpers with objects
This replaces the `{{#previous}}` and `{{#next}}` handelbars helpers
with simple objects that contain the previous and next values. These
helpers have been a bit fussy to work with and have caused issues in the
past. This drops a large amount of somewhat fragile code with something
that is a bit simpler.

Additionally, this switches the previous/next arrows to use an `{{#if}}`
instead CSS trickery which may help with upcoming changes to
font-awesome.
2025-08-13 17:56:18 -07:00
Eric Huss
c1b631d086 Merge pull request #2793 from rust-lang/dependabot/cargo/slab-0.4.11
Bump slab from 0.4.10 to 0.4.11
2025-08-13 20:48:15 +00:00
dependabot[bot]
39ce6123b6 Bump slab from 0.4.10 to 0.4.11
Bumps [slab](https://github.com/tokio-rs/slab) from 0.4.10 to 0.4.11.
- [Release notes](https://github.com/tokio-rs/slab/releases)
- [Changelog](https://github.com/tokio-rs/slab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/slab/compare/v0.4.10...v0.4.11)

---
updated-dependencies:
- dependency-name: slab
  dependency-version: 0.4.11
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-13 04:48:48 +00:00
Eric Huss
01da420f76 Merge pull request #2792 from ehuss/remove-relative-renderer-command
Remove legacy relative renderer command paths
2025-08-13 01:14:05 +00:00
Eric Huss
df037d132d Remove legacy relative renderer command paths
This removes the deprecated support for renderer paths that are relative
to the destination. Relative renderer command paths now must always be
relative to the book root.
2025-08-12 18:08:29 -07:00
Eric Huss
534725cbb8 Merge pull request #2791 from ehuss/un-pub-unique-id
Move id_from_content private
2025-08-13 01:07:38 +00:00
Eric Huss
4c948b4547 Merge pull request #2790 from ehuss/remove-copy-fonts
Remove copy-fonts
2025-08-13 01:02:33 +00:00
Eric Huss
bba1216df1 Move id_from_content private
This follows through with the deprecation of `id_from_content` which was
deprecated in https://github.com/rust-lang/mdBook/pull/1749.
2025-08-12 18:01:45 -07:00