Enable smart punctuation in mdBook.

This commit is contained in:
Enyium 2023-02-12 06:03:25 +01:00
parent 2a4ec9f2f1
commit 0263ef4379
11 changed files with 21 additions and 10 deletions

View File

@ -19,7 +19,7 @@ jobs:
- name: Install mdbook - name: Install mdbook
run: | run: |
mkdir mdbook 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 echo `pwd`/mdbook >> $GITHUB_PATH
- name: Deploy docs - name: Deploy docs
run: | run: |

View File

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.11.0" version = "0.11.0"

View File

@ -400,12 +400,20 @@ impl<'e> ManRenderer<'e> {
} }
fn escape(s: &str) -> Result<String, Error> { fn escape(s: &str) -> Result<String, Error> {
// 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 let mut replaced = s
.replace('\\', "\\(rs") .replace('\\', "\\(rs")
.replace('-', "\\-") .replace('-', "\\-")
.replace('\u{00A0}', "\\ ") // non-breaking space (non-stretchable) .replace('\u{00A0}', "\\ ") // non-breaking space (non-stretchable)
.replace('', "\\[en]") // \u{2013} en-dash .replace('', "\\[en]") // \u{2013} en-dash
.replace('—', "\\[em]") // \u{2014} em-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{2502} box drawing light vertical (could use \[br])
.replace('├', "|") // \u{251C} box drawings light vertical and right .replace('├', "|") // \u{251C} box drawings light vertical and right
.replace('└', "`") // \u{2514} box drawings light up and right .replace('└', "`") // \u{2514} box drawings light up and right
@ -413,8 +421,6 @@ fn escape(s: &str) -> Result<String, Error> {
; ;
if replaced.starts_with('.') { if replaced.starts_with('.') {
replaced = format!("\\&.{}", &replaced[1..]); replaced = format!("\\&.{}", &replaced[1..]);
} else if replaced.starts_with('\'') {
replaced = format!("\\(aq{}", &replaced[1..]);
} }
if let Some(ch) = replaced.chars().find(|ch| { if let Some(ch) = replaced.chars().find(|ch| {

View File

@ -69,6 +69,7 @@ pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter {
options.insert(Options::ENABLE_TABLES); options.insert(Options::ENABLE_TABLES);
options.insert(Options::ENABLE_FOOTNOTES); options.insert(Options::ENABLE_FOOTNOTES);
options.insert(Options::ENABLE_STRIKETHROUGH); options.insert(Options::ENABLE_STRIKETHROUGH);
options.insert(Options::ENABLE_SMART_PUNCTUATION);
let parser = Parser::new_ext(input, options); let parser = Parser::new_ext(input, options);
let parser = parser.into_offset_iter(); let parser = parser.into_offset_iter();
// Translate all links to include the base url. // Translate all links to include the base url.

View File

@ -66,7 +66,7 @@ With a second paragraph inside it
.sp .sp
.RS 4 .RS 4
\h'-04'\(bu\h'+02'Milk \h'-04'\(bu\h'+02'Milk
5. Don't start at one. 5. Don\[cq]t start at one.
6. tamarind 6. tamarind
.RE .RE
.RE .RE

View File

@ -43,7 +43,7 @@ LISTS
o Eggs o Eggs
o Milk 5. Don't start at one. 6. tamarind o Milk 5. Dont start at one. 6. tamarind
2. Second element 2. Second element

View File

@ -12,7 +12,7 @@ my\-command \- A brief description
.br .br
\fBmy\-command\fR (\fB\-m\fR | \fB\-M\fR) [\fIoldbranch\fR] \fInewbranch\fR \fBmy\-command\fR (\fB\-m\fR | \fB\-M\fR) [\fIoldbranch\fR] \fInewbranch\fR
.br .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" .SH "DESCRIPTION"
A description of the command. A description of the command.
.sp .sp
@ -49,7 +49,7 @@ Demo \fIemphasis\fR, \fBstrong\fR, ~~strike~~
This has multiple flags. This has multiple flags.
.RE .RE
.sp .sp
\fInamed\-arg...\fR \fInamed\-arg\[u2026]\fR
.RS 4 .RS 4
A named argument. A named argument.
.RE .RE

View File

@ -37,7 +37,7 @@ A description of the command.
<dd class="option-desc">This has multiple flags.</dd> <dd class="option-desc">This has multiple flags.</dd>
<dt class="option-term" id="option-options-named-arg..."><a class="option-anchor" href="#option-options-named-arg..."></a><em>named-arg...</em></dt> <dt class="option-term" id="option-options-named-arg"><a class="option-anchor" href="#option-options-named-arg…"></a><em>named-arg…</em></dt>
<dd class="option-desc">A named argument.</dd> <dd class="option-desc">A named argument.</dd>

View File

@ -7,7 +7,7 @@ SYNOPSIS
my-command [--abc | --xyz] name my-command [--abc | --xyz] name
my-command [-f file] my-command [-f file]
my-command (-m | -M) [oldbranch] newbranch my-command (-m | -M) [oldbranch] newbranch
my-command (-d | -D) [-r] branchname... my-command (-d | -D) [-r] branchname
DESCRIPTION DESCRIPTION
A description of the command. A description of the command.
@ -29,7 +29,7 @@ OPTIONS
-p spec, --package spec -p spec, --package spec
This has multiple flags. This has multiple flags.
named-arg... named-arg
A named argument. A named argument.
Common Options Common Options

View File

@ -3,5 +3,6 @@ title = "The Cargo Book"
author = "Alex Crichton, Steve Klabnik and Carol Nichols, with contributions from the Rust community" author = "Alex Crichton, Steve Klabnik and Carol Nichols, with contributions from the Rust community"
[output.html] [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" 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}" edit-url-template = "https://github.com/rust-lang/cargo/edit/master/src/doc/{path}"

View File

@ -3,6 +3,7 @@ title = "Cargo Contributor Guide"
authors = ["Eric Huss"] authors = ["Eric Huss"]
[output.html] [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" git-repository-url = "https://github.com/rust-lang/cargo/tree/master/src/doc/contrib/src"
[output.html.redirect] [output.html.redirect]