lukechu10 / mdsycx Goto Github PK
View Code? Open in Web Editor NEWmarkdown with Sycamore
Home Page: https://lukechu10.github.io/mdsycx
License: MIT License
markdown with Sycamore
Home Page: https://lukechu10.github.io/mdsycx
License: MIT License
I'm working on getting math rendering. There are a couple issues here, the first and foremost being that pulldown-cmark hasn't yet implemented a math renderer, though it looks like they're considering using latex2mathml.
A drop in latex2mathml almost works. On reload I see the latex math briefly rendered, then revert back to de-latexified text.
let template = std::fs::read_to_string("dist/.stage/index.html")
.expect("could not read staged index.html");
let rendered = sycamore::render_to_string(App);
let index = template.replace("%sycamore.body%", &rendered);
let index= latex2mathml::replace(&index).unwrap();
// order not important
// can replace in either order, based on my tests
std::fs::write("dist/.stage/index.html", index)
.expect("could not write to staged index.html");
}
I'm not so familiar with the html rendering step, but this seems like a potentially easy fix, any ideas @lukechu10?
given following scenario:
I have a markdown file with a TOC which route to headings in the article / parsed markdown.
since most article based pages usually route their blog posts and articles over a url looking something like this
example.com/article/some-cool-article-you-should-checkout
now imagine you're inside this article and press the TOC anker tag you'll be redirected to the root page with the id attached like this example.com/#i-pressed-a-toc-link
but the desired anker should be example.com/article/some-cool-article-you-should-checkout#i-pressed-a-toc-link
while generating a anker tag current path of the url should be used instead of root.
example md link:
- [Intro](#intro)
i'm still facing the same issue :/ maybe you have an idea
❯ rustc --version
rustc 1.66.0-nightly (2019147c5 2022-09-19)
my cargo toml
[package]
name = "dn"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
perseus = { version = "0.4.0-beta.10", features = [ "hydrate" ] }
sycamore = { version = "^0.8.2", features = ["ssr", "hydrate" ] }
web-sys = "^0.3.60"
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde-wasm-bindgen = { version = "0.4.3"}
serde_json = "1"
reqwasm = {version = "0.5", features = ["json"]}
wasm-bindgen = {version = "0.2", features = ["serde-serialize"]}
mdsycx = "0.1.0"
[patch.crates-io]
sycamore = { git = "https://github.com/sycamore-rs/sycamore", rev = "2a7d015" }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = [ "macros", "rt", "rt-multi-thread" ] }
perseus-warp = { version = "0.4.0-beta.10", features = [ "dflt-server" ] }
# [target.'cfg(target_arch = "wasm32")'.dependencies]
[lib]
name = "lib"
path = "src/lib.rs"
crate-type = [ "cdylib", "rlib" ]
[[bin]]
name = "dn"
path = "src/lib.rs"
cargo check --target wasm32-unknown-unknown
❯ cargo check --target wasm32-unknown-unknown
warning: file found to be present in multiple build targets: /home/redacted/code/rust/dn/src/lib.rs
Updating crates.io index
warning: Patch `sycamore v0.8.1 (https://github.com/sycamore-rs/sycamore?rev=2a7d015#2a7d015b)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
Downloaded perseus-warp v0.4.0-beta.10
Downloaded perseus v0.4.0-beta.10
Downloaded perseus-macro v0.4.0-beta.10
Downloaded 3 crates (140.6 KB) in 0.31s
Compiling perseus-macro v0.4.0-beta.10
Checking mdsycx v0.1.0
error[E0599]: no method named `to_web_sys` found for type parameter `G` in the current scope
--> /home/redacted/.cargo/registry/src/github.com-1ecc6299db9ec823/mdsycx-0.1.0/src/components.rs:124:45
|
92 | fn events_to_view<'a, G: Html>(
| - method `to_web_sys` not found for this type parameter
...
124 | let node = node.to_web_sys();
| ^^^^^^^^^^ method not found in `G`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `mdsycx` due to previous error
warning: build failed, waiting for other jobs to finish...
I think the contentlayer api is well designed to easily import mdx into the code. And also batch filtering of mdx based on conditions. There's also frontmatter metadata that can be type nested
Markdowndb's solution is pretty good too, the sql is very flexible
there is no crate even though the website links to one
I'm confused. This may not be an actual bug but just an ID10T error by me.
the trait bound `&for<'a> fn(sycamore_reactive::BoundedScope<'a, 'a>, MdSycXProps<'a, _>) -> sycamore_core::view::View<_> {MDSycX::<_>}: sycamore::component::Component<'_, _, _, _>` is not satisfied
the trait `sycamore::component::Component<'_, _, _, _>` is not implemented for `&for<'a> fn(sycamore_reactive::BoundedScope<'a, 'a>, MdSycXProps<'a, _>) -> sycamore_core::view::View<_> {MDSycX::<_>}
I'm receiving this error when handing off the pased.body
to an MDSycX. I can see #[component]
on the MDSycX function so I don't understand why I'm receiving this error.
use sycamore::prelude::*;
use mdsycx::{parse, MDSycX};
use crate::model::posts::{get_post};
async fn fetch_post() {
let md_string = get_post(String::from("test.md"));
}
#[component]
pub async fn PostList<G: Html>(cx: Scope<'_>) -> View<G> {
let req = get_post(String::from("test.md"));
let result = req.await;
match result {
Ok(value) => {
let parsed = parse::<()>(&value).unwrap();
view! { cx,
MDSycX(cx=cx,body=parsed.body)
}
}
Err(error) => {
println!("{error:?}");
view! { cx,
table {
tbody {
(format!("Unable to render post. {error:?}"))
}
}
}
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.