Merge pull request #2951 from ehuss/fa-improvements
Font Awesome fixes and improvements
This commit is contained in:
commit
8385e750ec
7 changed files with 17 additions and 14 deletions
|
|
@ -75,7 +75,7 @@ The following is a summary of the changes that may require your attention when u
|
||||||
|
|
||||||
- Updated to a newer version of `pulldown-cmark`. This brings a large number of fixes to markdown processing.
|
- Updated to a newer version of `pulldown-cmark`. This brings a large number of fixes to markdown processing.
|
||||||
[#2401](https://github.com/rust-lang/mdBook/pull/2401)
|
[#2401](https://github.com/rust-lang/mdBook/pull/2401)
|
||||||
- The font-awesome font is no longer loaded as a font. Instead, the corresponding SVG is embedded in the output for the corresponding `<i>` tags. Additionally, a handlebars helper has been added for the `hbs` files.
|
- The font-awesome font is no longer loaded as a font. Instead, the corresponding SVG is embedded in the output for the corresponding `<i>` tags. Additionally, a handlebars helper has been added for the `hbs` files. This also updates the version from 4.7.0 to 6.2.0, which means some of the icon names and styles have changed. Most of the free icons are in the "solid" set. See the [free icon set](https://fontawesome.com/v6/search) for the available icons.
|
||||||
[#1330](https://github.com/rust-lang/mdBook/pull/1330)
|
[#1330](https://github.com/rust-lang/mdBook/pull/1330)
|
||||||
- Changed all internal HTML IDs to have an `mdbook-` prefix. This helps avoid namespace conflicts with header IDs.
|
- Changed all internal HTML IDs to have an `mdbook-` prefix. This helps avoid namespace conflicts with header IDs.
|
||||||
[#2808](https://github.com/rust-lang/mdBook/pull/2808)
|
[#2808](https://github.com/rust-lang/mdBook/pull/2808)
|
||||||
|
|
|
||||||
|
|
@ -1030,14 +1030,14 @@ where
|
||||||
let i_el = node.value().as_element().unwrap();
|
let i_el = node.value().as_element().unwrap();
|
||||||
let classes = i_el.attr("class").unwrap_or_default();
|
let classes = i_el.attr("class").unwrap_or_default();
|
||||||
for class in classes.split(" ") {
|
for class in classes.split(" ") {
|
||||||
if let Some(class) = class.strip_prefix("fa-") {
|
if matches!(class, "fa" | "fa-regular") {
|
||||||
icon = class.to_owned();
|
|
||||||
} else if class == "fa" {
|
|
||||||
type_ = fa::Type::Regular;
|
type_ = fa::Type::Regular;
|
||||||
} else if class == "fas" {
|
} else if matches!(class, "fas" | "fa-solid") {
|
||||||
type_ = fa::Type::Solid;
|
type_ = fa::Type::Solid;
|
||||||
} else if class == "fab" {
|
} else if matches!(class, "fab" | "fa-brands") {
|
||||||
type_ = fa::Type::Brands;
|
type_ = fa::Type::Brands;
|
||||||
|
} else if let Some(class) = class.strip_prefix("fa-") {
|
||||||
|
icon = class.to_owned();
|
||||||
} else {
|
} else {
|
||||||
new_classes += " ";
|
new_classes += " ";
|
||||||
new_classes += class;
|
new_classes += class;
|
||||||
|
|
|
||||||
|
|
@ -143,9 +143,7 @@ The following configuration options are available:
|
||||||
those labels. Defaults to `false`.
|
those labels. Defaults to `false`.
|
||||||
- **git-repository-url:** A url to the git repository for the book. If provided
|
- **git-repository-url:** A url to the git repository for the book. If provided
|
||||||
an icon link will be output in the menu bar of the book.
|
an icon link will be output in the menu bar of the book.
|
||||||
- **git-repository-icon:** The FontAwesome icon class to use for the git
|
- **git-repository-icon:** The Font Awesome icon class to use for the git repository link. Defaults to `fab-github` which looks like <i class="fab fa-github"></i>. If you are not using GitHub, another option to consider is `fas-code-fork` which looks like <i class="fas fa-code-fork"></i>. The start of the string should be `fa-` for regular icons, `fas-` for solid icons, or `fab-` for brand icons. See the [free icon set](https://fontawesome.com/v6/search) for the available icons.
|
||||||
repository link. Defaults to `fab-github` which looks like <i class="fa fab-github"></i>.
|
|
||||||
If you are not using GitHub, another option to consider is `fa-code-fork` which looks like <i class="fas fa-code-fork"></i>.
|
|
||||||
- **edit-url-template:** Edit url template, when provided shows a
|
- **edit-url-template:** Edit url template, when provided shows a
|
||||||
"Suggest an edit" button (which looks like <i class="fas fa-pencil"></i>) for directly jumping to editing the currently
|
"Suggest an edit" button (which looks like <i class="fas fa-pencil"></i>) for directly jumping to editing the currently
|
||||||
viewed page. For e.g. GitHub projects set this to
|
viewed page. For e.g. GitHub projects set this to
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ HTML tags with class `hidden` will not be shown.
|
||||||
|
|
||||||
## Font-Awesome icons
|
## Font-Awesome icons
|
||||||
|
|
||||||
mdBook includes a copy of [Font Awesome Free's](https://fontawesome.com)
|
mdBook includes a copy of version 6 of [Font Awesome Free's](https://fontawesome.com)
|
||||||
MIT-licensed SVG files. It emulates the `<i>` syntax, but converts the results
|
MIT-licensed SVG files. It emulates the `<i>` syntax, but converts the results
|
||||||
to inline SVG. Only the regular, solid, and brands icons are included; paid
|
to inline SVG. Only the regular, solid, and brands icons are included; paid
|
||||||
features like the light icons are not.
|
features like the light icons are not.
|
||||||
|
|
@ -348,7 +348,9 @@ features like the light icons are not.
|
||||||
For example, given this HTML syntax:
|
For example, given this HTML syntax:
|
||||||
|
|
||||||
```hbs
|
```hbs
|
||||||
The result looks like this: <i class="fas fa-print"></i>
|
The result looks like this: <i class="fa-solid fa-print"></i>
|
||||||
```
|
```
|
||||||
|
|
||||||
The result looks like this: <i class="fas fa-print"></i>
|
The result looks like this: <i class="fa-solid fa-print"></i>
|
||||||
|
|
||||||
|
See the [free icon set](https://fontawesome.com/v6/search) for the available icons.
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ MIT-licensed SVG files. It accepts three positional arguments:
|
||||||
1. Type: one of "solid", "regular", and "brands" (light and duotone are not
|
1. Type: one of "solid", "regular", and "brands" (light and duotone are not
|
||||||
currently supported)
|
currently supported)
|
||||||
2. Icon: anything chosen from the
|
2. Icon: anything chosen from the
|
||||||
[free icon set](https://fontawesome.com/icons?d=gallery&m=free)
|
[free icon set](https://fontawesome.com/v6/search)
|
||||||
3. ID (optional): if included, an HTML ID attribute will be added to the
|
3. ID (optional): if included, an HTML ID attribute will be added to the
|
||||||
icon's wrapping `<span>` tag
|
icon's wrapping `<span>` tag
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@
|
||||||
<p><span class="fa-svg"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d="M272 304h-96C78.8 304 0 382.8 0 480c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32C448 382.8 369.2 304 272 304zM48.99 464C56.89 400.9 110.8 352 176 352h96c65.16 0 119.1 48.95 127 112H48.99zM224 256c70.69 0 128-57.31 128-128c0-70.69-57.31-128-128-128S96 57.31 96 128C96 198.7 153.3 256 224 256zM224 48c44.11 0 80 35.89 80 80c0 44.11-35.89 80-80 80S144 172.1 144 128C144 83.89 179.9 48 224 48z"/></svg></span></p>
|
<p><span class="fa-svg"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d="M272 304h-96C78.8 304 0 382.8 0 480c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32C448 382.8 369.2 304 272 304zM48.99 464C56.89 400.9 110.8 352 176 352h96c65.16 0 119.1 48.95 127 112H48.99zM224 256c70.69 0 128-57.31 128-128c0-70.69-57.31-128-128-128S96 57.31 96 128C96 198.7 153.3 256 224 256zM224 48c44.11 0 80 35.89 80 80c0 44.11-35.89 80-80 80S144 172.1 144 128C144 83.89 179.9 48 224 48z"/></svg></span></p>
|
||||||
<p><span class="fa-svg"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d="M448 48V384C385 407 366 416 329 416C266 416 242 384 179 384C159 384 143 388 128 392V328C143 324 159 320 179 320C242 320 266 352 329 352C349 352 364 349 384 343V135C364 141 349 144 329 144C266 144 242 112 179 112C128 112 104 133 64 141V448C64 466 50 480 32 480S0 466 0 448V64C0 46 14 32 32 32S64 46 64 64V77C104 69 128 48 179 48C242 48 266 80 329 80C366 80 385 71 448 48Z"/></svg></span></p>
|
<p><span class="fa-svg"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d="M448 48V384C385 407 366 416 329 416C266 416 242 384 179 384C159 384 143 388 128 392V328C143 324 159 320 179 320C242 320 266 352 329 352C349 352 364 349 384 343V135C364 141 349 144 329 144C266 144 242 112 179 112C128 112 104 133 64 141V448C64 466 50 480 32 480S0 466 0 448V64C0 46 14 32 32 32S64 46 64 64V77C104 69 128 48 179 48C242 48 266 80 329 80C366 80 385 71 448 48Z"/></svg></span></p>
|
||||||
<p><i class="fas fa-heart">Text prevents translation.</i></p>
|
<p><i class="fas fa-heart">Text prevents translation.</i></p>
|
||||||
<p><i class="fa fa-does-not-exist"></i></p>
|
<p><i class="fa fa-does-not-exist"></i></p>
|
||||||
|
<p><span class="fa-svg"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d="M288 192h17.1c22.1 38.3 63.5 64 110.9 64c11 0 21.8-1.4 32-4v4 32V480c0 17.7-14.3 32-32 32s-32-14.3-32-32V339.2L248 448h56c17.7 0 32 14.3 32 32s-14.3 32-32 32H160c-53 0-96-43-96-96V192.5c0-16.1-12-29.8-28-31.8l-7.9-1C10.5 157.6-1.9 141.6 .2 124s18.2-30 35.7-27.8l7.9 1c48 6 84.1 46.8 84.1 95.3v85.3c34.4-51.7 93.2-85.8 160-85.8zm160 26.5v0c-10 3.5-20.8 5.5-32 5.5c-28.4 0-54-12.4-71.6-32h0c-3.7-4.1-7-8.5-9.9-13.2C325.3 164 320 146.6 320 128v0V32 12 10.7C320 4.8 324.7 .1 330.6 0h.2c3.3 0 6.4 1.6 8.4 4.2l0 .1L352 21.3l27.2 36.3L384 64h64l4.8-6.4L480 21.3 492.8 4.3l0-.1c2-2.6 5.1-4.2 8.4-4.2h.2C507.3 .1 512 4.8 512 10.7V12 32v96c0 17.3-4.6 33.6-12.6 47.6c-11.3 19.8-29.6 35.2-51.4 42.9zM400 128c0-8.8-7.2-16-16-16s-16 7.2-16 16s7.2 16 16 16s16-7.2 16-16zm48 16c8.8 0 16-7.2 16-16s-7.2-16-16-16s-16 7.2-16 16s7.2 16 16 16z"/></svg></span></p>
|
||||||
|
|
@ -9,3 +9,5 @@
|
||||||
<i class="fas fa-heart">Text prevents translation.</i>
|
<i class="fas fa-heart">Text prevents translation.</i>
|
||||||
|
|
||||||
<i class="fa fa-does-not-exist"></i>
|
<i class="fa fa-does-not-exist"></i>
|
||||||
|
|
||||||
|
<i class="fa-solid fa-cat"></i>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue