Commit Graph
5117 Commits
Author SHA1 Message Date
Chris Krycho e28a6b01f4 infra: fix rendering bug in mdbook-trpl-note
Previously, this was only pushing in the opening paragraph tag before
getting to text, so it was accidentally dropping cases where the text
started after some other opening tag, e.g. strong emphasis.
2024-05-16 08:47:25 -06:00
Chris Krycho 7e2a00d5d0 Merge pull request #3920 from rust-lang/listings-without-file-name
infra: support `Listing`s without `file-name`
2024-05-14 15:56:37 -06:00
Chris Krycho ad673cfb00 infra: support Listings without file-name
I did not realize we had some of these, but: we do!
2024-05-14 15:51:53 -06:00
Chris Krycho 444932b1c8 Merge pull request #3918 from rust-lang/trpl-listing
Add a `<Listing>` preprocessor
2024-05-14 11:41:03 -06:00
Chris Krycho 17c244ac13 infra: Convert one listing to use <Listing>
- Add CSS for `figure.listing`; this now renders identically to how the
  existing listings render.
- Convert the first listing in the book to use `<Listing>` instead of
  a bunch of `<span>`s.
2024-05-14 08:25:02 -06:00
Chris Krycho e65efe3a99 infra: handle trailing newlines correctly in mdbook-trpl-listing 2024-05-14 08:25:02 -06:00
Chris Krycho 04841f73ba infra: configure trpl-listing preprocessor 2024-05-14 08:25:02 -06:00
Chris Krycho 3254856510 infra: Hoist mdBook preprocessor workspace dependencies 2024-05-14 07:50:10 -06:00
Chris Krycho 59a02b9ed4 Merge mdbook-trpl-listing into the repository
This does not yet update all the workspace dependencies to be shared
between the listing and note preprocessors; it *only* integrates the
repo histories.
2024-05-14 07:39:16 -06:00
Chris Krycho dad2b61a69 Prepare to integrate into TRPL repo 2024-05-14 07:32:56 -06:00
Chris Krycho e07789118b Implement an mdBook preprocessor for <Listing>s
Instead of requiring a bunch of `<span>` wrangling, add a custom tag,
`<Listing>`, whose attributes get rewritten into the desired output
format, using `<figure>` and `<figcaption>` for improved semantic HTML.

Support both a default (nice and fancy) HTML output mode and a “simple”
mode to make it so we get the desired output format for the NoStarch
input files as well.
2024-05-14 07:32:06 -06:00
Chris Krycho 000b3d03e1 Create a repo for listing preprocessor 2024-05-13 17:08:58 -06:00
Herbert Reiter 03178db51d Update explanation according to code listing 2024-05-13 09:54:37 -04:00
Chris Krycho 698a756e46 Merge pull request #3915 from rust-lang/run-package-tests
infra: run package tests
2024-05-10 08:45:22 -06:00
Chris Krycho 7e28bd7d73 infra: run package tests
With the introduction of the workspace, we were missing coverage for the
supporting packages.
2024-05-10 08:40:25 -06:00
Chris Krycho 2a20b8373d Merge pull request #3914 from rust-lang/fix-workspace
Fix workspace behavior by excluding `listings`
2024-05-09 12:57:37 -06:00
Chris Krycho d4c69fd881 Fix workspace behavior by excluding listings
At some point we may want to include these in the workspace, but for
now they need to be excluded so `cargo build` and `rust-analyzer` work
correctly with the workspace layout.
2024-05-09 12:38:54 -06:00
Carol (Nichols || Goulding) 93a7176c9a Add subslices to the dictionary 2024-05-07 19:58:22 -04:00
Carol (Nichols || Goulding) b04c03d01a Snapshot changes to ch8 to consider sending to nostarch 2024-05-07 19:58:22 -04:00
Carol (Nichols || Goulding) d1e3925a96 Snapshot changes to generated ch8 that SHOULDN'T be sent to nostarch 2024-05-07 19:58:22 -04:00
Carol (Nichols || Goulding) 36d9cfc0ad Backport changes to chapter 8 2024-05-07 19:58:22 -04:00
Chris Krycho bebcf527e6 Merge pull request #3904 from LukeFranceschini/main
[ch10-03] Fix wording change about mandatory type annotation
2024-04-29 20:06:57 -06:00
Chris Krycho 7813712d03 Merge pull request #3907 from rust-lang/chriskrycho/semantic-notes
Introduce handling for accessible/semantic note rendering in HTML
2024-04-29 20:05:53 -06:00
Chris Krycho 427f7d3b8f Update CI config for workspace and mdbook-trpl-note
- Add building `mdbook-trpl-note` to the relevant workflow.
- Explicitly exclude `linkcheck` from new workspace.
2024-04-29 16:18:34 -06:00
Chris Krycho 593ec2af6a Do not apply semantic note handling to nostarch
Introduce a `book.toml` in the `nostarch` directory, which matches the
existing `book.toml` except for specifying the correct relative input
and output directories and disabling the `trpl-note` preprocessor. This
also lets us simplify the invocation in the `nostarch.sh` script a bit,
by providing the configuration directly in the file.
2024-04-29 16:18:34 -06:00
Chris Krycho da7a20f2fc Emit semantic HTML instead of blockquotes for notes
Use the newly-introduced `mdbook-trpl-note` to render accessible and
semantic HTML for the notes/callouts in the book. This currently applies
to the nostarch version as well, so a follow-on change will update the
build process to undo that. Add CSS so the new note rendering matches
the existing rendering of blockquotes. (We might want to change that at
some point, but for now the goal is to maximizing continuity.)
2024-04-29 16:18:34 -06:00
Chris Krycho 33fb62e92f Make mdbook a workspace root dependency 2024-04-29 16:18:34 -06:00
Chris Krycho 456a8dc440 Merge mdbook-trpl-note into the repository
I developed this in its own repo before we knew how we wanted to
integrate it. We decided on a workspace, so this pulls it in with all
its development history.
2024-04-29 16:18:34 -06:00
Chris Krycho da9e96e876 Modernize tools package contents 2024-04-29 09:29:59 -06:00
Chris Krycho f48b281275 Convert to a workspace
This will let us pull in, and work directly on, things like the
`mdbook-trpl-notes` preprocessor.
2024-04-29 09:27:34 -06:00
Chris Krycho 303206849b Prepare to merge into TRPL repo
In the destination, this will be part of a Cargo workspace, and should
*not* be in the root, where a merge will conflict with the workspace
Cargo config etc.
2024-04-29 08:24:50 -06:00
Luke Franceschini 1787086b5f [ch10-03] Fix wording change about mandatory type annotation
The wording change in 66aedb4 made this sentence flow more nicely, but is a misleading because it implies types can't be annotated if there is only one possible type. This changes it back to it's previous order, but replaces "must" with "have to" to keep it's correctness while still flowing more naturally.

