diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bac5ab4479..8bcb4297c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,9 @@ name: CI on: [push, pull_request] +env: + MDBOOK_VERSION: 0.5.1 + jobs: test: name: Run tests @@ -17,7 +20,7 @@ jobs: - name: Install mdbook run: | mkdir bin - curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.45/mdbook-v0.4.45-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin + curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin echo "$(pwd)/bin" >> "${GITHUB_PATH}" - name: Report versions run: | @@ -71,10 +74,8 @@ jobs: - name: Install mdbook run: | mkdir bin - curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.45/mdbook-v0.4.45-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin + curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin echo "$(pwd)/bin" >> "${GITHUB_PATH}" - - name: Install mdbook-trpl binaries - run: cargo install --path packages/mdbook-trpl - name: Install aspell run: sudo apt-get install aspell - name: Install shellcheck diff --git a/2018-edition/book.toml b/2018-edition/book.toml index 03b59090b4..45a3991a05 100644 --- a/2018-edition/book.toml +++ b/2018-edition/book.toml @@ -1,6 +1,6 @@ [book] title = "The Rust Programming Language" -author = "Steve Klabnik and Carol Nichols, with Contributions from the Rust Community" +authors = ["Steve Klabnik", "Carol Nichols", "Contributions from the Rust Community"] [output.html] additional-css = ["ferris.css"] diff --git a/README.md b/README.md index 4c62b1a73b..6ee459448b 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,6 @@ rust-lang/rust uses in [this file][rust-mdbook]. To get it: $ cargo install mdbook --locked --version ``` -The book also uses two mdbook plugins which are part of this repository. If you -do not install them, you will see warnings when building and the output will not -look right, but you _will_ still be able to build the book. To use the plugins, -you should run: - -```bash -$ cargo install --locked --path packages/mdbook-trpl --force -``` - ## Building To build the book, type: diff --git a/book.toml b/book.toml index 96f6c63552..cba4f905a2 100644 --- a/book.toml +++ b/book.toml @@ -39,9 +39,14 @@ use-boolean-and = true # Do not sync this preprocessor; it is for the HTML renderer only. [preprocessor.trpl-note] +command = "cargo run --manifest-path packages/mdbook-trpl/Cargo.toml --bin mdbook-trpl-note" [preprocessor.trpl-listing] +command = "cargo run --manifest-path packages/mdbook-trpl/Cargo.toml --bin mdbook-trpl-listing" output-mode = "default" [rust] edition = "2024" + +[build] +extra-watch-dirs = ["packages/mdbook-trpl"] diff --git a/first-edition/book.toml b/first-edition/book.toml index 3a3189c4d7..59ee4b1e02 100644 --- a/first-edition/book.toml +++ b/first-edition/book.toml @@ -1,3 +1,3 @@ [book] title = "The Rust Programming Language" -author = "The Rust Project Developers" +authors = ["The Rust Project Developers"] diff --git a/nostarch/book.toml b/nostarch/book.toml index 8def0c1e5f..d80cfe2cbb 100644 --- a/nostarch/book.toml +++ b/nostarch/book.toml @@ -12,14 +12,17 @@ git-repository-url = "https://github.com/rust-lang/book" build-dir = "../tmp" [preprocessor.trpl-listing] +command = "cargo run --manifest-path ../packages/mdbook-trpl/Cargo.toml --bin mdbook-trpl-listing" output-mode = "simple" # Only used in this version, *not* in the root `book.toml`, because its job is # to remove `
` and `
` markup from the version we send them. [preprocessor.trpl-figure] +command = "cargo run --manifest-path ../packages/mdbook-trpl/Cargo.toml --bin mdbook-trpl-figure" output-mode = "simple" [preprocessor.trpl-heading] +command = "cargo run --manifest-path ../packages/mdbook-trpl/Cargo.toml --bin mdbook-trpl-heading" output-mode = "simple" [rust] diff --git a/packages/mdbook-trpl/Cargo.lock b/packages/mdbook-trpl/Cargo.lock index e096e4cd67..e97f7c7e29 100644 --- a/packages/mdbook-trpl/Cargo.lock +++ b/packages/mdbook-trpl/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -11,21 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anstream" version = "0.6.18" @@ -62,7 +47,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -72,14 +57,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "assert_cmd" @@ -97,12 +82,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - [[package]] name = "bitflags" version = "2.6.0" @@ -129,44 +108,17 @@ dependencies = [ "serde", ] -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "cc" -version = "1.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" -dependencies = [ - "shlex", -] - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "windows-targets", -] - [[package]] name = "clap" -version = "4.5.20" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" dependencies = [ "clap_builder", "clap_derive", @@ -174,31 +126,21 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", - "terminal_size", -] - -[[package]] -name = "clap_complete" -version = "4.5.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11611dca53440593f38e6b25ec629de50b14cdfa63adc0fb856115a2c6d97595" -dependencies = [ - "clap", ] [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ "heck", "proc-macro2", @@ -208,9 +150,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "colorchoice" @@ -218,12 +160,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - [[package]] name = "cpufeatures" version = "0.2.14" @@ -243,17 +179,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "dbus" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" -dependencies = [ - "libc", - "libdbus-sys", - "winapi", -] - [[package]] name = "difflib" version = "0.4.0" @@ -276,51 +201,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "env_filter" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" - [[package]] name = "generic-array" version = "0.14.7" @@ -340,26 +226,11 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "handlebars" -version = "6.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4ccde012831f9a071a637b0d4e31df31c0f6c525784b35ae76a9ac6bc1e315" -dependencies = [ - "log", - "num-order", - "pest", - "pest_derive", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" [[package]] name = "heck" @@ -382,40 +253,11 @@ dependencies = [ "thiserror", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "iana-time-zone" -version = "0.1.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "indexmap" -version = "2.6.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", "hashbrown", @@ -433,67 +275,36 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "js-sys" -version = "0.3.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "libc" -version = "0.2.162" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] -name = "libdbus-sys" -version = "0.2.5" +name = "mdbook-core" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" +checksum = "2ef8430ec21b88489dfffd90c0fb9bd3eab96bf7642ef0cab74754b9d2e5b7f6" dependencies = [ - "cc", - "pkg-config", + "anyhow", + "regex", + "serde", + "serde_json", + "toml 0.9.8", + "tracing", ] [[package]] -name = "linux-raw-sys" -version = "0.4.14" +name = "mdbook-preprocessor" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "mdbook" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7624879735513024d323e7267a0b3a7176aceb0db537939beb4ee31d9e8945e3" +checksum = "01f84f2b2ef3ccf2c6dd71255f9d90912cce7d5a5aa32899d033003d2c71f84d" dependencies = [ "anyhow", - "chrono", - "clap", - "clap_complete", - "env_logger", - "handlebars", - "log", - "memchr", - "once_cell", - "opener", - "pulldown-cmark 0.10.3", - "regex", + "mdbook-core", "serde", "serde_json", - "shlex", - "tempfile", - "toml 0.5.11", - "topological-sort", ] [[package]] @@ -504,9 +315,10 @@ dependencies = [ "assert_cmd", "clap", "html_parser", - "mdbook", - "pulldown-cmark 0.12.2", + "mdbook-preprocessor", + "pulldown-cmark", "pulldown-cmark-to-cmark", + "serde", "serde_json", "thiserror", "toml 0.8.19", @@ -514,42 +326,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "normpath" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8911957c4b1549ac0dc74e30db9c8b0e66ddcd6d7acc33098f4c63a64a6d7ed" -dependencies = [ - "windows-sys 0.59.0", -] - -[[package]] -name = "num-modular" -version = "0.6.1" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f" - -[[package]] -name = "num-order" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" -dependencies = [ - "num-modular", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "once_cell" @@ -557,18 +336,6 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" -[[package]] -name = "opener" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0812e5e4df08da354c851a3376fead46db31c2214f849d3de356d774d057681" -dependencies = [ - "bstr", - "dbus", - "normpath", - "windows-sys 0.59.0", -] - [[package]] name = "pest" version = "2.7.14" @@ -615,10 +382,10 @@ dependencies = [ ] [[package]] -name = "pkg-config" -version = "0.3.31" +name = "pin-project-lite" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "predicates" @@ -656,18 +423,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "pulldown-cmark" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" -dependencies = [ - "bitflags", - "memchr", - "pulldown-cmark-escape 0.10.1", - "unicase", -] - [[package]] name = "pulldown-cmark" version = "0.12.2" @@ -677,16 +432,10 @@ dependencies = [ "bitflags", "getopts", "memchr", - "pulldown-cmark-escape 0.11.0", + "pulldown-cmark-escape", "unicase", ] -[[package]] -name = "pulldown-cmark-escape" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3" - [[package]] name = "pulldown-cmark-escape" version = "0.11.0" @@ -699,7 +448,7 @@ version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d742adcc7b655dba3e9ebab47954ca229fc0fa1df01fdc94349b6f3a2e6d257" dependencies = [ - "pulldown-cmark 0.12.2", + "pulldown-cmark", ] [[package]] @@ -713,9 +462,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -725,9 +474,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -740,19 +489,6 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" -[[package]] -name = "rustix" -version = "0.38.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - [[package]] name = "ryu" version = "1.0.18" @@ -761,18 +497,28 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -781,14 +527,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] @@ -800,23 +547,26 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" +dependencies = [ + "serde_core", +] + [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", "digest", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "strsim" version = "0.11.1" @@ -834,29 +584,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "tempfile" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" -dependencies = [ - "cfg-if", - "fastrand", - "once_cell", - "rustix", - "windows-sys 0.59.0", -] - -[[package]] -name = "terminal_size" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" -dependencies = [ - "rustix", - "windows-sys 0.59.0", -] - [[package]] name = "termtree" version = "0.4.1" @@ -885,23 +612,29 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", + "serde_spanned 0.6.8", + "toml_datetime 0.6.8", + "toml_edit", ] [[package]] name = "toml" -version = "0.8.19" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", + "indexmap", + "serde_core", + "serde_spanned 1.0.3", + "toml_datetime 0.7.3", + "toml_parser", + "toml_writer", + "winnow 0.7.13", ] [[package]] @@ -913,6 +646,15 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +dependencies = [ + "serde_core", +] + [[package]] name = "toml_edit" version = "0.22.22" @@ -921,16 +663,56 @@ checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", - "serde_spanned", - "toml_datetime", - "winnow", + "serde_spanned 0.6.8", + "toml_datetime 0.6.8", + "winnow 0.6.20", ] [[package]] -name = "topological-sort" -version = "0.2.2" +name = "toml_parser" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" +dependencies = [ + "winnow 0.7.13", +] + +[[package]] +name = "toml_writer" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", +] [[package]] name = "typenum" @@ -983,101 +765,6 @@ dependencies = [ "libc", ] -[[package]] -name = "wasm-bindgen" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" -dependencies = [ - "cfg-if", - "once_cell", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.59.0" @@ -1159,3 +846,9 @@ checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] + +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" diff --git a/packages/mdbook-trpl/Cargo.toml b/packages/mdbook-trpl/Cargo.toml index 1eea3c426d..84edf9128b 100644 --- a/packages/mdbook-trpl/Cargo.toml +++ b/packages/mdbook-trpl/Cargo.toml @@ -23,9 +23,10 @@ path = "src/bin/figure.rs" anyhow = "1" clap = { version = "4", features = ["derive"] } html_parser = "0.7.0" -mdbook = { version = "0.4", default-features = false } # only need the library +mdbook-preprocessor = "0.5.1" pulldown-cmark = { version = "0.12", features = ["simd"] } pulldown-cmark-to-cmark = "19" +serde = { version = "1.0.228", features = ["serde_derive"] } serde_json = "1" thiserror = "1.0.60" toml = "0.8.12" diff --git a/packages/mdbook-trpl/src/bin/figure.rs b/packages/mdbook-trpl/src/bin/figure.rs index e780cbd4e7..44657877b5 100644 --- a/packages/mdbook-trpl/src/bin/figure.rs +++ b/packages/mdbook-trpl/src/bin/figure.rs @@ -2,7 +2,7 @@ use std::io; use clap::{self, Parser, Subcommand}; -use mdbook::preprocess::{CmdPreprocessor, Preprocessor}; +use mdbook_preprocessor::Preprocessor; use mdbook_trpl::Figure; fn main() -> Result<(), String> { @@ -15,7 +15,7 @@ fn main() -> Result<(), String> { } } None => { - let (ctx, book) = CmdPreprocessor::parse_input(io::stdin()) + let (ctx, book) = mdbook_preprocessor::parse_input(io::stdin()) .map_err(|e| format!("{e}"))?; let processed = Figure.run(&ctx, book).map_err(|e| format!("{e}"))?; diff --git a/packages/mdbook-trpl/src/bin/heading.rs b/packages/mdbook-trpl/src/bin/heading.rs index c54091bcdd..1c53046389 100644 --- a/packages/mdbook-trpl/src/bin/heading.rs +++ b/packages/mdbook-trpl/src/bin/heading.rs @@ -1,21 +1,21 @@ use std::io; use clap::{self, Parser, Subcommand}; -use mdbook::preprocess::{CmdPreprocessor, Preprocessor}; +use mdbook_preprocessor::Preprocessor; use mdbook_trpl::Heading; fn main() -> Result<(), String> { let cli = Cli::parse(); if let Some(Command::Supports { renderer }) = cli.command { - return if Heading.supports_renderer(&renderer) { + return if Heading.supports_renderer(&renderer).unwrap() { Ok(()) } else { Err(format!("Renderer '{renderer}' is unsupported")) }; } - let (ctx, book) = CmdPreprocessor::parse_input(io::stdin()) + let (ctx, book) = mdbook_preprocessor::parse_input(io::stdin()) .map_err(|e| format!("{e}"))?; let processed = Heading.run(&ctx, book).map_err(|e| format!("{e}"))?; serde_json::to_writer(io::stdout(), &processed).map_err(|e| format!("{e}")) diff --git a/packages/mdbook-trpl/src/bin/listing.rs b/packages/mdbook-trpl/src/bin/listing.rs index ed3f7226db..83c26a659a 100644 --- a/packages/mdbook-trpl/src/bin/listing.rs +++ b/packages/mdbook-trpl/src/bin/listing.rs @@ -1,21 +1,21 @@ use std::io; use clap::{self, Parser, Subcommand}; -use mdbook::preprocess::{CmdPreprocessor, Preprocessor}; +use mdbook_preprocessor::Preprocessor; use mdbook_trpl::Listing; fn main() -> Result<(), String> { let cli = Cli::parse(); if let Some(Command::Supports { renderer }) = cli.command { - return if Listing.supports_renderer(&renderer) { + return if Listing.supports_renderer(&renderer).unwrap() { Ok(()) } else { Err(format!("Renderer '{renderer}' is unsupported")) }; } - let (ctx, book) = CmdPreprocessor::parse_input(io::stdin()) + let (ctx, book) = mdbook_preprocessor::parse_input(io::stdin()) .map_err(|e| format!("{e}"))?; let processed = Listing.run(&ctx, book).map_err(|e| format!("{e}"))?; serde_json::to_writer(io::stdout(), &processed).map_err(|e| format!("{e}")) diff --git a/packages/mdbook-trpl/src/bin/note.rs b/packages/mdbook-trpl/src/bin/note.rs index 8af222b8d2..0367fcbbcf 100644 --- a/packages/mdbook-trpl/src/bin/note.rs +++ b/packages/mdbook-trpl/src/bin/note.rs @@ -1,7 +1,7 @@ use std::io; use clap::{self, Parser, Subcommand}; -use mdbook::preprocess::{CmdPreprocessor, Preprocessor}; +use mdbook_preprocessor::Preprocessor; use mdbook_trpl::Note; @@ -9,14 +9,14 @@ fn main() -> Result<(), String> { let cli = Cli::parse(); let simple_note = Note; if let Some(Command::Supports { renderer }) = cli.command { - return if simple_note.supports_renderer(&renderer) { + return if simple_note.supports_renderer(&renderer).unwrap() { Ok(()) } else { Err(format!("Renderer '{renderer}' is unsupported")) }; } - let (ctx, book) = CmdPreprocessor::parse_input(io::stdin()) + let (ctx, book) = mdbook_preprocessor::parse_input(io::stdin()) .map_err(|e| format!("blah: {e}"))?; let processed = simple_note.run(&ctx, book).map_err(|e| format!("{e}"))?; serde_json::to_writer(io::stdout(), &processed).map_err(|e| format!("{e}")) diff --git a/packages/mdbook-trpl/src/config/mod.rs b/packages/mdbook-trpl/src/config/mod.rs index 2a9ed2058b..12ffba9152 100644 --- a/packages/mdbook-trpl/src/config/mod.rs +++ b/packages/mdbook-trpl/src/config/mod.rs @@ -1,9 +1,11 @@ //! Get any `preprocessor.trpl-*` config. -use mdbook::preprocess::PreprocessorContext; +use mdbook_preprocessor::PreprocessorContext; -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, serde::Deserialize)] +#[serde(rename_all = "snake_case")] pub enum Mode { + #[default] Default, Simple, } @@ -13,58 +15,28 @@ impl Mode { ctx: &PreprocessorContext, preprocessor_name: &str, ) -> Result { - let config = ctx + #[derive(Default, serde::Deserialize)] + #[serde(rename_all = "kebab-case")] + struct Config { + #[serde(default)] + output_mode: Mode, + } + + let config: Config = ctx .config - .get_preprocessor(preprocessor_name) + .get(&format!("preprocessor.{preprocessor_name}"))? .ok_or_else(|| Error::NoConfig(preprocessor_name.into()))?; - - let key = String::from("output-mode"); - let mode = config - .get(&key) - .map(|value| match value.as_str() { - Some(s) => Mode::try_from(s).map_err(|_| Error::BadValue { - key, - value: value.to_string(), - }), - None => Err(Error::BadValue { - key, - value: value.to_string(), - }), - }) - .transpose()? - .unwrap_or(Mode::Default); - - Ok(mode) - } -} - -/// Trivial marker struct to indicate an internal error. -/// -/// The caller has enough info to do what it needs without passing data around. -pub struct ParseErr; - -impl TryFrom<&str> for Mode { - type Error = ParseErr; - - fn try_from(value: &str) -> Result { - match value { - "default" => Ok(Mode::Default), - "simple" => Ok(Mode::Simple), - _ => Err(ParseErr), - } + Ok(config.output_mode) } } #[derive(Debug, thiserror::Error)] pub enum Error { #[error(transparent)] - Mdbook(#[from] mdbook::errors::Error), + Mdbook(#[from] mdbook_preprocessor::errors::Error), #[error("No config for '{0}'")] NoConfig(String), - - #[error("Bad config value '{value}' for key '{key}'")] - BadValue { key: String, value: String }, } #[cfg(test)] diff --git a/packages/mdbook-trpl/src/config/tests.rs b/packages/mdbook-trpl/src/config/tests.rs index 0795595abc..9bf855ac03 100644 --- a/packages/mdbook-trpl/src/config/tests.rs +++ b/packages/mdbook-trpl/src/config/tests.rs @@ -6,11 +6,10 @@ //! more complex in the future, it would be good to revisit and integrate //! the same kinds of tests as the unit tests above here. -use mdbook::{ - book::Book, +use mdbook_preprocessor::{ + book::{Book, BookItem}, errors::Result, - preprocess::{Preprocessor, PreprocessorContext}, - BookItem, + Preprocessor, PreprocessorContext, }; use crate::config::Mode; @@ -39,17 +38,16 @@ fn no_config() { "book": { "authors": ["AUTHOR"], "language": "en", - "multilingual": false, "src": "src", "title": "TITLE" }, "preprocessor": {} }, "renderer": "html", - "mdbook_version": "0.4.21" + "mdbook_version": "0.5.1" }, { - "sections": [ + "items": [ { "Chapter": { "name": "Chapter 1", @@ -66,8 +64,7 @@ fn no_config() { } ]"##; let input_json = input_json.as_bytes(); - let (ctx, book) = - mdbook::preprocess::CmdPreprocessor::parse_input(input_json).unwrap(); + let (ctx, book) = mdbook_preprocessor::parse_input(input_json).unwrap(); let result = TestPreprocessor.run(&ctx, book); assert!(result.is_err()); let err = result.unwrap_err(); @@ -83,7 +80,6 @@ fn empty_config() { "book": { "authors": ["AUTHOR"], "language": "en", - "multilingual": false, "src": "src", "title": "TITLE" }, @@ -92,10 +88,10 @@ fn empty_config() { } }, "renderer": "html", - "mdbook_version": "0.4.21" + "mdbook_version": "0.5.0" }, { - "sections": [ + "items": [ { "Chapter": { "name": "Chapter 1", @@ -112,8 +108,7 @@ fn empty_config() { } ]"##; let input_json = input_json.as_bytes(); - let (ctx, book) = - mdbook::preprocess::CmdPreprocessor::parse_input(input_json).unwrap(); + let (ctx, book) = mdbook_preprocessor::parse_input(input_json).unwrap(); let book = TestPreprocessor.run(&ctx, book).unwrap(); assert!(book.iter().any( |item| matches!(item, BookItem::PartTitle(title) if title == &format!("{:?}", Mode::Default)) @@ -129,7 +124,6 @@ fn specify_default() { "book": { "authors": ["AUTHOR"], "language": "en", - "multilingual": false, "src": "src", "title": "TITLE" }, @@ -140,10 +134,10 @@ fn specify_default() { } }, "renderer": "html", - "mdbook_version": "0.4.21" + "mdbook_version": "0.5.1" }, { - "sections": [ + "items": [ { "Chapter": { "name": "Chapter 1", @@ -160,8 +154,7 @@ fn specify_default() { } ]"##; let input_json = input_json.as_bytes(); - let (ctx, book) = - mdbook::preprocess::CmdPreprocessor::parse_input(input_json).unwrap(); + let (ctx, book) = mdbook_preprocessor::parse_input(input_json).unwrap(); let book = TestPreprocessor.run(&ctx, book).unwrap(); assert!(book.iter().any( |item| matches!(item, BookItem::PartTitle(title) if title == &format!("{:?}", Mode::Default)) @@ -177,7 +170,6 @@ fn specify_simple() { "book": { "authors": ["AUTHOR"], "language": "en", - "multilingual": false, "src": "src", "title": "TITLE" }, @@ -188,10 +180,10 @@ fn specify_simple() { } }, "renderer": "html", - "mdbook_version": "0.4.21" + "mdbook_version": "0.5.1" }, { - "sections": [ + "items": [ { "Chapter": { "name": "Chapter 1", @@ -208,8 +200,7 @@ fn specify_simple() { } ]"##; let input_json = input_json.as_bytes(); - let (ctx, book) = - mdbook::preprocess::CmdPreprocessor::parse_input(input_json).unwrap(); + let (ctx, book) = mdbook_preprocessor::parse_input(input_json).unwrap(); let book = TestPreprocessor.run(&ctx, book).unwrap(); assert!(book.iter().any( |item| matches!(item, BookItem::PartTitle(title) if title == &format!("{:?}", Mode::Simple)) @@ -225,7 +216,6 @@ fn specify_invalid() { "book": { "authors": ["AUTHOR"], "language": "en", - "multilingual": false, "src": "src", "title": "TITLE" }, @@ -236,10 +226,10 @@ fn specify_invalid() { } }, "renderer": "html", - "mdbook_version": "0.4.21" + "mdbook_version": "0.5.1" }, { - "sections": [ + "items": [ { "Chapter": { "name": "Chapter 1", @@ -256,11 +246,14 @@ fn specify_invalid() { } ]"##; let input_json = input_json.as_bytes(); - let (ctx, book) = - mdbook::preprocess::CmdPreprocessor::parse_input(input_json).unwrap(); + let (ctx, book) = mdbook_preprocessor::parse_input(input_json).unwrap(); let result = TestPreprocessor.run(&ctx, book).unwrap_err(); assert_eq!( - format!("{result}"), - "Bad config value '\"nonsense\"' for key 'output-mode'" + format!("{result:?}"), + "Failed to deserialize `preprocessor.test-preprocessor`\n\ + \n\ + Caused by:\n \ + unknown variant `nonsense`, expected `default` or `simple`\n \ + in `output-mode`\n " ); } diff --git a/packages/mdbook-trpl/src/figure/mod.rs b/packages/mdbook-trpl/src/figure/mod.rs index e8a564c0e8..87e37ebf0a 100644 --- a/packages/mdbook-trpl/src/figure/mod.rs +++ b/packages/mdbook-trpl/src/figure/mod.rs @@ -1,6 +1,9 @@ use anyhow::{anyhow, Result}; use html_parser::{Dom, Node}; -use mdbook::{book::Book, preprocess::Preprocessor, BookItem}; +use mdbook_preprocessor::{ + book::{Book, BookItem}, + Preprocessor, +}; use pulldown_cmark::Event; use pulldown_cmark_to_cmark::cmark; @@ -48,7 +51,7 @@ impl Preprocessor for TrplFigure { fn run( &self, - ctx: &mdbook::preprocess::PreprocessorContext, + ctx: &mdbook_preprocessor::PreprocessorContext, mut book: Book, ) -> Result { // The `
`-based output is only replaced in the `Simple` mode. diff --git a/packages/mdbook-trpl/src/heading/mod.rs b/packages/mdbook-trpl/src/heading/mod.rs index e0eb0afaeb..cf08dea54a 100644 --- a/packages/mdbook-trpl/src/heading/mod.rs +++ b/packages/mdbook-trpl/src/heading/mod.rs @@ -1,8 +1,8 @@ use anyhow::anyhow; -use mdbook::{ - book::Book, - preprocess::{Preprocessor, PreprocessorContext}, - BookItem, +use mdbook_preprocessor::{ + book::{Book, BookItem}, + errors::Result, + Preprocessor, PreprocessorContext, }; use pulldown_cmark::{Event, Tag, TagEnd}; use pulldown_cmark_to_cmark::cmark; @@ -16,11 +16,7 @@ impl Preprocessor for TrplHeading { "trpl-heading" } - fn run( - &self, - ctx: &PreprocessorContext, - mut book: Book, - ) -> anyhow::Result { + fn run(&self, ctx: &PreprocessorContext, mut book: Book) -> Result { let mode = Mode::from_context(ctx, self.name())?; let mut errors = vec![]; @@ -40,8 +36,8 @@ impl Preprocessor for TrplHeading { } } - fn supports_renderer(&self, renderer: &str) -> bool { - renderer == "html" || renderer == "markdown" || renderer == "test" + fn supports_renderer(&self, renderer: &str) -> Result { + Ok(renderer == "html" || renderer == "markdown" || renderer == "test") } } diff --git a/packages/mdbook-trpl/src/listing/mod.rs b/packages/mdbook-trpl/src/listing/mod.rs index 91bd522448..f39b9e97b4 100644 --- a/packages/mdbook-trpl/src/listing/mod.rs +++ b/packages/mdbook-trpl/src/listing/mod.rs @@ -1,10 +1,9 @@ use anyhow::anyhow; use html_parser::Dom; -use mdbook::{ - book::Book, +use mdbook_preprocessor::{ + book::{Book, BookItem}, errors::Result, - preprocess::{Preprocessor, PreprocessorContext}, - BookItem, + Preprocessor, PreprocessorContext, }; use pulldown_cmark::{html, Event}; use pulldown_cmark_to_cmark::cmark; @@ -80,8 +79,8 @@ impl Preprocessor for TrplListing { } } - fn supports_renderer(&self, renderer: &str) -> bool { - renderer == "html" || renderer == "markdown" || renderer == "test" + fn supports_renderer(&self, renderer: &str) -> Result { + Ok(renderer == "html" || renderer == "markdown" || renderer == "test") } } diff --git a/packages/mdbook-trpl/src/note/mod.rs b/packages/mdbook-trpl/src/note/mod.rs index 12528a1f2e..08c62811fd 100644 --- a/packages/mdbook-trpl/src/note/mod.rs +++ b/packages/mdbook-trpl/src/note/mod.rs @@ -1,8 +1,7 @@ -use mdbook::{ - book::Book, +use mdbook_preprocessor::{ + book::{Book, BookItem}, errors::Result, - preprocess::{Preprocessor, PreprocessorContext}, - BookItem, + Preprocessor, PreprocessorContext, }; use pulldown_cmark::{ Event::{self, *}, @@ -43,8 +42,8 @@ impl Preprocessor for TrplNote { Ok(book) } - fn supports_renderer(&self, renderer: &str) -> bool { - renderer == "html" || renderer == "markdown" || renderer == "test" + fn supports_renderer(&self, renderer: &str) -> Result { + Ok(renderer == "html" || renderer == "markdown" || renderer == "test") } } diff --git a/second-edition/book.toml b/second-edition/book.toml index 9789a435c2..64d5099081 100644 --- a/second-edition/book.toml +++ b/second-edition/book.toml @@ -1,3 +1,3 @@ [book] title = "The Rust Programming Language" -author = "Steve Klabnik and Carol Nichols, with Contributions from the Rust Community" +authors = ["Steve Klabnik", "Carol Nichols", "Contributions from the Rust Community"] diff --git a/tools/nostarch.sh b/tools/nostarch.sh index f209b306dd..7d9c735a80 100755 --- a/tools/nostarch.sh +++ b/tools/nostarch.sh @@ -4,14 +4,12 @@ set -eu cargo build --release -cargo install --locked --path ./packages/mdbook-trpl --offline - mkdir -p tmp rm -rf tmp/*.md rm -rf tmp/markdown # Render the book as Markdown to include all the code listings -MDBOOK_OUTPUT__MARKDOWN=1 mdbook build nostarch +MDBOOK_OUTPUT__MARKDOWN='{}' mdbook build nostarch # Get all the Markdown files # TODO: what was this doing and why?!?