Skip to content

Commit

Permalink
feat: add width for html
Browse files Browse the repository at this point in the history
  • Loading branch information
Its-Just-Nans committed Jan 26, 2024
1 parent 120a36c commit d644c5b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ pub fn format_document_with_plugins<'a>(
output: &mut dyn Write,
plugins: &Plugins,
) -> io::Result<()> {
if options.render.width > 0 {
output.write_all(b"<!DOCTYPE html>\n")?;
output.write_all(b"<html>\n<head> <meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"></head>")?;
let body_tag = format!(
"<body style=\"width: {}%; margin: auto\">",
options.render.width
);
output.write_all(body_tag.as_bytes())?;
}
let mut writer = WriteWithLast {
output,
last_was_lf: Cell::new(true),
Expand All @@ -40,6 +49,10 @@ pub fn format_document_with_plugins<'a>(
if f.footnote_ix > 0 {
f.output.write_all(b"</ol>\n</section>\n")?;
}
if options.render.width > 0 {
output.write_all(b"</body>\n")?;
output.write_all(b"</html>\n")?;
}
Ok(())
}

Expand Down

0 comments on commit d644c5b

Please sign in to comment.