Add lang to html tag and charset to head

feature/epub-rendering
trivernis 4 years ago
parent 8fe2c47739
commit 4cce555310

2
Cargo.lock generated

@ -1117,7 +1117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "snekdown" name = "snekdown"
version = "0.22.1" version = "0.22.2"
dependencies = [ dependencies = [
"asciimath-rs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "asciimath-rs 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",

@ -1,6 +1,6 @@
[package] [package]
name = "snekdown" name = "snekdown"
version = "0.22.1" version = "0.22.2"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
license-file = "LICENSE" license-file = "LICENSE"

@ -122,11 +122,17 @@ impl ToHtml for Document {
"".to_string() "".to_string()
}; };
if self.is_root { if self.is_root {
let language = if let Some(entry) = self.config.get_entry("lang") {
entry.get().as_string()
} else {
"en".to_string()
};
let style = minify(std::include_str!("assets/style.css")); let style = minify(std::include_str!("assets/style.css"));
format!( format!(
"<!DOCTYPE html>\ "<!DOCTYPE html>\
<html>\ <html lang={}>\
<head {}>\ <head {}>\
<meta charset='UTF-8'>\
<script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'></script> <script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'></script>
<style>{}</style>\ <style>{}</style>\
{}\ {}\
@ -135,6 +141,7 @@ impl ToHtml for Document {
<div class='content'>{}</div>\ <div class='content'>{}</div>\
</body>\ </body>\
</html>", </html>",
encode_minimal(language.as_str()),
path, style, self.stylesheets.iter().fold("".to_string(), |a, b| format!("{}<style>{}</style>", a, encode_minimal(b))), inner path, style, self.stylesheets.iter().fold("".to_string(), |a, b| format!("{}<style>{}</style>", a, encode_minimal(b))), inner
) )
} else { } else {

Loading…
Cancel
Save