Support `text_direction` attribute in HTML output
This commit is contained in:
parent
819a108f07
commit
7717b9dcf2
|
@ -648,6 +648,10 @@ fn make_data(
|
|||
"language".to_owned(),
|
||||
json!(config.book.language.clone().unwrap_or_default()),
|
||||
);
|
||||
data.insert(
|
||||
"text_direction".to_owned(),
|
||||
json!(config.book.realized_text_direction()),
|
||||
);
|
||||
data.insert(
|
||||
"book_title".to_owned(),
|
||||
json!(config.book.title.clone().unwrap_or_default()),
|
||||
|
@ -1088,6 +1092,8 @@ struct RenderItemContext<'a> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::config::TextDirection;
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
|
@ -1299,4 +1305,10 @@ mod tests {
|
|||
assert_eq!(&*got, *should_be);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_json_direction() {
|
||||
assert_eq!(json!(TextDirection::RightToLeft), json!("rtl"));
|
||||
assert_eq!(json!(TextDirection::LeftToRight), json!("ltr"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="{{ language }}" class="{{ default_theme }}">
|
||||
<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}">
|
||||
<head>
|
||||
<!-- Book generated using mdBook -->
|
||||
<meta charset="UTF-8">
|
||||
|
|
Loading…
Reference in New Issue