Provide a runnable local Beta and fix multi-page SVG previews
This commit is contained in:
1 parent
fb557c09c6
commit
9841e88900
7 files changed
+324
-9
No files matched your search
@@ -625,7 +625,7 @@ impl DisplayList {
|
||||
write!(
|
||||
out,
|
||||
"<g data-font=\"{}\" data-glyph=\"{}\" data-slot=\"{slot}\" aria-label=\"{}\"><path d=\"{}\" transform=\"",
|
||||
escape(font), escape(glyph), escape(&label), path,
|
||||
escape_attribute(font), escape_attribute(glyph), escape_attribute(&label), path,
|
||||
).unwrap();
|
||||
if let Some([vx2, vy]) = vertical_origin {
|
||||
let vx = f64::from(vx2) / 2.0;
|
||||
@@ -680,7 +680,7 @@ impl DisplayList {
|
||||
write!(
|
||||
out,
|
||||
"<g data-font=\"{}\" data-glyph=\"{glyph}\" aria-label=\"{}\"><path d=\"{path}\" transform=\"translate({x:.5} {y:.5})",
|
||||
escape(&font.name), escape(text),
|
||||
escape_attribute(&font.name), escape_attribute(text),
|
||||
).unwrap();
|
||||
if transform.is_none() {
|
||||
if let Some([a, b, c, d, e, f]) = vertical {
|
||||
@@ -733,7 +733,7 @@ impl DisplayList {
|
||||
let scale = *size as f64 / 65_536_000.0;
|
||||
out.push_str(&format!(
|
||||
"<g data-font=\"{}\" data-slot=\"{slot}\" aria-label=\"{}\"><use href=\"#math-{}-{slot}\" transform=\"translate({x:.5} {y:.5}) scale({scale:.8} -{scale:.8})\" fill=\"#{:02x}{:02x}{:02x}\"{fill_opacity}/><text x=\"{x:.5}\" y=\"{y:.5}\" opacity=\"0\" aria-hidden=\"true\">{}</text></g>\n",
|
||||
face.name(), escape(&character.to_string()), face.0,
|
||||
escape_attribute(face.name()), escape_attribute(&character.to_string()), face.0,
|
||||
fill[0], fill[1], fill[2], escape(&character.to_string())
|
||||
));
|
||||
}
|
||||
@@ -1083,6 +1083,15 @@ fn base64(data: &[u8]) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
fn escape_attribute(text: &str) -> String {
|
||||
let escaped = escape(text);
|
||||
if text.contains('"') {
|
||||
escaped.replace('"', """)
|
||||
} else {
|
||||
escaped
|
||||
}
|
||||
}
|
||||
|
||||
fn escape(text: &str) -> String {
|
||||
text.replace('&', "&")
|
||||
.replace('<', "<")
|
||||
|
||||
Reference in new issue
Block a user