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]]
name = "snekdown"
version = "0.22.1"
version = "0.22.2"
dependencies = [
"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)",

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

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

Loading…
Cancel
Save