#[derive(Debug, Clone, Default)]
pub struct HtmlExportOptions {
pub inline_styles: bool,
pub clear: bool,
pub font_family: Option<String>,
pub font_url: Option<String>,
pub dark_mode: bool,
pub copy_button: bool,
pub code_format: Option<String>,
}
impl HtmlExportOptions {
#[must_use]
pub fn inline_styles(mut self, v: bool) -> Self {
self.inline_styles = v;
self
}
#[must_use]
pub fn clear(mut self, v: bool) -> Self {
self.clear = v;
self
}
#[must_use]
pub fn font_family(mut self, v: impl Into<String>) -> Self {
self.font_family = Some(v.into());
self
}
#[must_use]
pub fn font_url(mut self, v: impl Into<String>) -> Self {
self.font_url = Some(v.into());
self
}
#[must_use]
pub fn dark_mode(mut self, v: bool) -> Self {
self.dark_mode = v;
self
}
#[must_use]
pub fn copy_button(mut self, v: bool) -> Self {
self.copy_button = v;
self
}
#[must_use]
pub fn code_format(mut self, v: impl Into<String>) -> Self {
self.code_format = Some(v.into());
self
}
}
#[derive(Debug, Clone)]
pub enum FontEmbedding {
None,
Base64(Vec<u8>),
}
#[derive(Debug, Clone)]
pub struct SvgExportOptions {
pub title: String,
pub font_embedding: FontEmbedding,
pub clear: bool,
pub unique_id: Option<String>,
pub font_aspect_ratio: f64,
}
impl Default for SvgExportOptions {
fn default() -> Self {
SvgExportOptions {
title: String::new(),
font_embedding: FontEmbedding::None,
clear: false,
unique_id: None,
font_aspect_ratio: 0.61,
}
}
}
impl SvgExportOptions {
#[must_use]
pub fn title(mut self, v: impl Into<String>) -> Self {
self.title = v.into();
self
}
#[must_use]
pub fn font_embedding(mut self, v: FontEmbedding) -> Self {
self.font_embedding = v;
self
}
#[must_use]
pub fn clear(mut self, v: bool) -> Self {
self.clear = v;
self
}
#[must_use]
pub fn unique_id(mut self, v: impl Into<String>) -> Self {
self.unique_id = Some(v.into());
self
}
#[must_use]
pub fn font_aspect_ratio(mut self, v: f64) -> Self {
self.font_aspect_ratio = v;
self
}
}
pub const CONSOLE_HTML_FORMAT: &str = r##"<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
{stylesheet}
body {
color: {foreground};
background-color: {background};
}
</style>
</head>
<body>
<pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code style="font-family:inherit">{code}</code></pre>
</body>
</html>
"##;
pub const CONSOLE_SVG_FORMAT: &str = r##"<svg class="gilt-terminal" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
<!-- Generated with gilt https://github.com/gilt-rs -->
<style>
@font-face {
font-family: "Fira Code";
src: local("FiraCode-Regular"),
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
font-style: normal;
font-weight: 400;
}
@font-face {
font-family: "Fira Code";
src: local("FiraCode-Bold"),
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
font-style: bold;
font-weight: 700;
}
.{unique_id}-matrix {
font-family: Fira Code, monospace;
font-size: {char_height}px;
line-height: {line_height}px;
font-variant-east-asian: full-width;
}
.{unique_id}-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
{styles}
</style>
<defs>
<clipPath id="{unique_id}-clip-terminal">
<rect x="0" y="0" width="{terminal_width}" height="{terminal_height}" />
</clipPath>
{lines}
</defs>
{chrome}
<g transform="translate({terminal_x}, {terminal_y})" clip-path="url(#{unique_id}-clip-terminal)">
{backgrounds}
<g class="{unique_id}-matrix">
{matrix}
</g>
</g>
</svg>
"##;