1pub const CONSOLE_SVG_FORMAT: &str = r#"<svg class="rich-terminal" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
26 <!-- Generated with Rich-rs https://github.com/Textualize/rich -->
27 <style>
28
29 @font-face {
30 font-family: "Fira Code";
31 src: local("FiraCode-Regular"),
32 url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
33 url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
34 font-style: normal;
35 font-weight: 400;
36 }
37 @font-face {
38 font-family: "Fira Code";
39 src: local("FiraCode-Bold"),
40 url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
41 url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
42 font-style: bold;
43 font-weight: 700;
44 }
45
46 .{unique_id}-matrix {
47 font-family: Fira Code, monospace;
48 font-size: {char_height}px;
49 line-height: {line_height}px;
50 font-variant-east-asian: full-width;
51 }
52
53 .{unique_id}-title {
54 font-size: 18px;
55 font-weight: bold;
56 font-family: arial;
57 }
58
59 {styles}
60 </style>
61
62 <defs>
63 <clipPath id="{unique_id}-clip-terminal">
64 <rect x="0" y="0" width="{terminal_width}" height="{terminal_height}" />
65 </clipPath>
66 {lines}
67 </defs>
68
69 {chrome}
70 <g transform="translate({terminal_x}, {terminal_y})" clip-path="url(#{unique_id}-clip-terminal)">
71 {backgrounds}
72 <g class="{unique_id}-matrix">
73 {matrix}
74 </g>
75 </g>
76</svg>
77"#;
78
79pub const CONSOLE_HTML_FORMAT: &str = r#"<!DOCTYPE html>
88<html>
89<head>
90<meta charset="UTF-8">
91<style>
92{stylesheet}
93body {
94 color: {foreground};
95 background-color: {background};
96}
97</style>
98</head>
99<body>
100 <pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code style="font-family:inherit">{code}</code></pre>
101</body>
102</html>
103"#;
104
105#[cfg(test)]
106mod tests {
107 use super::*;
108
109 #[test]
110 fn test_svg_format_contains_placeholders() {
111 assert!(CONSOLE_SVG_FORMAT.contains("{unique_id}"));
112 assert!(CONSOLE_SVG_FORMAT.contains("{width}"));
113 assert!(CONSOLE_SVG_FORMAT.contains("{height}"));
114 assert!(CONSOLE_SVG_FORMAT.contains("{styles}"));
115 assert!(CONSOLE_SVG_FORMAT.contains("{chrome}"));
116 assert!(CONSOLE_SVG_FORMAT.contains("{matrix}"));
117 }
118
119 #[test]
120 fn test_html_format_contains_placeholders() {
121 assert!(CONSOLE_HTML_FORMAT.contains("{stylesheet}"));
122 assert!(CONSOLE_HTML_FORMAT.contains("{foreground}"));
123 assert!(CONSOLE_HTML_FORMAT.contains("{background}"));
124 assert!(CONSOLE_HTML_FORMAT.contains("{code}"));
125 }
126}