mirror of https://github.com/Nutomic/ibis.git
Fix math parsing (#68)
* Updates version? * Adds Display mode after whitespace for LaTex Includes fonts directory in binaries Removed unecessary font types (kept .woff2) * Woodpecker checks Removed debug print statement for equations * Use `ok_or` instead of `if let` Co-authored-by: Nutomic <me@nutomic.com> * Adds font_dir variable back --------- Co-authored-by: Bintou Ali <bintou005@protonmail.com> Co-authored-by: Nutomic <me@nutomic.com>
This commit is contained in:
parent
6235349b52
commit
a38c4a3e5e
|
@ -1726,6 +1726,7 @@ dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
"hex",
|
"hex",
|
||||||
|
"include_dir",
|
||||||
"jsonwebtoken",
|
"jsonwebtoken",
|
||||||
"katex",
|
"katex",
|
||||||
"leptos",
|
"leptos",
|
||||||
|
@ -1780,6 +1781,25 @@ dependencies = [
|
||||||
"unicode-normalization",
|
"unicode-normalization",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "include_dir"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd"
|
||||||
|
dependencies = [
|
||||||
|
"include_dir_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "include_dir_macros"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.2.3"
|
version = "2.2.3"
|
||||||
|
|
|
@ -80,6 +80,7 @@ doku = "0.21.1"
|
||||||
smart-default = "0.7.1"
|
smart-default = "0.7.1"
|
||||||
tower-layer = "0.3.3"
|
tower-layer = "0.3.3"
|
||||||
katex = { version = "0.4", default-features = false }
|
katex = { version = "0.4", default-features = false }
|
||||||
|
include_dir = "0.7.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.4.1"
|
pretty_assertions = "1.4.1"
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8,6 +8,7 @@ use axum::{
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use axum_macros::debug_handler;
|
use axum_macros::debug_handler;
|
||||||
|
use include_dir::include_dir;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use reqwest::header::HeaderMap;
|
use reqwest::header::HeaderMap;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
|
@ -72,16 +73,7 @@ async fn serve_wasm() -> MyResult<impl IntoResponse> {
|
||||||
#[debug_handler]
|
#[debug_handler]
|
||||||
async fn get_font(Path(font): Path<String>) -> MyResult<impl IntoResponse> {
|
async fn get_font(Path(font): Path<String>) -> MyResult<impl IntoResponse> {
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
let content_type = if font.ends_with(".ttf") {
|
let font_dir = include_dir!("assets/fonts");
|
||||||
"font/ttf"
|
let file = font_dir.get_file(font).ok_or(anyhow!("invalid font"))?;
|
||||||
} else if font.ends_with(".woff") {
|
Ok((headers, file.contents()))
|
||||||
"font/woff"
|
|
||||||
} else if font.ends_with(".woff2") {
|
|
||||||
"font/woff2"
|
|
||||||
} else {
|
|
||||||
return Err(anyhow!("invalid font").into());
|
|
||||||
};
|
|
||||||
headers.insert("Content-type", content_type.parse()?);
|
|
||||||
let content = std::fs::read("assets/fonts/".to_owned() + &font)?;
|
|
||||||
Ok((headers, content))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ impl InlineRule for MathEquationScanner {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut display_mode = false;
|
let mut display_mode = false;
|
||||||
if input.starts_with("$$\n") {
|
if input.starts_with("$$\n") || input.starts_with("$$ ") {
|
||||||
display_mode = true;
|
display_mode = true;
|
||||||
}
|
}
|
||||||
const SEPARATOR_LENGTH: usize = 2;
|
const SEPARATOR_LENGTH: usize = 2;
|
||||||
|
|
Loading…
Reference in New Issue