Technically it's still incorrect because types have to be annotated in type signatures even if there is only one possible type. Maybe the word "only" in this sentence should be removed?
2024-04-29 06:27:13 -04:00
Chris Krycho 2eabe4eb1d Remove aria-label from <section>s.
My inspiration for these included the `aria-label` because the notes did
not have a label like `Note: ` or a heading on them; these do, though.
Keep the `aria-role` so screen readers present notes distinctively the
same way the visual presentation is set off.

Fix README: remove `aria-label` from there as well
2024-04-26 16:00:09 -06:00
Chris Krycho 8c899a3bee Correctly handle adjacent quotes and notes.
In a scenario like this:

```markdown
> This is a quote.

> Note: this is a note
```

The result should be this output:

```markdown
> This is a quote.

<section class="note" aria-label="Note" aria-role="note">

Note: this is a note

</section>
```

The same goes for heading-type notes, and for the inverted flow.
2024-04-26 14:49:27 -06:00
Chris Krycho 215420ab42 Rename header tests for clarity (prep for adding more tests!). 2024-04-26 14:49:25 -06:00
Chris Krycho 804a6ad768 Do *not* remove the leading “Note: ” from notes. 2024-04-26 14:48:34 -06:00
Chris Krycho 5f19f77fdf Invert the order of the pattern match for readability.
Trying to make changes to this made my head hurt: the fundamental split
is on the state, *not* on the tag. So flip it.
2024-04-26 14:47:07 -06:00
Chris Krycho 301c7048a3 Rename to mdbook-trpl-note. This is *very* specific. 2024-04-26 14:07:33 -06:00
Chris Krycho 563d52bcc5 Add support for headings.
This kind of thing works now:

```markdown
> ## Something Big
>
> Here is the content!
```

The book does a lot of that (not just `> Note: …`). 😅
2024-04-26 14:02:56 -06:00
Chris Krycho 077b0c98b4 Rename to mdbook-simple-note. No need to be so verbose! 2024-04-26 13:05:54 -06:00
Chris Krycho d098a33cb7 Integrate rewrite into an mdBook preprocessor
- Rework the `rewrite` function to spit back out Markdown instead of
  going all the way to HTML.
- Implement the `Preprocessor` type and wire up a CLI conforming to the
  mdBook preprocessor spec.
- Add relevant deps, including for an integration test.
2024-04-26 12:56:30 -06:00
Chris Krycho da52d2ad99 Implement functionality for actual rewrite 2024-04-25 16:48:09 -06:00
Carol (Nichols || Goulding) cb0a24007f Snapshot changes to ch7 to consider sending to nostarch 2024-04-25 17:04:25 -04:00
Carol (Nichols || Goulding) f954cb859f Snapshot changes to generated ch7 that SHOULDN'T be sent to nostarch
This snapshot contains line wrapping problems, irrelevant comments,
extraneous output lines, and differences we're going to allow between
the online and print version.

The intention is to make this a baseline commit for chapter 7 that we
can diff against to find changes to consider sending to nostarch as tiny
tweaks.
2024-04-25 17:04:25 -04:00
Carol (Nichols || Goulding) 98165c4279 Backport changes from print for ch7 2024-04-25 17:04:25 -04:00
Chris Krycho d207d894cc Merge pull request #3898 from rust-lang/chriskrycho/crab-pincers
Ch. 2: intentionally use `{}` at first
2024-04-19 13:48:19 -06:00
Chris Krycho 0b4e00345c Merge pull request #3897 from nyurik/redirect-lints
Inline fmt lints for `redirects/`
2024-04-19 13:48:13 -06:00
Chris Krycho 502d012cab Ch. 2: intentionally use {} at first
This supports the prose in the guessing game tutorial, which uses this
as a way of teaching where you can do `{foo}` and where you cannot.
2024-04-19 13:42:05 -06:00
Yuri Astrakhan c13271897d Inline fmt lints for redirects/
I couldn't find any documentation of how `redirects/` dir is being used,
but fixed inlined format args for consistency
2024-04-19 15:40:41 -04:00
Chris Krycho 8a79f3e15d Merge pull request #3287 from bravequickcleverfibreyarn/listing-12-02
ch12-03: `expect` is not used multitude times by this chapter
2024-04-19 13:36:49 -06:00