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
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: |

View file

@ -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"

View file

@ -400,12 +400,20 @@ impl<'e> ManRenderer<'e> {
}
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
.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<String, Error> {
;
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| {

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_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.

View file

@ -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

View file

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

View file

@ -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

View file

@ -37,7 +37,7 @@ A description of the command.
<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>

View file

@ -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

View file

@ -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}"

View file

@ -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]