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(),
|
"language".to_owned(),
|
||||||
json!(config.book.language.clone().unwrap_or_default()),
|
json!(config.book.language.clone().unwrap_or_default()),
|
||||||
);
|
);
|
||||||
|
data.insert(
|
||||||
|
"text_direction".to_owned(),
|
||||||
|
json!(config.book.realized_text_direction()),
|
||||||
|
);
|
||||||
data.insert(
|
data.insert(
|
||||||
"book_title".to_owned(),
|
"book_title".to_owned(),
|
||||||
json!(config.book.title.clone().unwrap_or_default()),
|
json!(config.book.title.clone().unwrap_or_default()),
|
||||||
|
@ -1088,6 +1092,8 @@ struct RenderItemContext<'a> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::config::TextDirection;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
@ -1299,4 +1305,10 @@ mod tests {
|
||||||
assert_eq!(&*got, *should_be);
|
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>
|
<!DOCTYPE HTML>
|
||||||
<html lang="{{ language }}" class="{{ default_theme }}">
|
<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}">
|
||||||
<head>
|
<head>
|
||||||
<!-- Book generated using mdBook -->
|
<!-- Book generated using mdBook -->
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|
Loading…
Reference in New Issue