Make Markdown previews sans-serif on principle

main
_ 2020-11-10 03:01:00 +00:00
parent ff6e841e0b
commit b333b56e80
5 changed files with 12 additions and 9 deletions

1
.gitignore vendored
View File

@ -5,5 +5,4 @@
/ptth_relay.toml
/ptth_build_L6KLMVS6/
/target
/test

View File

@ -235,7 +235,7 @@ async fn serve_root (
fn serve_html (s: String) -> Response {
let mut resp = Response::default ();
resp
.header ("content-type".to_string (), "text/html".to_string ().into_bytes ())
.header ("content-type".to_string (), "text/html; charset=UTF-8".to_string ().into_bytes ())
.body_bytes (s.into_bytes ())
;
resp
@ -394,10 +394,13 @@ fn render_markdown (bytes: &[u8]) -> Result <String, MarkdownError> {
let parser = Parser::new_ext (markdown_input, options);
// Write to String buffer.
let mut html_output = String::new ();
html::push_html (&mut html_output, parser);
let mut out = String::new ();
Ok (html_output)
out.push_str ("<body style=\"font-family: sans-serif;\">");
html::push_html (&mut out, parser);
out.push_str ("</body>");
Ok (out)
}
// Sort of an internal API endpoint to make testing work better.
@ -809,13 +812,12 @@ mod tests {
range_requested: false,
file: AlwaysEqual::testing_blank (),
})),
("/files/test.md", ServeFile (ServeFileParams {
("/files/test/test.md", ServeFile (ServeFileParams {
send_body: true,
range: 0..117,
range: 0..144,
range_requested: false,
file: AlwaysEqual::testing_blank (),
})),
("/files/test.md?as_markdown", MarkdownPreview ("<h1>Markdown test</h1>\n<p>This is a test file for the Markdown previewing feature.</p>\n<p>Don\'t change it, it will break the tests.</p>\n".into ())),
("/ ", InvalidUri),
].into_iter () {
let resp = internal_serve_all (

BIN
test/face.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -3,3 +3,5 @@
This is a test file for the Markdown previewing feature.
Don't change it, it will break the tests.
![A silly face](face.png)

View File

@ -1,4 +1,4 @@
- "Preview as" feature for Markdown / pretty-printed logs
- "Preview as" feature for Markdown (It's not threaded through the relay yet)
- Make a debug client to replicate the issue Firefox is having with turtling
- Add Prometheus metrics
- Not working great behind reverse proxies