1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-12-25 13:11:24 +00:00

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:
Silver-Sorbet 2024-10-16 14:23:30 +00:00 committed by GitHub
parent 6235349b52
commit a38c4a3e5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 26 additions and 13 deletions

20
Cargo.lock generated
View file

@ -1726,6 +1726,7 @@ dependencies = [
"env_logger",
"futures",
"hex",
"include_dir",
"jsonwebtoken",
"katex",
"leptos",
@ -1780,6 +1781,25 @@ dependencies = [
"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]]
name = "indexmap"
version = "2.2.3"

View file

@ -80,6 +80,7 @@ doku = "0.21.1"
smart-default = "0.7.1"
tower-layer = "0.3.3"
katex = { version = "0.4", default-features = false }
include_dir = "0.7.4"
[dev-dependencies]
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.

View file

@ -8,6 +8,7 @@ use axum::{
Router,
};
use axum_macros::debug_handler;
use include_dir::include_dir;
use once_cell::sync::OnceCell;
use reqwest::header::HeaderMap;
use std::fs::read_to_string;
@ -72,16 +73,7 @@ async fn serve_wasm() -> MyResult<impl IntoResponse> {
#[debug_handler]
async fn get_font(Path(font): Path<String>) -> MyResult<impl IntoResponse> {
let mut headers = HeaderMap::new();
let content_type = if font.ends_with(".ttf") {
"font/ttf"
} else if font.ends_with(".woff") {
"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))
let font_dir = include_dir!("assets/fonts");
let file = font_dir.get_file(font).ok_or(anyhow!("invalid font"))?;
Ok((headers, file.contents()))
}

View file

@ -115,7 +115,7 @@ impl InlineRule for MathEquationScanner {
return None;
}
let mut display_mode = false;
if input.starts_with("$$\n") {
if input.starts_with("$$\n") || input.starts_with("$$ ") {
display_mode = true;
}
const SEPARATOR_LENGTH: usize = 2;