Compare commits

...

10 Commits

Author SHA1 Message Date
Eric Huss
405f407260 Fix typo in changelog 2025-10-29 20:23:31 -07:00
Eric Huss
eaa778bebd Merge pull request #2908 from rust-lang/ehuss-patch-1
mdbook-compare: fix duplicate "diff" print
2025-10-30 02:51:01 +00:00
Eric Huss
a17c1d1b95 mdbook-compare: fix duplicate "diff" print
The "diff" arg is already in the args list.
2025-10-29 19:45:22 -07:00
Eric Huss
8a27d1b7ac Merge pull request #2904 from traviscross/TC/fix-ayu-comments
Remove italics from `ayu` quotes/comments for alignment
2025-10-28 19:50:07 +00:00
Eric Huss
d6cd50b601 Merge pull request #2907 from ehuss/search-feature
Expose "search" feature from mdbook-driver
2025-10-28 18:37:03 +00:00
Eric Huss
68d9bcfec4 Expose "search" feature from mdbook-driver
This allows users of mdbook-driver to easily enable the search feature.
2025-10-28 11:29:48 -07:00
Eric Huss
3fa49214ad Merge pull request #2905 from ehuss/fix-indented-code-block
Fix rust fenced code blocks with an indent
2025-10-28 01:44:41 +00:00
Eric Huss
ddf02e0c0c Fix rust fenced code blocks with an indent
This fixes a bug in the Rust code block partitioning that was
incorrectly removing the whitespace from the beginning of a code block.
2025-10-27 18:38:27 -07:00
Eric Huss
3992bc18f5 Add a test for a fenced code block with an indent 2025-10-27 18:35:39 -07:00
Travis Cross
49f9c9741e Remove italics from ayu quotes/comments for alignment
Comments in code examples often rely on exact column alignment,
e.g. for ASCII-art.  This alignment often relies on both code and
comment characters having exactly the same width.

Setting `font-style: italic` seems to break these invariants with
common monospace fonts used by browsers.  This may be due to font
synthesis when the monospace font does not have a native italic
variant.

E.g., see these code examples when using the `ayu` theme:

- https://doc.rust-lang.org/1.90.0/reference/types/closure.html#r-type.closure.drop-order
- https://doc.rust-lang.org/1.90.0/reference/types/impl-trait.html#r-type.impl-trait.generic-capture.precise.use

It seems more important to have correct alignment than to style these
elements in italics, so let's drop the italic styling.

One alternative would be to set `font-synthesis: none` instead.  This
would prevent font synthesis-related misalignment while still
rendering italics when a font supports italics natively.  This might
correct the alignment issue, but ASCII-art in comments often wants
vertical bars to actually be vertical, so it still seems better to
just turn off italics entirely.

A more minimal change might be to only drop this from comments and not
from `hljs-quote`, but it seems the styling for these classes are
usually kept in sync, so we preserve that here.
2025-10-27 20:26:04 +00:00
11 changed files with 46 additions and 4 deletions

View File

@@ -76,7 +76,7 @@ The following is a summary of the changes that may require your attention when u
- [`mdbook-markdown`](https://docs.rs/mdbook-markdown/latest/mdbook_markdown/) — The Markdown renderer. If you are processing markdown, this is the crate you should depend on. This is essentially a thin wrapper around `pulldown-cmark`, and re-exports that crate so that you can ensure the version stays in sync with mdBook.
- [`mdbook-summary`](https://docs.rs/mdbook-summary/latest/mdbook_summary/) — The `SUMMARY.md` parser.
- [`mdbook-html`](https://docs.rs/mdbook-html/latest/mdbook_html/) — The HTML renderer.
- [`mdbook-core`](https://docs.rs/mdbook-core/latest/mdbook_core/) — An internal library that is used by the other crates for shared types. You should not depend on this crate directly since types from this crate are rexported from the other crates as appropriate.
- [`mdbook-core`](https://docs.rs/mdbook-core/latest/mdbook_core/) — An internal library that is used by the other crates for shared types. You should not depend on this crate directly since types from this crate are re-exported from the other crates as appropriate.
- Changes to `Config`:
- [`Config::get`](https://docs.rs/mdbook-core/latest/mdbook_core/config/struct.Config.html#method.get) is now generic over the return value, using `serde` to deserialize the value. It also returns a `Result` to handle deserialization errors. [#2773](https://github.com/rust-lang/mdBook/pull/2773)
- Removed `Config::get_deserialized`. Use `Config::get` instead.

View File

@@ -104,7 +104,7 @@ fn tidy(path: &Path) {
fn diff(a: &Path, b: &Path) {
let args = "diff --no-index";
println!("running `git diff {args} {a:?} {b:?}`");
println!("running `git {args} {a:?} {b:?}`");
Command::new("git")
.args(args.split(' '))
.args([a, b])

View File

@@ -27,3 +27,6 @@ tracing.workspace = true
[lints]
workspace = true
[features]
search = ["mdbook-html/search"]

View File

@@ -23,6 +23,12 @@
//! for shared types. Types from this crate are rexported from the other
//! crates as appropriate.
//!
//! ## Cargo features
//!
//! The following cargo features are available:
//!
//! - `search`: Enables the search index in the HTML renderer.
//!
//! ## Examples
//!
//! If creating a new book from scratch, you'll want to get a [`init::BookBuilder`] via

View File

@@ -13,7 +13,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
.hljs-comment,
.hljs-quote {
color: #5c6773;
font-style: italic;
}
.hljs-variable,

View File

@@ -141,7 +141,14 @@ fn partition_rust_source(s: &str) -> (&str, &str) {
let split_idx = match HEADER_RE.captures(s) {
Some(caps) => {
let attributes = &caps[1];
attributes.len()
if attributes.trim().is_empty() {
// Don't include pure whitespace as an attribute. The
// whitespace in the regex is intended to handle multiple
// attributes *separated* by potential whitespace.
0
} else {
attributes.len()
}
}
None => 0,
};
@@ -179,4 +186,8 @@ fn it_partitions_rust_source() {
),
("\n#![allow(foo)]\n\n#![allow(bar)]\n\n", "let x = 1;")
);
assert_eq!(
partition_rust_source(" // Example"),
("", " // Example")
);
}

View File

@@ -223,3 +223,9 @@ Html text was:
fn html_blocks() {
BookTest::from_dir("rendering/html_blocks").check_all_main_files();
}
// Test for a fenced code block that is also indented.
#[test]
fn code_block_fenced_with_indent() {
BookTest::from_dir("rendering/code_blocks_fenced_with_indent").check_all_main_files();
}

View File

@@ -0,0 +1,2 @@
[book]
title = "code_blocks_fenced_with_indent"

View File

@@ -0,0 +1,6 @@
<h1 id="code-blocks-fenced-with-indent"><a class="header" href="#code-blocks-fenced-with-indent">Code blocks fenced with indent</a></h1>
<pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span> // This has a first line that is indented.
println!("hello");
<span class="boring">}</span></code></pre>

View File

@@ -0,0 +1,3 @@
# Summary
- [Code blocks fenced with indent](./code-blocks-fenced-with-indent.md)

View File

@@ -0,0 +1,6 @@
# Code blocks fenced with indent
```rust
// This has a first line that is indented.
println!("hello");
```