fix: make css into another file

This commit is contained in:
KyleUltimate 2025-04-28 19:17:48 +08:00
parent 262b2af3e7
commit 8f40a8295b

View File

@ -240,26 +240,37 @@ let originalHeight = {height};
) )
} }
}; };
let html = format!( let style = match self.output_format {
r#" OutputFormat::Pdf => String::new(),
<html> OutputFormat::Html => format!(
"
<head> <head>
<style> <style>
{css} {css}
</style> </style>
</head> </head>
"
),
};
let html = format!(
r"
<html>
{style}
<body> <body>
{html_body} {html_body}
{html_script} {html_script}
</body> </body>
</html>"# </html>"
); );
let html_path = self.content_manager.persist_file("index.html", html.as_bytes())?; let html_path = self.content_manager.persist_file("index.html", html.as_bytes())?;
let css_path = self.content_manager.persist_file("styles.css", css.as_bytes())?;
match self.output_format { match self.output_format {
OutputFormat::Pdf => { OutputFormat::Pdf => {
ThirdPartyTools::weasyprint(&[ ThirdPartyTools::weasyprint(&[
"-s",
css_path.to_string_lossy().as_ref(),
"--presentational-hints", "--presentational-hints",
"-e", "-e",
"utf8", "utf8",