mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-12 13:52:36 +00:00
Some minor corrections from code review.
This commit is contained in:
parent
8564a7fb51
commit
4749f9d97a
2 changed files with 5 additions and 5 deletions
|
@ -48,7 +48,7 @@ This is general information about your book.
|
|||
- **language:** The main language of the book, which is used as a language attribute `<html lang="en">` for example.
|
||||
This is also used to derive the direction of text (RTL, LTR) within the book.
|
||||
- **text_direction**: The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL). Possible values: `ltr`, `rtl`.
|
||||
When not specified, the correct text direction is derived from the book's `language` attribute.
|
||||
When not specified, the text direction is derived from the book's `language` attribute.
|
||||
|
||||
**book.toml**
|
||||
```toml
|
||||
|
|
|
@ -412,7 +412,7 @@ pub struct BookConfig {
|
|||
/// The main language of the book.
|
||||
pub language: Option<String>,
|
||||
/// The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL).
|
||||
/// When not specified, the correct text direction is derived from [BookConfig::language].
|
||||
/// When not specified, the text direction is derived from [`BookConfig::language`].
|
||||
pub text_direction: Option<TextDirection>,
|
||||
}
|
||||
|
||||
|
@ -431,13 +431,13 @@ impl Default for BookConfig {
|
|||
}
|
||||
|
||||
impl BookConfig {
|
||||
/// Gets the realized text direction, either from [BookConfig::text_direction]
|
||||
/// or derived from [BookConfig::language], to be used by templating engines.
|
||||
/// Gets the realized text direction, either from [`BookConfig::text_direction`]
|
||||
/// or derived from [`BookConfig::language`], to be used by templating engines.
|
||||
pub fn realized_text_direction(&self) -> TextDirection {
|
||||
if let Some(direction) = self.text_direction {
|
||||
direction
|
||||
} else {
|
||||
TextDirection::from_lang_code(&self.language.clone().unwrap_or_default())
|
||||
TextDirection::from_lang_code(self.language.as_deref().unwrap_or_default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue