Based on the conversation in https://github.com/rust-lang/mdBook/issues/1238,
this implements the suggestion by markhildreth to implement such a setting.
I've additionally infixed `-site-` to highlight the relationship with the
`site-url`, and to distinguish it from the canonical URL as it occurs in a
page.
The {{ resource }} directive in templates uses / as separator, but Path::join on Windows produces \. This caused hash map lookups to fail on Windows when templates use forward slashes (or vice versa).
Add normalize_path() to normalize filenames to forward slashes when registering static files and when resolving resource directives.
Fixes#3221
Signed-off-by: Mustafa Senoglu <mmustafasenoglu0@gmail.com>
Add a `--socket-activate` flag that adopts a pre-bound TCP listener
from `LISTEN_FDS` instead of binding a new one. This allows process
managers like foreman (with Socketfile support) or systemd to own the
socket, so it survives server restarts.
Three modes:
- `--socket-activate`: require a passed-in socket, fail if absent
- `--port N` / `--hostname H`: always bind, ignore `LISTEN_FDS`
- Neither: try `LISTEN_FDS` first, fall back to binding the default
The listener is now bound in the main thread before spawning the
server, so the actual address is always known for logging and
`--open`.
Also parse `--port` as `u16` at arg-parse time instead of leaving
it as a string.
Socket activation is normally associated with systemd. And indeed, it
would be peculiar to wire up this development command with systemd, but
it is also used in other contexts more appropriate to this command, like
https://github.com/mitsuhiko/systemfd, a development tool. From a
Capsicum/WASI perspective, it also is generally better when tools can
consume resources provided by a more privileged caller, rather than
having to open them themselves. For these reasons, I think everything
should support socket-activation.
the sidebar treats the first chapter as an alias for index.html, but a README chapter placed later in SUMMARY.md generates index.html itself, so both entries were marked active. Skip the alias when a chapter already links to index.html. Fixes#2883.
parse_quoted_path now takes the input right after the opening quote,
both callers strip it with strip_prefix. Rewrite the quoted-path tests
as plain assertion tests and drop the noisy banner comments.
Signed-off-by: Alex Chen <l46983284@gmail.com>
A quoted path like " spaces " keeps its whitespace characters
verbatim; nothing is trimmed inside quotes.
Signed-off-by: Alex Chen <l46983284@gmail.com>
- Extract parse_quoted_or_plain to eliminate duplication between
parse_include_path and parse_rustdoc_include_path
- Only \" and \\ are escapes; other \X preserves the backslash
so Windows paths like C:\Users\file.md work correctly
- Remove trim_start inside parse_quoted_path: whitespace inside
quotes is part of the path
- Trailing backslash (\ at end of quoted string) is now an error
- Add 44 architectural, escape-semantics, and cross-platform tests
Signed-off-by: Alex Chen <l46983284@gmail.com>
Require double quotes for file paths containing spaces across
include, rustdoc_include, and playground directives. Preserve full
backwards compatibility for unquoted paths without spaces, and
support escaped quotes inside paths.
Signed-off-by: Alex Chen <l46983284@gmail.com>
Parse the full include/rustdoc_include target instead of splitting on
whitespace, so paths like `fila a.md` work. Line ranges still work
(`fila a.md:1:2`). Playground links keep whitespace-separated properties.
Fixes#2812.
Signed-off-by: Alex Chen <l46983284@gmail.com>