diff --git a/.github/workflows/contrib.yml b/.github/workflows/contrib.yml index 1872ae11c..ee1529194 100644 --- a/.github/workflows/contrib.yml +++ b/.github/workflows/contrib.yml @@ -19,7 +19,7 @@ jobs: - name: Install mdbook run: | mkdir mdbook - curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.9/mdbook-v0.4.9-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook + curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.26/mdbook-v0.4.26-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook echo `pwd`/mdbook >> $GITHUB_PATH - name: Deploy docs run: | diff --git a/crates/mdman/Cargo.lock b/crates/mdman/Cargo.lock index bb67460dd..2ce8af0d1 100644 --- a/crates/mdman/Cargo.lock +++ b/crates/mdman/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ansi_term" version = "0.11.0" diff --git a/crates/mdman/src/format/man.rs b/crates/mdman/src/format/man.rs index 5df817871..9767fdd51 100644 --- a/crates/mdman/src/format/man.rs +++ b/crates/mdman/src/format/man.rs @@ -400,12 +400,20 @@ impl<'e> ManRenderer<'e> { } fn escape(s: &str) -> Result { + // Note: Possible source on output escape sequences: https://man7.org/linux/man-pages/man7/groff_char.7.html. + // Otherwise, use generic escaping in the form `\[u1EE7]` or `\[u1F994]`. + let mut replaced = s .replace('\\', "\\(rs") .replace('-', "\\-") .replace('\u{00A0}', "\\ ") // non-breaking space (non-stretchable) .replace('–', "\\[en]") // \u{2013} en-dash .replace('—', "\\[em]") // \u{2014} em-dash + .replace('‘', "\\[oq]") // \u{2018} left single quote + .replace('’', "\\[cq]") // \u{2019} right single quote or apostrophe + .replace('“', "\\[lq]") // \u{201C} left double quote + .replace('”', "\\[rq]") // \u{201D} right double quote + .replace('…', "\\[u2026]") // \u{2026} ellipsis .replace('│', "|") // \u{2502} box drawing light vertical (could use \[br]) .replace('├', "|") // \u{251C} box drawings light vertical and right .replace('└', "`") // \u{2514} box drawings light up and right @@ -413,8 +421,6 @@ fn escape(s: &str) -> Result { ; if replaced.starts_with('.') { replaced = format!("\\&.{}", &replaced[1..]); - } else if replaced.starts_with('\'') { - replaced = format!("\\(aq{}", &replaced[1..]); } if let Some(ch) = replaced.chars().find(|ch| { diff --git a/crates/mdman/src/lib.rs b/crates/mdman/src/lib.rs index 0b17be590..01c3c8d31 100644 --- a/crates/mdman/src/lib.rs +++ b/crates/mdman/src/lib.rs @@ -69,6 +69,7 @@ pub(crate) fn md_parser(input: &str, url: Option) -> EventIter { options.insert(Options::ENABLE_TABLES); options.insert(Options::ENABLE_FOOTNOTES); options.insert(Options::ENABLE_STRIKETHROUGH); + options.insert(Options::ENABLE_SMART_PUNCTUATION); let parser = Parser::new_ext(input, options); let parser = parser.into_offset_iter(); // Translate all links to include the base url. diff --git a/crates/mdman/tests/compare/expected/formatting.1 b/crates/mdman/tests/compare/expected/formatting.1 index 120859287..076c5135a 100644 --- a/crates/mdman/tests/compare/expected/formatting.1 +++ b/crates/mdman/tests/compare/expected/formatting.1 @@ -66,7 +66,7 @@ With a second paragraph inside it .sp .RS 4 \h'-04'\(bu\h'+02'Milk -5. Don't start at one. +5. Don\[cq]t start at one. 6. tamarind .RE .RE diff --git a/crates/mdman/tests/compare/expected/formatting.txt b/crates/mdman/tests/compare/expected/formatting.txt index 87bbb87dc..face4a3cc 100644 --- a/crates/mdman/tests/compare/expected/formatting.txt +++ b/crates/mdman/tests/compare/expected/formatting.txt @@ -43,7 +43,7 @@ LISTS o Eggs - o Milk 5. Don't start at one. 6. tamarind + o Milk 5. Don’t start at one. 6. tamarind 2. Second element diff --git a/crates/mdman/tests/compare/expected/options.1 b/crates/mdman/tests/compare/expected/options.1 index 2d75cd25e..d362421e9 100644 --- a/crates/mdman/tests/compare/expected/options.1 +++ b/crates/mdman/tests/compare/expected/options.1 @@ -12,7 +12,7 @@ my\-command \- A brief description .br \fBmy\-command\fR (\fB\-m\fR | \fB\-M\fR) [\fIoldbranch\fR] \fInewbranch\fR .br -\fBmy\-command\fR (\fB\-d\fR | \fB\-D\fR) [\fB\-r\fR] \fIbranchname\fR\&... +\fBmy\-command\fR (\fB\-d\fR | \fB\-D\fR) [\fB\-r\fR] \fIbranchname\fR\[u2026] .SH "DESCRIPTION" A description of the command. .sp @@ -49,7 +49,7 @@ Demo \fIemphasis\fR, \fBstrong\fR, ~~strike~~ This has multiple flags. .RE .sp -\fInamed\-arg...\fR +\fInamed\-arg\[u2026]\fR .RS 4 A named argument. .RE diff --git a/crates/mdman/tests/compare/expected/options.md b/crates/mdman/tests/compare/expected/options.md index d8b8276f6..19b0b443b 100644 --- a/crates/mdman/tests/compare/expected/options.md +++ b/crates/mdman/tests/compare/expected/options.md @@ -37,7 +37,7 @@ A description of the command.
This has multiple flags.
-
named-arg...
+
named-arg…
A named argument.
diff --git a/crates/mdman/tests/compare/expected/options.txt b/crates/mdman/tests/compare/expected/options.txt index 32ccfd249..9bfdec67c 100644 --- a/crates/mdman/tests/compare/expected/options.txt +++ b/crates/mdman/tests/compare/expected/options.txt @@ -7,7 +7,7 @@ SYNOPSIS my-command [--abc | --xyz] name my-command [-f file] my-command (-m | -M) [oldbranch] newbranch - my-command (-d | -D) [-r] branchname... + my-command (-d | -D) [-r] branchname… DESCRIPTION A description of the command. @@ -29,7 +29,7 @@ OPTIONS -p spec, --package spec This has multiple flags. - named-arg... + named-arg… A named argument. Common Options diff --git a/src/doc/book.toml b/src/doc/book.toml index fdbba067e..1dd1f8e0f 100644 --- a/src/doc/book.toml +++ b/src/doc/book.toml @@ -3,5 +3,6 @@ title = "The Cargo Book" author = "Alex Crichton, Steve Klabnik and Carol Nichols, with contributions from the Rust community" [output.html] +curly-quotes = true # Enable smart-punctuation feature for more than quotes. git-repository-url = "https://github.com/rust-lang/cargo/tree/master/src/doc/src" edit-url-template = "https://github.com/rust-lang/cargo/edit/master/src/doc/{path}" diff --git a/src/doc/contrib/book.toml b/src/doc/contrib/book.toml index 543d58576..d6697f37f 100644 --- a/src/doc/contrib/book.toml +++ b/src/doc/contrib/book.toml @@ -3,6 +3,7 @@ title = "Cargo Contributor Guide" authors = ["Eric Huss"] [output.html] +curly-quotes = true # Enable smart-punctuation feature for more than quotes. git-repository-url = "https://github.com/rust-lang/cargo/tree/master/src/doc/contrib/src" [output.html.redirect]