├── .cargo └── config.toml ├── .github └── workflows │ └── main.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── examples ├── custom_components │ ├── Cargo.toml │ ├── index.html │ ├── markdown.css │ └── src │ │ └── main.rs ├── editor │ ├── Cargo.toml │ ├── index.html │ ├── src │ │ └── main.rs │ └── style.css ├── onclick │ ├── Cargo.toml │ ├── index.html │ └── src │ │ └── main.rs └── showcase │ ├── Cargo.toml │ ├── index.html │ ├── markdown.css │ └── src │ └── main.rs ├── flake.lock ├── flake.nix ├── img └── showcase.jpg ├── index.html └── src └── lib.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [check] 2 | target = "wasm32-unknown-unknown" 3 | 4 | [build] 5 | target = "wasm32-unknown-unknown" 6 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: "build website" 2 | on: 3 | push: 4 | branches: ["main"] 5 | permissions: 6 | contents: write 7 | jobs: 8 | build-pages: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: cachix/install-nix-action@v20 13 | with: 14 | nix_path: nixpkgs=channel:nixos-22.05 15 | - uses: cachix/cachix-action@v12 16 | with: 17 | name: rambip 18 | # If you chose API tokens for write access OR if you have a private cache 19 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 20 | 21 | - run: nix build 22 | 23 | - uses: actions/upload-pages-artifact@v2 24 | with: 25 | path: "result/" 26 | 27 | 28 | deploy: 29 | needs: build-pages 30 | runs-on: ubuntu-latest 31 | # Grant GITHUB_TOKEN the permissions required to make a Pages deployment 32 | permissions: 33 | pages: write # to deploy to Pages 34 | id-token: write # to verify the deployment originates from an appropriate source 35 | 36 | environment: 37 | name: github-pages 38 | # don't forget to go to the settings/environment and to allow main to push ! 39 | url: ${{ steps.deployment.outputs.page_url }} 40 | 41 | steps: 42 | - name: Deploy to GitHub Pages 43 | id: deployment 44 | uses: actions/deploy-pages@v2 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | **/dist 3 | .envrc 4 | .direnv 5 | result 6 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "adler" 7 | version = "1.0.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 10 | 11 | [[package]] 12 | name = "ahash" 13 | version = "0.7.7" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" 16 | dependencies = [ 17 | "getrandom", 18 | "once_cell", 19 | "version_check", 20 | ] 21 | 22 | [[package]] 23 | name = "aho-corasick" 24 | version = "1.1.2" 25 | source = "registry+https://github.com/rust-lang/crates.io-index" 26 | checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" 27 | dependencies = [ 28 | "memchr", 29 | ] 30 | 31 | [[package]] 32 | name = "async-channel" 33 | version = "1.9.0" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" 36 | dependencies = [ 37 | "concurrent-queue", 38 | "event-listener 2.5.3", 39 | "futures-core", 40 | ] 41 | 42 | [[package]] 43 | name = "async-channel" 44 | version = "2.1.1" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" 47 | dependencies = [ 48 | "concurrent-queue", 49 | "event-listener 4.0.1", 50 | "event-listener-strategy", 51 | "futures-core", 52 | "pin-project-lite", 53 | ] 54 | 55 | [[package]] 56 | name = "async-lock" 57 | version = "3.2.0" 58 | source = "registry+https://github.com/rust-lang/crates.io-index" 59 | checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" 60 | dependencies = [ 61 | "event-listener 4.0.1", 62 | "event-listener-strategy", 63 | "pin-project-lite", 64 | ] 65 | 66 | [[package]] 67 | name = "async-task" 68 | version = "4.6.0" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | checksum = "e1d90cd0b264dfdd8eb5bad0a2c217c1f88fa96a8573f40e7b12de23fb468f46" 71 | 72 | [[package]] 73 | name = "async-trait" 74 | version = "0.1.75" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" 77 | dependencies = [ 78 | "proc-macro2", 79 | "quote", 80 | "syn 2.0.43", 81 | ] 82 | 83 | [[package]] 84 | name = "atomic-waker" 85 | version = "1.1.2" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" 88 | 89 | [[package]] 90 | name = "autocfg" 91 | version = "1.1.0" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 94 | 95 | [[package]] 96 | name = "base64" 97 | version = "0.21.5" 98 | source = "registry+https://github.com/rust-lang/crates.io-index" 99 | checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" 100 | 101 | [[package]] 102 | name = "bincode" 103 | version = "1.3.3" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" 106 | dependencies = [ 107 | "serde", 108 | ] 109 | 110 | [[package]] 111 | name = "bit-set" 112 | version = "0.5.3" 113 | source = "registry+https://github.com/rust-lang/crates.io-index" 114 | checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" 115 | dependencies = [ 116 | "bit-vec", 117 | ] 118 | 119 | [[package]] 120 | name = "bit-vec" 121 | version = "0.6.3" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" 124 | 125 | [[package]] 126 | name = "bitflags" 127 | version = "1.3.2" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 130 | 131 | [[package]] 132 | name = "bitflags" 133 | version = "2.4.1" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" 136 | 137 | [[package]] 138 | name = "blocking" 139 | version = "1.5.1" 140 | source = "registry+https://github.com/rust-lang/crates.io-index" 141 | checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" 142 | dependencies = [ 143 | "async-channel 2.1.1", 144 | "async-lock", 145 | "async-task", 146 | "fastrand", 147 | "futures-io", 148 | "futures-lite", 149 | "piper", 150 | "tracing", 151 | ] 152 | 153 | [[package]] 154 | name = "bumpalo" 155 | version = "3.14.0" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" 158 | 159 | [[package]] 160 | name = "cfg-if" 161 | version = "1.0.0" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 164 | 165 | [[package]] 166 | name = "concurrent-queue" 167 | version = "2.4.0" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" 170 | dependencies = [ 171 | "crossbeam-utils", 172 | ] 173 | 174 | [[package]] 175 | name = "console_error_panic_hook" 176 | version = "0.1.7" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" 179 | dependencies = [ 180 | "cfg-if", 181 | "wasm-bindgen", 182 | ] 183 | 184 | [[package]] 185 | name = "constcat" 186 | version = "0.3.1" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "cd7e35aee659887cbfb97aaf227ac12cad1a9d7c71e55ff3376839ed4e282d08" 189 | 190 | [[package]] 191 | name = "crc32fast" 192 | version = "1.3.2" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" 195 | dependencies = [ 196 | "cfg-if", 197 | ] 198 | 199 | [[package]] 200 | name = "crossbeam-utils" 201 | version = "0.8.18" 202 | source = "registry+https://github.com/rust-lang/crates.io-index" 203 | checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" 204 | dependencies = [ 205 | "cfg-if", 206 | ] 207 | 208 | [[package]] 209 | name = "custom_components" 210 | version = "0.1.0" 211 | dependencies = [ 212 | "dioxus", 213 | "dioxus-markdown", 214 | "dioxus-web", 215 | ] 216 | 217 | [[package]] 218 | name = "darling" 219 | version = "0.14.4" 220 | source = "registry+https://github.com/rust-lang/crates.io-index" 221 | checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" 222 | dependencies = [ 223 | "darling_core 0.14.4", 224 | "darling_macro 0.14.4", 225 | ] 226 | 227 | [[package]] 228 | name = "darling" 229 | version = "0.20.3" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" 232 | dependencies = [ 233 | "darling_core 0.20.3", 234 | "darling_macro 0.20.3", 235 | ] 236 | 237 | [[package]] 238 | name = "darling_core" 239 | version = "0.14.4" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" 242 | dependencies = [ 243 | "fnv", 244 | "ident_case", 245 | "proc-macro2", 246 | "quote", 247 | "strsim", 248 | "syn 1.0.109", 249 | ] 250 | 251 | [[package]] 252 | name = "darling_core" 253 | version = "0.20.3" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" 256 | dependencies = [ 257 | "fnv", 258 | "ident_case", 259 | "proc-macro2", 260 | "quote", 261 | "syn 2.0.43", 262 | ] 263 | 264 | [[package]] 265 | name = "darling_macro" 266 | version = "0.14.4" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" 269 | dependencies = [ 270 | "darling_core 0.14.4", 271 | "quote", 272 | "syn 1.0.109", 273 | ] 274 | 275 | [[package]] 276 | name = "darling_macro" 277 | version = "0.20.3" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" 280 | dependencies = [ 281 | "darling_core 0.20.3", 282 | "quote", 283 | "syn 2.0.43", 284 | ] 285 | 286 | [[package]] 287 | name = "deranged" 288 | version = "0.3.10" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" 291 | dependencies = [ 292 | "powerfmt", 293 | ] 294 | 295 | [[package]] 296 | name = "derive_builder" 297 | version = "0.12.0" 298 | source = "registry+https://github.com/rust-lang/crates.io-index" 299 | checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" 300 | dependencies = [ 301 | "derive_builder_macro", 302 | ] 303 | 304 | [[package]] 305 | name = "derive_builder_core" 306 | version = "0.12.0" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" 309 | dependencies = [ 310 | "darling 0.14.4", 311 | "proc-macro2", 312 | "quote", 313 | "syn 1.0.109", 314 | ] 315 | 316 | [[package]] 317 | name = "derive_builder_macro" 318 | version = "0.12.0" 319 | source = "registry+https://github.com/rust-lang/crates.io-index" 320 | checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" 321 | dependencies = [ 322 | "derive_builder_core", 323 | "syn 1.0.109", 324 | ] 325 | 326 | [[package]] 327 | name = "dioxus" 328 | version = "0.4.3" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "2d9e3b0725e520250bf23213f996d241cca29cea4360a9bf08a44e0033f8e569" 331 | dependencies = [ 332 | "dioxus-core", 333 | "dioxus-core-macro", 334 | "dioxus-hooks", 335 | "dioxus-hot-reload", 336 | "dioxus-html", 337 | "dioxus-rsx", 338 | ] 339 | 340 | [[package]] 341 | name = "dioxus-core" 342 | version = "0.4.3" 343 | source = "registry+https://github.com/rust-lang/crates.io-index" 344 | checksum = "0f33186615b2e90bceab24a195b3cfad4e0b4d91a33ec44a94845876bfb25c13" 345 | dependencies = [ 346 | "bumpalo", 347 | "futures-channel", 348 | "futures-util", 349 | "longest-increasing-subsequence", 350 | "rustc-hash", 351 | "serde", 352 | "slab", 353 | "smallbox", 354 | "tracing", 355 | ] 356 | 357 | [[package]] 358 | name = "dioxus-core-macro" 359 | version = "0.4.3" 360 | source = "registry+https://github.com/rust-lang/crates.io-index" 361 | checksum = "21afaccb28587aed0ba98856335912f5ce7052c0aafa74b213829a3b8bfd2345" 362 | dependencies = [ 363 | "constcat", 364 | "dioxus-core", 365 | "dioxus-rsx", 366 | "prettyplease", 367 | "proc-macro2", 368 | "quote", 369 | "syn 2.0.43", 370 | ] 371 | 372 | [[package]] 373 | name = "dioxus-debug-cell" 374 | version = "0.1.1" 375 | source = "registry+https://github.com/rust-lang/crates.io-index" 376 | checksum = "2ea539174bb236e0e7dc9c12b19b88eae3cb574dedbd0252a2d43ea7e6de13e2" 377 | 378 | [[package]] 379 | name = "dioxus-hooks" 380 | version = "0.4.3" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | checksum = "5bb23ce82df4fb13e9ddaa01d1469f1f32d683dd4636204bd0a0eaf434b65946" 383 | dependencies = [ 384 | "dioxus-core", 385 | "dioxus-debug-cell", 386 | "futures-channel", 387 | "slab", 388 | "thiserror", 389 | "tracing", 390 | ] 391 | 392 | [[package]] 393 | name = "dioxus-hot-reload" 394 | version = "0.4.3" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "b7d8c9e89e866a6b84b8ad696f0ff2f6f6563d2235eb99acc6952f19e516cc09" 397 | dependencies = [ 398 | "dioxus-core", 399 | "dioxus-html", 400 | "dioxus-rsx", 401 | "interprocess-docfix", 402 | "serde", 403 | "serde_json", 404 | ] 405 | 406 | [[package]] 407 | name = "dioxus-html" 408 | version = "0.4.0" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | checksum = "fb712fe56650dafddb626f8aed3d6ae194706c0299e175e99b45464add8b7af1" 411 | dependencies = [ 412 | "async-channel 1.9.0", 413 | "async-trait", 414 | "dioxus-core", 415 | "enumset", 416 | "euclid", 417 | "keyboard-types", 418 | "serde", 419 | "serde-value", 420 | "serde_json", 421 | "serde_repr", 422 | "wasm-bindgen", 423 | "web-sys", 424 | ] 425 | 426 | [[package]] 427 | name = "dioxus-interpreter-js" 428 | version = "0.4.0" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "b2d35a6680cb2cf003a6c84fcaaa6d2a60b930efe4750910977b4e513bd73826" 431 | dependencies = [ 432 | "js-sys", 433 | "sledgehammer_bindgen", 434 | "sledgehammer_utils", 435 | "wasm-bindgen", 436 | "web-sys", 437 | ] 438 | 439 | [[package]] 440 | name = "dioxus-markdown" 441 | version = "0.1.2" 442 | dependencies = [ 443 | "dioxus", 444 | "dioxus-web", 445 | "rust-web-markdown", 446 | ] 447 | 448 | [[package]] 449 | name = "dioxus-rsx" 450 | version = "0.4.3" 451 | source = "registry+https://github.com/rust-lang/crates.io-index" 452 | checksum = "c974133c7c95497a486d587e40449927711430b308134b9cd374b8d35eceafb3" 453 | dependencies = [ 454 | "dioxus-core", 455 | "proc-macro2", 456 | "quote", 457 | "syn 2.0.43", 458 | ] 459 | 460 | [[package]] 461 | name = "dioxus-web" 462 | version = "0.4.0" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "91d9dcd05db44c292220d520868bf703ea8165539ed8d80c60a7c33c3a846e8c" 465 | dependencies = [ 466 | "async-channel 1.9.0", 467 | "async-trait", 468 | "console_error_panic_hook", 469 | "dioxus-core", 470 | "dioxus-html", 471 | "dioxus-interpreter-js", 472 | "futures-channel", 473 | "futures-util", 474 | "js-sys", 475 | "log", 476 | "rustc-hash", 477 | "serde", 478 | "serde-wasm-bindgen", 479 | "serde_json", 480 | "wasm-bindgen", 481 | "wasm-bindgen-futures", 482 | "web-sys", 483 | ] 484 | 485 | [[package]] 486 | name = "either" 487 | version = "1.9.0" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" 490 | 491 | [[package]] 492 | name = "enumset" 493 | version = "1.1.3" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" 496 | dependencies = [ 497 | "enumset_derive", 498 | ] 499 | 500 | [[package]] 501 | name = "enumset_derive" 502 | version = "0.8.1" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" 505 | dependencies = [ 506 | "darling 0.20.3", 507 | "proc-macro2", 508 | "quote", 509 | "syn 2.0.43", 510 | ] 511 | 512 | [[package]] 513 | name = "equivalent" 514 | version = "1.0.1" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 517 | 518 | [[package]] 519 | name = "euclid" 520 | version = "0.22.9" 521 | source = "registry+https://github.com/rust-lang/crates.io-index" 522 | checksum = "87f253bc5c813ca05792837a0ff4b3a580336b224512d48f7eda1d7dd9210787" 523 | dependencies = [ 524 | "num-traits", 525 | "serde", 526 | ] 527 | 528 | [[package]] 529 | name = "event-listener" 530 | version = "2.5.3" 531 | source = "registry+https://github.com/rust-lang/crates.io-index" 532 | checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" 533 | 534 | [[package]] 535 | name = "event-listener" 536 | version = "4.0.1" 537 | source = "registry+https://github.com/rust-lang/crates.io-index" 538 | checksum = "84f2cdcf274580f2d63697192d744727b3198894b1bf02923643bf59e2c26712" 539 | dependencies = [ 540 | "concurrent-queue", 541 | "parking", 542 | "pin-project-lite", 543 | ] 544 | 545 | [[package]] 546 | name = "event-listener-strategy" 547 | version = "0.4.0" 548 | source = "registry+https://github.com/rust-lang/crates.io-index" 549 | checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" 550 | dependencies = [ 551 | "event-listener 4.0.1", 552 | "pin-project-lite", 553 | ] 554 | 555 | [[package]] 556 | name = "fancy-regex" 557 | version = "0.11.0" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" 560 | dependencies = [ 561 | "bit-set", 562 | "regex", 563 | ] 564 | 565 | [[package]] 566 | name = "fastrand" 567 | version = "2.0.1" 568 | source = "registry+https://github.com/rust-lang/crates.io-index" 569 | checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" 570 | 571 | [[package]] 572 | name = "flate2" 573 | version = "1.0.28" 574 | source = "registry+https://github.com/rust-lang/crates.io-index" 575 | checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" 576 | dependencies = [ 577 | "crc32fast", 578 | "miniz_oxide", 579 | ] 580 | 581 | [[package]] 582 | name = "fnv" 583 | version = "1.0.7" 584 | source = "registry+https://github.com/rust-lang/crates.io-index" 585 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 586 | 587 | [[package]] 588 | name = "futures-channel" 589 | version = "0.3.30" 590 | source = "registry+https://github.com/rust-lang/crates.io-index" 591 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 592 | dependencies = [ 593 | "futures-core", 594 | ] 595 | 596 | [[package]] 597 | name = "futures-core" 598 | version = "0.3.30" 599 | source = "registry+https://github.com/rust-lang/crates.io-index" 600 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 601 | 602 | [[package]] 603 | name = "futures-io" 604 | version = "0.3.30" 605 | source = "registry+https://github.com/rust-lang/crates.io-index" 606 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 607 | 608 | [[package]] 609 | name = "futures-lite" 610 | version = "2.1.0" 611 | source = "registry+https://github.com/rust-lang/crates.io-index" 612 | checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" 613 | dependencies = [ 614 | "futures-core", 615 | "pin-project-lite", 616 | ] 617 | 618 | [[package]] 619 | name = "futures-macro" 620 | version = "0.3.30" 621 | source = "registry+https://github.com/rust-lang/crates.io-index" 622 | checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" 623 | dependencies = [ 624 | "proc-macro2", 625 | "quote", 626 | "syn 2.0.43", 627 | ] 628 | 629 | [[package]] 630 | name = "futures-task" 631 | version = "0.3.30" 632 | source = "registry+https://github.com/rust-lang/crates.io-index" 633 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" 634 | 635 | [[package]] 636 | name = "futures-util" 637 | version = "0.3.30" 638 | source = "registry+https://github.com/rust-lang/crates.io-index" 639 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" 640 | dependencies = [ 641 | "futures-core", 642 | "futures-macro", 643 | "futures-task", 644 | "pin-project-lite", 645 | "pin-utils", 646 | "slab", 647 | ] 648 | 649 | [[package]] 650 | name = "getopts" 651 | version = "0.2.21" 652 | source = "registry+https://github.com/rust-lang/crates.io-index" 653 | checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" 654 | dependencies = [ 655 | "unicode-width", 656 | ] 657 | 658 | [[package]] 659 | name = "getrandom" 660 | version = "0.2.11" 661 | source = "registry+https://github.com/rust-lang/crates.io-index" 662 | checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" 663 | dependencies = [ 664 | "cfg-if", 665 | "libc", 666 | "wasi", 667 | ] 668 | 669 | [[package]] 670 | name = "hashbrown" 671 | version = "0.12.3" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 674 | dependencies = [ 675 | "ahash", 676 | ] 677 | 678 | [[package]] 679 | name = "hashbrown" 680 | version = "0.14.3" 681 | source = "registry+https://github.com/rust-lang/crates.io-index" 682 | checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" 683 | 684 | [[package]] 685 | name = "ident_case" 686 | version = "1.0.1" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 689 | 690 | [[package]] 691 | name = "indexmap" 692 | version = "2.1.0" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" 695 | dependencies = [ 696 | "equivalent", 697 | "hashbrown 0.14.3", 698 | ] 699 | 700 | [[package]] 701 | name = "interprocess-docfix" 702 | version = "1.2.2" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "4b84ee245c606aeb0841649a9288e3eae8c61b853a8cd5c0e14450e96d53d28f" 705 | dependencies = [ 706 | "blocking", 707 | "cfg-if", 708 | "futures-core", 709 | "futures-io", 710 | "intmap", 711 | "libc", 712 | "once_cell", 713 | "rustc_version", 714 | "spinning", 715 | "thiserror", 716 | "to_method", 717 | "winapi", 718 | ] 719 | 720 | [[package]] 721 | name = "intmap" 722 | version = "0.7.1" 723 | source = "registry+https://github.com/rust-lang/crates.io-index" 724 | checksum = "ae52f28f45ac2bc96edb7714de995cffc174a395fb0abf5bff453587c980d7b9" 725 | 726 | [[package]] 727 | name = "itertools" 728 | version = "0.10.5" 729 | source = "registry+https://github.com/rust-lang/crates.io-index" 730 | checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" 731 | dependencies = [ 732 | "either", 733 | ] 734 | 735 | [[package]] 736 | name = "itoa" 737 | version = "1.0.10" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" 740 | 741 | [[package]] 742 | name = "js-sys" 743 | version = "0.3.64" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" 746 | dependencies = [ 747 | "wasm-bindgen", 748 | ] 749 | 750 | [[package]] 751 | name = "katex" 752 | version = "0.4.6" 753 | source = "registry+https://github.com/rust-lang/crates.io-index" 754 | checksum = "4bdbc7a1823f188f56ac9486993536b70a2686a58d47095dcc10507a7d242bf5" 755 | dependencies = [ 756 | "cfg-if", 757 | "derive_builder", 758 | "itertools", 759 | "js-sys", 760 | "thiserror", 761 | "wasm-bindgen", 762 | ] 763 | 764 | [[package]] 765 | name = "keyboard-types" 766 | version = "0.6.2" 767 | source = "registry+https://github.com/rust-lang/crates.io-index" 768 | checksum = "0b7668b7cff6a51fe61cdde64cd27c8a220786f399501b57ebe36f7d8112fd68" 769 | dependencies = [ 770 | "bitflags 1.3.2", 771 | "serde", 772 | "unicode-segmentation", 773 | ] 774 | 775 | [[package]] 776 | name = "lazy_static" 777 | version = "1.4.0" 778 | source = "registry+https://github.com/rust-lang/crates.io-index" 779 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 780 | 781 | [[package]] 782 | name = "libc" 783 | version = "0.2.151" 784 | source = "registry+https://github.com/rust-lang/crates.io-index" 785 | checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" 786 | 787 | [[package]] 788 | name = "line-wrap" 789 | version = "0.1.1" 790 | source = "registry+https://github.com/rust-lang/crates.io-index" 791 | checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" 792 | dependencies = [ 793 | "safemem", 794 | ] 795 | 796 | [[package]] 797 | name = "linked-hash-map" 798 | version = "0.5.6" 799 | source = "registry+https://github.com/rust-lang/crates.io-index" 800 | checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" 801 | 802 | [[package]] 803 | name = "lock_api" 804 | version = "0.4.11" 805 | source = "registry+https://github.com/rust-lang/crates.io-index" 806 | checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" 807 | dependencies = [ 808 | "autocfg", 809 | "scopeguard", 810 | ] 811 | 812 | [[package]] 813 | name = "log" 814 | version = "0.4.20" 815 | source = "registry+https://github.com/rust-lang/crates.io-index" 816 | checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" 817 | 818 | [[package]] 819 | name = "longest-increasing-subsequence" 820 | version = "0.1.0" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86" 823 | 824 | [[package]] 825 | name = "lru" 826 | version = "0.8.1" 827 | source = "registry+https://github.com/rust-lang/crates.io-index" 828 | checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" 829 | dependencies = [ 830 | "hashbrown 0.12.3", 831 | ] 832 | 833 | [[package]] 834 | name = "markdown-editor" 835 | version = "0.1.0" 836 | dependencies = [ 837 | "dioxus", 838 | "dioxus-markdown", 839 | "dioxus-web", 840 | ] 841 | 842 | [[package]] 843 | name = "memchr" 844 | version = "2.7.1" 845 | source = "registry+https://github.com/rust-lang/crates.io-index" 846 | checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" 847 | 848 | [[package]] 849 | name = "miniz_oxide" 850 | version = "0.7.1" 851 | source = "registry+https://github.com/rust-lang/crates.io-index" 852 | checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" 853 | dependencies = [ 854 | "adler", 855 | ] 856 | 857 | [[package]] 858 | name = "num-traits" 859 | version = "0.2.17" 860 | source = "registry+https://github.com/rust-lang/crates.io-index" 861 | checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" 862 | dependencies = [ 863 | "autocfg", 864 | ] 865 | 866 | [[package]] 867 | name = "once_cell" 868 | version = "1.19.0" 869 | source = "registry+https://github.com/rust-lang/crates.io-index" 870 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 871 | 872 | [[package]] 873 | name = "onclick" 874 | version = "0.1.0" 875 | dependencies = [ 876 | "dioxus", 877 | "dioxus-markdown", 878 | "dioxus-web", 879 | ] 880 | 881 | [[package]] 882 | name = "ordered-float" 883 | version = "2.10.1" 884 | source = "registry+https://github.com/rust-lang/crates.io-index" 885 | checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" 886 | dependencies = [ 887 | "num-traits", 888 | ] 889 | 890 | [[package]] 891 | name = "parking" 892 | version = "2.2.0" 893 | source = "registry+https://github.com/rust-lang/crates.io-index" 894 | checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" 895 | 896 | [[package]] 897 | name = "pin-project-lite" 898 | version = "0.2.13" 899 | source = "registry+https://github.com/rust-lang/crates.io-index" 900 | checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" 901 | 902 | [[package]] 903 | name = "pin-utils" 904 | version = "0.1.0" 905 | source = "registry+https://github.com/rust-lang/crates.io-index" 906 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 907 | 908 | [[package]] 909 | name = "piper" 910 | version = "0.2.1" 911 | source = "registry+https://github.com/rust-lang/crates.io-index" 912 | checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" 913 | dependencies = [ 914 | "atomic-waker", 915 | "fastrand", 916 | "futures-io", 917 | ] 918 | 919 | [[package]] 920 | name = "plist" 921 | version = "1.6.0" 922 | source = "registry+https://github.com/rust-lang/crates.io-index" 923 | checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" 924 | dependencies = [ 925 | "base64", 926 | "indexmap", 927 | "line-wrap", 928 | "quick-xml", 929 | "serde", 930 | "time", 931 | ] 932 | 933 | [[package]] 934 | name = "powerfmt" 935 | version = "0.2.0" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" 938 | 939 | [[package]] 940 | name = "prettyplease" 941 | version = "0.2.15" 942 | source = "registry+https://github.com/rust-lang/crates.io-index" 943 | checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" 944 | dependencies = [ 945 | "proc-macro2", 946 | "syn 2.0.43", 947 | ] 948 | 949 | [[package]] 950 | name = "proc-macro2" 951 | version = "1.0.71" 952 | source = "registry+https://github.com/rust-lang/crates.io-index" 953 | checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" 954 | dependencies = [ 955 | "unicode-ident", 956 | ] 957 | 958 | [[package]] 959 | name = "pulldown-cmark" 960 | version = "0.9.2" 961 | source = "git+https://github.com/ollpu/pulldown-cmark.git?branch=alt-math#f923db20143aac50abe021bc6428ef686c5431ff" 962 | dependencies = [ 963 | "bitflags 2.4.1", 964 | "getopts", 965 | "memchr", 966 | "unicase", 967 | ] 968 | 969 | [[package]] 970 | name = "pulldown-cmark-wikilink" 971 | version = "0.1.4" 972 | source = "git+https://github.com/rambip/pulldown-cmark-wikilink#0f4c29624c77713ddcc08b4967d091a4c03f290d" 973 | dependencies = [ 974 | "pulldown-cmark", 975 | ] 976 | 977 | [[package]] 978 | name = "quick-xml" 979 | version = "0.31.0" 980 | source = "registry+https://github.com/rust-lang/crates.io-index" 981 | checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" 982 | dependencies = [ 983 | "memchr", 984 | ] 985 | 986 | [[package]] 987 | name = "quote" 988 | version = "1.0.33" 989 | source = "registry+https://github.com/rust-lang/crates.io-index" 990 | checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 991 | dependencies = [ 992 | "proc-macro2", 993 | ] 994 | 995 | [[package]] 996 | name = "regex" 997 | version = "1.10.2" 998 | source = "registry+https://github.com/rust-lang/crates.io-index" 999 | checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" 1000 | dependencies = [ 1001 | "aho-corasick", 1002 | "memchr", 1003 | "regex-automata", 1004 | "regex-syntax 0.8.2", 1005 | ] 1006 | 1007 | [[package]] 1008 | name = "regex-automata" 1009 | version = "0.4.3" 1010 | source = "registry+https://github.com/rust-lang/crates.io-index" 1011 | checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" 1012 | dependencies = [ 1013 | "aho-corasick", 1014 | "memchr", 1015 | "regex-syntax 0.8.2", 1016 | ] 1017 | 1018 | [[package]] 1019 | name = "regex-syntax" 1020 | version = "0.7.5" 1021 | source = "registry+https://github.com/rust-lang/crates.io-index" 1022 | checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" 1023 | 1024 | [[package]] 1025 | name = "regex-syntax" 1026 | version = "0.8.2" 1027 | source = "registry+https://github.com/rust-lang/crates.io-index" 1028 | checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" 1029 | 1030 | [[package]] 1031 | name = "rust-web-markdown" 1032 | version = "0.2.0" 1033 | source = "git+https://github.com/rambip/rust-web-markdown/#23874ab460a2df0054a5fab36c9e8e6976dab341" 1034 | dependencies = [ 1035 | "katex", 1036 | "lazy_static", 1037 | "pulldown-cmark-wikilink", 1038 | "syntect", 1039 | "web-sys", 1040 | ] 1041 | 1042 | [[package]] 1043 | name = "rustc-hash" 1044 | version = "1.1.0" 1045 | source = "registry+https://github.com/rust-lang/crates.io-index" 1046 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 1047 | 1048 | [[package]] 1049 | name = "rustc_version" 1050 | version = "0.4.0" 1051 | source = "registry+https://github.com/rust-lang/crates.io-index" 1052 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 1053 | dependencies = [ 1054 | "semver", 1055 | ] 1056 | 1057 | [[package]] 1058 | name = "ryu" 1059 | version = "1.0.16" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" 1062 | 1063 | [[package]] 1064 | name = "safemem" 1065 | version = "0.3.3" 1066 | source = "registry+https://github.com/rust-lang/crates.io-index" 1067 | checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" 1068 | 1069 | [[package]] 1070 | name = "same-file" 1071 | version = "1.0.6" 1072 | source = "registry+https://github.com/rust-lang/crates.io-index" 1073 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 1074 | dependencies = [ 1075 | "winapi-util", 1076 | ] 1077 | 1078 | [[package]] 1079 | name = "scopeguard" 1080 | version = "1.2.0" 1081 | source = "registry+https://github.com/rust-lang/crates.io-index" 1082 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 1083 | 1084 | [[package]] 1085 | name = "semver" 1086 | version = "1.0.20" 1087 | source = "registry+https://github.com/rust-lang/crates.io-index" 1088 | checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" 1089 | 1090 | [[package]] 1091 | name = "serde" 1092 | version = "1.0.193" 1093 | source = "registry+https://github.com/rust-lang/crates.io-index" 1094 | checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" 1095 | dependencies = [ 1096 | "serde_derive", 1097 | ] 1098 | 1099 | [[package]] 1100 | name = "serde-value" 1101 | version = "0.7.0" 1102 | source = "registry+https://github.com/rust-lang/crates.io-index" 1103 | checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" 1104 | dependencies = [ 1105 | "ordered-float", 1106 | "serde", 1107 | ] 1108 | 1109 | [[package]] 1110 | name = "serde-wasm-bindgen" 1111 | version = "0.5.0" 1112 | source = "registry+https://github.com/rust-lang/crates.io-index" 1113 | checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" 1114 | dependencies = [ 1115 | "js-sys", 1116 | "serde", 1117 | "wasm-bindgen", 1118 | ] 1119 | 1120 | [[package]] 1121 | name = "serde_derive" 1122 | version = "1.0.193" 1123 | source = "registry+https://github.com/rust-lang/crates.io-index" 1124 | checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" 1125 | dependencies = [ 1126 | "proc-macro2", 1127 | "quote", 1128 | "syn 2.0.43", 1129 | ] 1130 | 1131 | [[package]] 1132 | name = "serde_json" 1133 | version = "1.0.108" 1134 | source = "registry+https://github.com/rust-lang/crates.io-index" 1135 | checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" 1136 | dependencies = [ 1137 | "itoa", 1138 | "ryu", 1139 | "serde", 1140 | ] 1141 | 1142 | [[package]] 1143 | name = "serde_repr" 1144 | version = "0.1.17" 1145 | source = "registry+https://github.com/rust-lang/crates.io-index" 1146 | checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" 1147 | dependencies = [ 1148 | "proc-macro2", 1149 | "quote", 1150 | "syn 2.0.43", 1151 | ] 1152 | 1153 | [[package]] 1154 | name = "showcase" 1155 | version = "0.1.0" 1156 | dependencies = [ 1157 | "dioxus", 1158 | "dioxus-markdown", 1159 | "dioxus-web", 1160 | ] 1161 | 1162 | [[package]] 1163 | name = "slab" 1164 | version = "0.4.9" 1165 | source = "registry+https://github.com/rust-lang/crates.io-index" 1166 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 1167 | dependencies = [ 1168 | "autocfg", 1169 | ] 1170 | 1171 | [[package]] 1172 | name = "sledgehammer_bindgen" 1173 | version = "0.2.4" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "c0bc2cf26c12673eee8674b19d56cec04e9b815704c71298eafac61f131f99d7" 1176 | dependencies = [ 1177 | "quote", 1178 | "syn 2.0.43", 1179 | ] 1180 | 1181 | [[package]] 1182 | name = "sledgehammer_utils" 1183 | version = "0.2.0" 1184 | source = "registry+https://github.com/rust-lang/crates.io-index" 1185 | checksum = "5cd16550f1dd7866c7580dbf80c892dc1bef106737eeb850d42c62ec61896059" 1186 | dependencies = [ 1187 | "lru", 1188 | "once_cell", 1189 | "rustc-hash", 1190 | ] 1191 | 1192 | [[package]] 1193 | name = "smallbox" 1194 | version = "0.8.2" 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" 1196 | checksum = "d92359f97e6b417da4328a970cf04a044db104fbd57f7d72cb7ff665bb8806af" 1197 | 1198 | [[package]] 1199 | name = "spinning" 1200 | version = "0.1.0" 1201 | source = "registry+https://github.com/rust-lang/crates.io-index" 1202 | checksum = "2d4f0e86297cad2658d92a707320d87bf4e6ae1050287f51d19b67ef3f153a7b" 1203 | dependencies = [ 1204 | "lock_api", 1205 | ] 1206 | 1207 | [[package]] 1208 | name = "strsim" 1209 | version = "0.10.0" 1210 | source = "registry+https://github.com/rust-lang/crates.io-index" 1211 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 1212 | 1213 | [[package]] 1214 | name = "syn" 1215 | version = "1.0.109" 1216 | source = "registry+https://github.com/rust-lang/crates.io-index" 1217 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1218 | dependencies = [ 1219 | "proc-macro2", 1220 | "quote", 1221 | "unicode-ident", 1222 | ] 1223 | 1224 | [[package]] 1225 | name = "syn" 1226 | version = "2.0.43" 1227 | source = "registry+https://github.com/rust-lang/crates.io-index" 1228 | checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" 1229 | dependencies = [ 1230 | "proc-macro2", 1231 | "quote", 1232 | "unicode-ident", 1233 | ] 1234 | 1235 | [[package]] 1236 | name = "syntect" 1237 | version = "5.1.0" 1238 | source = "registry+https://github.com/rust-lang/crates.io-index" 1239 | checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" 1240 | dependencies = [ 1241 | "bincode", 1242 | "bitflags 1.3.2", 1243 | "fancy-regex", 1244 | "flate2", 1245 | "fnv", 1246 | "once_cell", 1247 | "plist", 1248 | "regex-syntax 0.7.5", 1249 | "serde", 1250 | "serde_json", 1251 | "thiserror", 1252 | "walkdir", 1253 | "yaml-rust", 1254 | ] 1255 | 1256 | [[package]] 1257 | name = "thiserror" 1258 | version = "1.0.52" 1259 | source = "registry+https://github.com/rust-lang/crates.io-index" 1260 | checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" 1261 | dependencies = [ 1262 | "thiserror-impl", 1263 | ] 1264 | 1265 | [[package]] 1266 | name = "thiserror-impl" 1267 | version = "1.0.52" 1268 | source = "registry+https://github.com/rust-lang/crates.io-index" 1269 | checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" 1270 | dependencies = [ 1271 | "proc-macro2", 1272 | "quote", 1273 | "syn 2.0.43", 1274 | ] 1275 | 1276 | [[package]] 1277 | name = "time" 1278 | version = "0.3.31" 1279 | source = "registry+https://github.com/rust-lang/crates.io-index" 1280 | checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" 1281 | dependencies = [ 1282 | "deranged", 1283 | "itoa", 1284 | "powerfmt", 1285 | "serde", 1286 | "time-core", 1287 | "time-macros", 1288 | ] 1289 | 1290 | [[package]] 1291 | name = "time-core" 1292 | version = "0.1.2" 1293 | source = "registry+https://github.com/rust-lang/crates.io-index" 1294 | checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" 1295 | 1296 | [[package]] 1297 | name = "time-macros" 1298 | version = "0.2.16" 1299 | source = "registry+https://github.com/rust-lang/crates.io-index" 1300 | checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" 1301 | dependencies = [ 1302 | "time-core", 1303 | ] 1304 | 1305 | [[package]] 1306 | name = "to_method" 1307 | version = "1.1.0" 1308 | source = "registry+https://github.com/rust-lang/crates.io-index" 1309 | checksum = "c7c4ceeeca15c8384bbc3e011dbd8fccb7f068a440b752b7d9b32ceb0ca0e2e8" 1310 | 1311 | [[package]] 1312 | name = "tracing" 1313 | version = "0.1.40" 1314 | source = "registry+https://github.com/rust-lang/crates.io-index" 1315 | checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" 1316 | dependencies = [ 1317 | "pin-project-lite", 1318 | "tracing-attributes", 1319 | "tracing-core", 1320 | ] 1321 | 1322 | [[package]] 1323 | name = "tracing-attributes" 1324 | version = "0.1.27" 1325 | source = "registry+https://github.com/rust-lang/crates.io-index" 1326 | checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" 1327 | dependencies = [ 1328 | "proc-macro2", 1329 | "quote", 1330 | "syn 2.0.43", 1331 | ] 1332 | 1333 | [[package]] 1334 | name = "tracing-core" 1335 | version = "0.1.32" 1336 | source = "registry+https://github.com/rust-lang/crates.io-index" 1337 | checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" 1338 | dependencies = [ 1339 | "once_cell", 1340 | ] 1341 | 1342 | [[package]] 1343 | name = "unicase" 1344 | version = "2.7.0" 1345 | source = "registry+https://github.com/rust-lang/crates.io-index" 1346 | checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" 1347 | dependencies = [ 1348 | "version_check", 1349 | ] 1350 | 1351 | [[package]] 1352 | name = "unicode-ident" 1353 | version = "1.0.12" 1354 | source = "registry+https://github.com/rust-lang/crates.io-index" 1355 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 1356 | 1357 | [[package]] 1358 | name = "unicode-segmentation" 1359 | version = "1.10.1" 1360 | source = "registry+https://github.com/rust-lang/crates.io-index" 1361 | checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" 1362 | 1363 | [[package]] 1364 | name = "unicode-width" 1365 | version = "0.1.11" 1366 | source = "registry+https://github.com/rust-lang/crates.io-index" 1367 | checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" 1368 | 1369 | [[package]] 1370 | name = "version_check" 1371 | version = "0.9.4" 1372 | source = "registry+https://github.com/rust-lang/crates.io-index" 1373 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1374 | 1375 | [[package]] 1376 | name = "walkdir" 1377 | version = "2.4.0" 1378 | source = "registry+https://github.com/rust-lang/crates.io-index" 1379 | checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" 1380 | dependencies = [ 1381 | "same-file", 1382 | "winapi-util", 1383 | ] 1384 | 1385 | [[package]] 1386 | name = "wasi" 1387 | version = "0.11.0+wasi-snapshot-preview1" 1388 | source = "registry+https://github.com/rust-lang/crates.io-index" 1389 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1390 | 1391 | [[package]] 1392 | name = "wasm-bindgen" 1393 | version = "0.2.87" 1394 | source = "registry+https://github.com/rust-lang/crates.io-index" 1395 | checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" 1396 | dependencies = [ 1397 | "cfg-if", 1398 | "wasm-bindgen-macro", 1399 | ] 1400 | 1401 | [[package]] 1402 | name = "wasm-bindgen-backend" 1403 | version = "0.2.87" 1404 | source = "registry+https://github.com/rust-lang/crates.io-index" 1405 | checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" 1406 | dependencies = [ 1407 | "bumpalo", 1408 | "log", 1409 | "once_cell", 1410 | "proc-macro2", 1411 | "quote", 1412 | "syn 2.0.43", 1413 | "wasm-bindgen-shared", 1414 | ] 1415 | 1416 | [[package]] 1417 | name = "wasm-bindgen-futures" 1418 | version = "0.4.37" 1419 | source = "registry+https://github.com/rust-lang/crates.io-index" 1420 | checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" 1421 | dependencies = [ 1422 | "cfg-if", 1423 | "js-sys", 1424 | "wasm-bindgen", 1425 | "web-sys", 1426 | ] 1427 | 1428 | [[package]] 1429 | name = "wasm-bindgen-macro" 1430 | version = "0.2.87" 1431 | source = "registry+https://github.com/rust-lang/crates.io-index" 1432 | checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" 1433 | dependencies = [ 1434 | "quote", 1435 | "wasm-bindgen-macro-support", 1436 | ] 1437 | 1438 | [[package]] 1439 | name = "wasm-bindgen-macro-support" 1440 | version = "0.2.87" 1441 | source = "registry+https://github.com/rust-lang/crates.io-index" 1442 | checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" 1443 | dependencies = [ 1444 | "proc-macro2", 1445 | "quote", 1446 | "syn 2.0.43", 1447 | "wasm-bindgen-backend", 1448 | "wasm-bindgen-shared", 1449 | ] 1450 | 1451 | [[package]] 1452 | name = "wasm-bindgen-shared" 1453 | version = "0.2.87" 1454 | source = "registry+https://github.com/rust-lang/crates.io-index" 1455 | checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" 1456 | 1457 | [[package]] 1458 | name = "web-sys" 1459 | version = "0.3.64" 1460 | source = "registry+https://github.com/rust-lang/crates.io-index" 1461 | checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" 1462 | dependencies = [ 1463 | "js-sys", 1464 | "wasm-bindgen", 1465 | ] 1466 | 1467 | [[package]] 1468 | name = "winapi" 1469 | version = "0.3.9" 1470 | source = "registry+https://github.com/rust-lang/crates.io-index" 1471 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1472 | dependencies = [ 1473 | "winapi-i686-pc-windows-gnu", 1474 | "winapi-x86_64-pc-windows-gnu", 1475 | ] 1476 | 1477 | [[package]] 1478 | name = "winapi-i686-pc-windows-gnu" 1479 | version = "0.4.0" 1480 | source = "registry+https://github.com/rust-lang/crates.io-index" 1481 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1482 | 1483 | [[package]] 1484 | name = "winapi-util" 1485 | version = "0.1.6" 1486 | source = "registry+https://github.com/rust-lang/crates.io-index" 1487 | checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" 1488 | dependencies = [ 1489 | "winapi", 1490 | ] 1491 | 1492 | [[package]] 1493 | name = "winapi-x86_64-pc-windows-gnu" 1494 | version = "0.4.0" 1495 | source = "registry+https://github.com/rust-lang/crates.io-index" 1496 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1497 | 1498 | [[package]] 1499 | name = "yaml-rust" 1500 | version = "0.4.5" 1501 | source = "registry+https://github.com/rust-lang/crates.io-index" 1502 | checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" 1503 | dependencies = [ 1504 | "linked-hash-map", 1505 | ] 1506 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dioxus-markdown" 3 | version = "0.1.2" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | dioxus = "0.4.0" 10 | dioxus-web = "0.4.0" 11 | rust-web-markdown = { git = "https://github.com/rambip/rust-web-markdown/", default-features=false } 12 | 13 | [features] 14 | debug = ["rust-web-markdown/debug"] 15 | 16 | [workspace] 17 | members = [ 18 | "examples/*" 19 | ] 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Antonin Peronnet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Disclaimer 2 | 3 | This repository is now archived. 4 | It moved to **https://github.com/rambip/rust-web-markdown** 5 | 6 | That was the bad news. The good news is that in the meantime, you can use install `dioxus-markdown` from crates.io ! 7 | 8 | https://github.com/rambip/dioxus-markdown/edit/main/README.md 9 | 10 | 11 | # Goal 12 | A simple library to render markdown with dioxus, at runtime. 13 | The best rust crates are involved ! 14 | 15 | # Usage 16 | Add dioxus-markdown to your project: 17 | ```toml 18 | # Cargo.toml 19 | dioxus-markdown = {git="https://github.com/rambip/dioxus-markdown"} 20 | ``` 21 | 22 | If you just need to render basic markdown, you can do 23 | 24 | ```rust 25 | use dioxus_markdown::Markdown; 26 | ... 27 | rsx!{ 28 | Markdown {src:"# Mardown power !"} 29 | } 30 | ``` 31 | 32 | # Examples 33 | Take a look at the different examples ! 34 | You just need trunk and a web-browser to test them. 35 | 36 | ## Showcase 37 | the example is included in `./examples/showcase` 38 | 39 | Here is an illustration: 40 | ![](./img/showcase.jpg) 41 | 42 | see [here](https://rambip.github.io/dioxus-markdown/showcase) 43 | 44 | ## Editor 45 | Of course, a basic markdown editor is included. 46 | 47 | You can test for yourself [here](https://rambip.github.io/dioxus-markdown/editor) ! 48 | 49 | ## Interactivity 50 | see [here](https://rambip.github.io/dioxus-markdown/onclick) 51 | 52 | ## Custom Components 53 | 54 | You can define your own components in your code and call them inside markdown ! 55 | 56 | see [here](https://rambip.github.io/dioxus-markdown/custom_components) 57 | -------------------------------------------------------------------------------- /examples/custom_components/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "custom_components" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | dioxus = "0.4.0" 10 | dioxus-web = "0.4.0" 11 | dioxus-markdown = {path="../../"} 12 | -------------------------------------------------------------------------------- /examples/custom_components/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | custom components in markdown 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/custom_components/markdown.css: -------------------------------------------------------------------------------- 1 | blockquote { 2 | margin: 5px; border-left: 5px solid grey; 3 | padding: 5px; 4 | } 5 | 6 | blockquote p { 7 | margin: 5px 8 | } 9 | 10 | ul { 11 | list-style-type:disc 12 | } 13 | 14 | table { 15 | border: 1px solid black; border-collapse: collapse 16 | } 17 | 18 | td { 19 | border: 1px solid grey; padding: 5px 20 | } 21 | 22 | thead { 23 | background-color: #eee; font-weight: bold; 24 | } 25 | 26 | span.markdown-error { 27 | background-color: red; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /examples/custom_components/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | use dioxus::prelude::*; 3 | 4 | use dioxus_markdown::*; 5 | 6 | static MARKDOWN_SOURCE: &str = r#" 7 | ## Here is a counter: 8 | 9 | 10 | 11 | 12 | 13 | 14 | ## Here is a Box: 15 | 16 | 17 | **I am in a blue box !** 18 | 19 | 20 | "#; 21 | 22 | #[component] 23 | fn Counter(cx: Scope, initial: i32) -> Element { 24 | let mut count = use_state(cx, || *initial); 25 | 26 | cx.render(rsx!{ 27 | div{ 28 | button { 29 | onclick: move |_| count-=1, 30 | "-" 31 | }, 32 | "{count}", 33 | button { 34 | onclick: move |_| count+=1, 35 | "+" 36 | } 37 | } 38 | }) 39 | } 40 | 41 | #[component] 42 | fn ColorBox<'a>(cx: Scope, children: Element<'a>) -> Element<'a> { 43 | cx.render(rsx!{ 44 | div{ 45 | style: "border: 2px solid blue", 46 | children 47 | } 48 | }) 49 | } 50 | 51 | // create a component that renders a div with the text "Hello, world!" 52 | fn App(cx: Scope) -> Element { 53 | 54 | let mut components = CustomComponents::new(); 55 | 56 | components.register( 57 | "Counter", 58 | |cx, props| Ok(render!{ 59 | Counter {initial: props.get_parsed_optional("initial")?.unwrap_or(0)} 60 | }) 61 | ); 62 | 63 | components.register( 64 | "box", 65 | |cx, props| Ok(render!{ 66 | ColorBox {props.children} 67 | }) 68 | ); 69 | 70 | cx.render(rsx! { 71 | h1 {"Source"} 72 | Markdown { 73 | src: "```md\n{MARKDOWN_SOURCE}\n``" 74 | } 75 | 76 | h1 {"Result"} 77 | Markdown { 78 | src: MARKDOWN_SOURCE, 79 | components: components 80 | } 81 | }) 82 | } 83 | 84 | fn main() { 85 | // launch the web app 86 | dioxus_web::launch(App); 87 | } 88 | -------------------------------------------------------------------------------- /examples/editor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "markdown-editor" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | dioxus = "0.4.0" 10 | dioxus-web = "0.4.0" 11 | dioxus-markdown = {path="../..", features=["debug"]} 12 | -------------------------------------------------------------------------------- /examples/editor/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | markdown editor 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/editor/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | 3 | 4 | use dioxus::prelude::*; 5 | 6 | use dioxus_markdown::Markdown; 7 | use dioxus_markdown::debug::EventInfo; 8 | 9 | #[component] 10 | fn Logger(cx: Scope) -> Element { 11 | let debug_info = use_shared_state::(cx).unwrap(); 12 | render!{ 13 | debug_info.read().0.iter().map(|x: &String| cx.render(rsx!{li {x.clone()}})) 14 | } 15 | } 16 | 17 | 18 | fn App(cx: Scope) -> Element { 19 | let content = use_state(cx, || String::from("**bold**")); 20 | let wikilinks_enabled = use_state(cx, || false); 21 | let hardbreaks_enabled = use_state(cx, || false); 22 | let debug_enabled = use_state(cx, || false); 23 | 24 | use_shared_state_provider(cx, || EventInfo(vec![])); 25 | 26 | render!{ 27 | h1 {"Markdown Editor"}, 28 | div { 29 | class: "container", 30 | div { 31 | textarea { 32 | value: "{content}", 33 | rows: "30", 34 | oninput: move |evt| content.set(evt.value.clone()), 35 | }, 36 | div { 37 | label { r#for: "wiki", "enable wikilinks" }, 38 | input {r#type: "checkbox", id: "wiki", 39 | oninput: move |e| wikilinks_enabled.set(e.value=="true") 40 | } 41 | } 42 | div { 43 | label { r#for: "hardbreaks", "convert soft breaks to hard breaks" }, 44 | input {r#type: "checkbox", id: "hardbreaks", 45 | oninput: move |e| hardbreaks_enabled.set(e.value=="true") 46 | } 47 | } 48 | div { 49 | label { r#for: "debug", "enable debugging" }, 50 | input {r#type: "checkbox", id: "debug", 51 | oninput: move |e| debug_enabled.set(e.value=="true") 52 | } 53 | } 54 | }, 55 | div { 56 | class: "md-view", 57 | Markdown { 58 | src: content, 59 | wikilinks: *wikilinks_enabled.get(), 60 | hard_line_breaks: *hardbreaks_enabled.get(), 61 | }, 62 | } 63 | div { 64 | class: "debug-view", 65 | if **debug_enabled { 66 | cx.render(rsx!{ 67 | Logger {} 68 | }) 69 | } 70 | } 71 | } 72 | } 73 | } 74 | 75 | fn main() { 76 | dioxus_web::launch(App) 77 | } 78 | -------------------------------------------------------------------------------- /examples/editor/style.css: -------------------------------------------------------------------------------- 1 | .container { 2 | display: flex; 3 | align-items: top; 4 | } 5 | 6 | .md-view { 7 | border: 1px solid black; 8 | margin: 10px; 9 | width: 50% 10 | } 11 | 12 | .debug-view { 13 | margin: 40px; 14 | } 15 | -------------------------------------------------------------------------------- /examples/onclick/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "onclick" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | dioxus = "0.4.0" 10 | dioxus-web = "0.4.0" 11 | dioxus-markdown = {path="../.."} 12 | -------------------------------------------------------------------------------- /examples/onclick/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | interactivity in markdown 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/onclick/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | 3 | 4 | 5 | use dioxus::prelude::*; 6 | 7 | use dioxus_markdown::*; 8 | 9 | static MARKDOWN_SOURCE: &str = r#" 10 | # Interactive markdown experiment 11 | ## Goal 12 | This page illustrates how you can use the `onclick` property of the `Markdown` component in order to add some interactivity in your markdown 13 | 14 | ## Usage 15 | Test for yourself: click on any text on this page and it will appear highlighted in the source 16 | 17 | 18 | 19 | ## Code 20 | 21 | Here is how you can use it in your project: 22 | ```rust 23 | 24 | let range = use_state(|| 0..0); 25 | 26 | render!{ 27 | Markdown {src: source, on_click: move |e: MarkdownMouseEvent| 28 | range.set(e.position) 29 | } 30 | } 31 | ``` 32 | "#; 33 | 34 | 35 | fn App(cx: Scope) -> Element { 36 | let range = use_state(cx, || 0..0); 37 | 38 | let (before, x) = MARKDOWN_SOURCE.split_at(range.start); 39 | let (middle, after) = x.split_at(range.len()); 40 | 41 | render!{ 42 | div { 43 | Markdown {src:MARKDOWN_SOURCE, on_click:move |e: MarkdownMouseEvent|{ 44 | range.set(e.position); 45 | } 46 | } 47 | br {} 48 | hr {} 49 | pre { 50 | style: "border: 2 px solid orange", 51 | before 52 | span { 53 | style: "background-color: orange", 54 | middle 55 | } 56 | after 57 | } 58 | } 59 | } 60 | } 61 | 62 | fn main() { 63 | dioxus_web::launch(App) 64 | } 65 | -------------------------------------------------------------------------------- /examples/showcase/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "showcase" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | dioxus = "0.4.0" 10 | dioxus-web = "0.4.0" 11 | dioxus-markdown = {path="../../"} 12 | -------------------------------------------------------------------------------- /examples/showcase/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | showcase of markdown in-browser rendering 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/showcase/markdown.css: -------------------------------------------------------------------------------- 1 | blockquote { 2 | margin: 5px; border-left: 5px solid grey; 3 | padding: 5px; 4 | } 5 | 6 | blockquote p { 7 | margin: 5px 8 | } 9 | 10 | ul { 11 | list-style-type:disc 12 | } 13 | 14 | table { 15 | border: 1px solid black; border-collapse: collapse 16 | } 17 | 18 | td { 19 | border: 1px solid grey; padding: 5px 20 | } 21 | 22 | thead { 23 | background-color: #eee; font-weight: bold; 24 | } 25 | 26 | span.markdown-error { 27 | background-color: red; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /examples/showcase/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | // import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types 3 | use dioxus::prelude::*; 4 | 5 | use dioxus_markdown::*; 6 | 7 | static MARKDOWN_SOURCE: &str = r#" 8 | ## Code 9 | ```rust 10 | fn main() { 11 | println!("hello world !") 12 | } 13 | ``` 14 | 15 | ## Math 16 | - $1+1=2$ 17 | 18 | - $e^{i\pi}+1=0$ 19 | 20 | 21 | $$\int_0^{+\infty}\dfrac{\sin(t)}{t}\,dt=\dfrac{\sqrt{\pi}}{2}$$ 22 | 23 | 24 | ## Links and images 25 | ![](https://raw.githubusercontent.com/wooorm/markdown-rs/8924580/media/logo-monochromatic.svg?sanitize=true) 26 | 27 | for markdown documentation, see [here](https://commonmark.org/help/) 28 | 29 | Wikilinks are supported to: [[https://en.wikipedia.org/wiki/Markdown|markdown]] 30 | 31 | ## Style 32 | | unstyled | styled | 33 | | :-----: | ------ | 34 | | bold | **bold** | 35 | | italics | *italics* | 36 | | strike | ~strike~ | 37 | 38 | > Hey, I am a quote ! 39 | 40 | ## Lists 41 | 1) one 42 | 2) two 43 | 3) three 44 | 45 | - and 46 | - unorderded 47 | - too 48 | 49 | Even todo lists: 50 | - [ ] todo 51 | - [x] done 52 | "#; 53 | 54 | // create a component that renders a div with the text "Hello, world!" 55 | fn App(cx: Scope) -> Element { 56 | cx.render(rsx! { 57 | Markdown { 58 | src: MARKDOWN_SOURCE, 59 | wikilinks: true, 60 | } 61 | }) 62 | } 63 | 64 | fn main() { 65 | // launch the web app 66 | dioxus_web::launch(App); 67 | } 68 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "crane": { 4 | "inputs": { 5 | "nixpkgs": [ 6 | "nixpkgs" 7 | ] 8 | }, 9 | "locked": { 10 | "lastModified": 1703439018, 11 | "narHash": "sha256-VT+06ft/x3eMZ1MJxWzQP3zXFGcrxGo5VR2rB7t88hs=", 12 | "owner": "ipetkov", 13 | "repo": "crane", 14 | "rev": "afdcd41180e3dfe4dac46b5ee396e3b12ccc967a", 15 | "type": "github" 16 | }, 17 | "original": { 18 | "owner": "ipetkov", 19 | "repo": "crane", 20 | "type": "github" 21 | } 22 | }, 23 | "flake-utils": { 24 | "inputs": { 25 | "systems": "systems" 26 | }, 27 | "locked": { 28 | "lastModified": 1701680307, 29 | "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", 30 | "owner": "numtide", 31 | "repo": "flake-utils", 32 | "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", 33 | "type": "github" 34 | }, 35 | "original": { 36 | "owner": "numtide", 37 | "repo": "flake-utils", 38 | "type": "github" 39 | } 40 | }, 41 | "nixpkgs": { 42 | "locked": { 43 | "lastModified": 1703499205, 44 | "narHash": "sha256-lF9rK5mSUfIZJgZxC3ge40tp1gmyyOXZ+lRY3P8bfbg=", 45 | "owner": "NixOS", 46 | "repo": "nixpkgs", 47 | "rev": "e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870", 48 | "type": "github" 49 | }, 50 | "original": { 51 | "owner": "NixOS", 52 | "ref": "nixpkgs-unstable", 53 | "repo": "nixpkgs", 54 | "type": "github" 55 | } 56 | }, 57 | "nixpkgs_2": { 58 | "locked": { 59 | "lastModified": 1681358109, 60 | "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", 61 | "owner": "NixOS", 62 | "repo": "nixpkgs", 63 | "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", 64 | "type": "github" 65 | }, 66 | "original": { 67 | "owner": "NixOS", 68 | "ref": "nixpkgs-unstable", 69 | "repo": "nixpkgs", 70 | "type": "github" 71 | } 72 | }, 73 | "root": { 74 | "inputs": { 75 | "crane": "crane", 76 | "flake-utils": "flake-utils", 77 | "nixpkgs": "nixpkgs", 78 | "rust-overlay": "rust-overlay" 79 | } 80 | }, 81 | "rust-overlay": { 82 | "inputs": { 83 | "flake-utils": [ 84 | "flake-utils" 85 | ], 86 | "nixpkgs": "nixpkgs_2" 87 | }, 88 | "locked": { 89 | "lastModified": 1703729606, 90 | "narHash": "sha256-5QlUMNPKv++mWlS2r3F8bffoSBHXq1qHg+V5mnfSixg=", 91 | "owner": "oxalica", 92 | "repo": "rust-overlay", 93 | "rev": "347789ef125df15b685e8295364ad8ed331fef94", 94 | "type": "github" 95 | }, 96 | "original": { 97 | "owner": "oxalica", 98 | "repo": "rust-overlay", 99 | "type": "github" 100 | } 101 | }, 102 | "systems": { 103 | "locked": { 104 | "lastModified": 1681028828, 105 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 106 | "owner": "nix-systems", 107 | "repo": "default", 108 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 109 | "type": "github" 110 | }, 111 | "original": { 112 | "owner": "nix-systems", 113 | "repo": "default", 114 | "type": "github" 115 | } 116 | } 117 | }, 118 | "root": "root", 119 | "version": 7 120 | } 121 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "a dioxus markdown component"; 3 | 4 | inputs = { 5 | flake-utils.url = "github:numtide/flake-utils"; 6 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 7 | rust-overlay = { 8 | url = "github:oxalica/rust-overlay"; 9 | inputs = { 10 | flake-utils.follows = "flake-utils"; 11 | }; 12 | }; 13 | crane = { 14 | url = "github:ipetkov/crane"; 15 | inputs.nixpkgs.follows = "nixpkgs"; 16 | }; 17 | }; 18 | 19 | outputs = { self, rust-overlay, nixpkgs, flake-utils, crane }: 20 | flake-utils.lib.eachDefaultSystem (system: 21 | let 22 | pkgs = import nixpkgs { 23 | inherit system; 24 | overlays = [ (import rust-overlay) ]; 25 | }; 26 | inherit (pkgs) lib; 27 | 28 | rustToolchain = pkgs.rust-bin.stable.latest.default.override { 29 | targets = [ "wasm32-unknown-unknown" ]; 30 | }; 31 | 32 | craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; 33 | 34 | # discard the directories inside examples to build the library less often 35 | libSrc = lib.cleanSourceWith { 36 | src = ./.; 37 | filter = path: type: 38 | (builtins.match ".*examples/.*" path == null) 39 | && (craneLib.filterCargoSources path type) 40 | ; 41 | }; 42 | 43 | fullSrc = lib.cleanSourceWith { 44 | src = ./.; 45 | filter = path: type: 46 | (lib.hasSuffix "\.html" path) || (lib.hasSuffix "\.css" path) 47 | || (craneLib.filterCargoSources path type) 48 | ; 49 | }; 50 | 51 | CARGO_BUILD_TARGET = "wasm32-unknown-unknown"; 52 | 53 | # Build *just* the cargo dependencies, so we can reuse 54 | # all of that work (e.g. via cachix) when running in CI 55 | cargoArtifacts = craneLib.buildDepsOnly { 56 | inherit CARGO_BUILD_TARGET; 57 | src = libSrc; 58 | doCheck = false; 59 | }; 60 | 61 | wasmBindgen = pkgs.wasm-bindgen-cli.override { 62 | version = "0.2.87"; 63 | hash = "sha256-0u9bl+FkXEK2b54n7/l9JOCtKo+pb42GF9E1EnAUQa0="; 64 | cargoHash = "sha256-AsZBtE2qHJqQtuCt/wCAgOoxYMfvDh8IzBPAOkYSYko="; 65 | }; 66 | 67 | buildExample = name: craneLib.buildTrunkPackage { 68 | inherit CARGO_BUILD_TARGET cargoArtifacts; 69 | src = fullSrc; 70 | pname = "dioxus-markdown-${name}"; 71 | trunkIndexPath = "examples/${name}/index.html"; 72 | cargoExtraArgs = "--package=./examples/${name}"; 73 | # RELATIVE URLS are a MESS 74 | # https://github.com/thedodd/trunk/pull/470 75 | trunkExtraBuildArgs = "--public-url=/dioxus-markdown/${name}"; 76 | 77 | nativeBuildInputs = [ 78 | wasmBindgen 79 | ]; 80 | }; 81 | example_names = builtins.attrNames(builtins.readDir ./examples); 82 | attr_examples = builtins.map 83 | (name: {inherit name; path=buildExample name; value=buildExample name;}) 84 | example_names; 85 | 86 | examples = builtins.listToAttrs attr_examples; 87 | in 88 | { 89 | checks = {}; 90 | packages = examples // { 91 | default = pkgs.linkFarm "dioxus-markdown examples" attr_examples; 92 | }; 93 | 94 | devShells.default = pkgs.mkShell { 95 | buildInputs = with pkgs; [ 96 | rustToolchain 97 | dioxus-cli 98 | binaryen 99 | openssl 100 | pkg-config 101 | trunk 102 | rust-analyzer 103 | wasmBindgen 104 | ]; 105 | }; 106 | } 107 | ); 108 | } 109 | 110 | -------------------------------------------------------------------------------- /img/showcase.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rambip/dioxus-markdown/a4278d670ecf06256da18901ab34640321077eb0/img/showcase.jpg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | a random yew project 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | use rust_web_markdown::{ 2 | render_markdown, 3 | CowStr, 4 | }; 5 | 6 | use std::collections::BTreeMap; 7 | 8 | pub type MdComponentProps<'a> = rust_web_markdown::MdComponentProps>; 9 | 10 | use core::ops::Range; 11 | 12 | pub use rust_web_markdown::{ 13 | LinkDescription, Options, 14 | HtmlElement, 15 | Context, 16 | ElementAttributes, 17 | ComponentCreationError, 18 | }; 19 | 20 | use dioxus::prelude::*; 21 | 22 | use std::rc::Rc; 23 | 24 | pub type HtmlCallback<'a, T> = Rc Element<'a>>; 25 | 26 | #[cfg(feature="debug")] 27 | pub mod debug { 28 | #[derive(Clone)] 29 | pub struct EventInfo(pub Vec); 30 | } 31 | 32 | 33 | #[derive(Props)] 34 | pub struct MdProps<'a> { 35 | src: &'a str, 36 | 37 | /// the callback called when a component is clicked. 38 | /// if you want to controll what happens when a link is clicked, 39 | /// use [`render_links`][render_links] 40 | on_click: Option>, 41 | 42 | /// 43 | render_links: Option>>>, 44 | 45 | /// the name of the theme used for syntax highlighting. 46 | /// Only the default themes of [syntect::Theme] are supported 47 | theme: Option, 48 | 49 | /// wether to enable wikilinks support. 50 | /// Wikilinks look like [[shortcut link]] or [[url|name]] 51 | #[props(default = false)] 52 | wikilinks: bool, 53 | 54 | /// wether to convert soft breaks to hard breaks. 55 | #[props(default = false)] 56 | hard_line_breaks: bool, 57 | 58 | /// pulldown_cmark options. 59 | /// See [`Options`][pulldown_cmark_wikilink::Options] for reference. 60 | parse_options: Option, 61 | 62 | #[props(default)] 63 | components: CustomComponents<'a>, 64 | 65 | frontmatter: Option>, 66 | } 67 | 68 | #[derive(Clone, Debug)] 69 | pub struct MarkdownMouseEvent { 70 | /// the original mouse event triggered when a text element was clicked on 71 | pub mouse_event: MouseEvent, 72 | 73 | /// the corresponding range in the markdown source, as a slice of [`u8`][u8] 74 | pub position: Range, 75 | 76 | // TODO: add a clonable tag for the type of the element 77 | // pub tag: pulldown_cmark::Tag<'a>, 78 | } 79 | 80 | #[derive(Clone, Copy)] 81 | pub struct MdContext<'a>(pub &'a Scoped<'a, MdProps<'a>>); 82 | 83 | 84 | /// component store. 85 | /// It is called when therer is a `` inside the markdown source. 86 | /// It is basically a hashmap but more efficient for a small number of items 87 | pub struct CustomComponents<'a>(BTreeMap<&'static str, 88 | Box) -> Result, ComponentCreationError>> 89 | >); 90 | 91 | impl Default for CustomComponents<'_> { 92 | fn default() -> Self { 93 | Self (Default::default()) 94 | } 95 | } 96 | 97 | impl<'a> CustomComponents<'a> 98 | { 99 | pub fn new() -> Self { 100 | Self(Default::default()) 101 | } 102 | 103 | /// register a new component. 104 | /// The function `component` takes a context and props of type `MdComponentProps` 105 | /// and returns html 106 | pub fn register(&mut self, name: &'static str, component: F) 107 | where F: Fn(&'a ScopeState, MdComponentProps<'a>) -> Result, ComponentCreationError> + 'static 108 | { 109 | self.0.insert(name, Box::new(component)); 110 | } 111 | } 112 | 113 | impl<'a> Context<'a, 'a> for MdContext<'a> { 114 | type View = Element<'a>; 115 | 116 | type Handler = EventHandler<'a, T>; 117 | 118 | type MouseEvent = MouseEvent; 119 | 120 | #[cfg(feature="debug")] 121 | fn send_debug_info(self, info: Vec) { 122 | let debug = use_shared_state::(self.0).unwrap(); 123 | // to avoid re-rendering the parent component 124 | // if not needed 125 | if *debug.read().0 != info { 126 | debug.write().0 = info 127 | } 128 | } 129 | 130 | fn el_with_attributes(self, e: HtmlElement, inside: Self::View, attributes: ElementAttributes>) -> Self::View { 131 | let class = attributes.classes.join(" "); 132 | let style = attributes.style.unwrap_or_default(); 133 | let onclick = attributes.on_click.unwrap_or_default(); 134 | let onclick = move |e| onclick.call(e); 135 | 136 | let vnode = match e { 137 | HtmlElement::Div => rsx!{div {onclick:onclick, style: "{style}", class: "{class}", inside } }, 138 | HtmlElement::Span => rsx!{span {onclick: onclick, style: "{style}", class: "{class}", inside } }, 139 | HtmlElement::Paragraph => rsx!{p {onclick: onclick, style: "{style}", class: "{class}", inside } }, 140 | HtmlElement::BlockQuote => rsx!{blockquote {onclick: onclick, style: "{style}", class: "{class}", inside } }, 141 | HtmlElement::Ul => rsx!{ul {onclick: onclick, style: "{style}", class: "{class}", inside } }, 142 | HtmlElement::Ol(x) => rsx!{ol {onclick: onclick, style: "{style}", class: "{class}", start: x as i64, inside } }, 143 | HtmlElement::Li => rsx!{li {onclick: onclick, style: "{style}", class: "{class}", inside } }, 144 | HtmlElement::Heading(1) => rsx!{h1 {onclick: onclick, style: "{style}", class: "{class}", inside } }, 145 | HtmlElement::Heading(2) => rsx!{h2 {onclick: onclick, style: "{style}", class: "{class}", inside } }, 146 | HtmlElement::Heading(3) => rsx!{h3 {onclick: onclick, style: "{style}", class: "{class}", inside } }, 147 | HtmlElement::Heading(4) => rsx!{h4 {onclick: onclick, style: "{style}", class: "{class}", inside } }, 148 | HtmlElement::Heading(5) => rsx!{h5 {onclick: onclick, style: "{style}", class: "{class}", inside } }, 149 | HtmlElement::Heading(6) => rsx!{h6 {onclick: onclick, style: "{style}", class: "{class}", inside } }, 150 | HtmlElement::Heading(_) => panic!(), 151 | HtmlElement::Table => rsx!{table {onclick: onclick, style: "{style}", class: "{class}", inside } }, 152 | HtmlElement::Thead => rsx!{thead {onclick: onclick, style: "{style}", class: "{class}", inside } }, 153 | HtmlElement::Trow => rsx!{tr {onclick: onclick, style: "{style}", class: "{class}", inside } }, 154 | HtmlElement::Tcell => rsx!{td {onclick: onclick, style: "{style}", class: "{class}", inside } }, 155 | HtmlElement::Italics => rsx!{i {onclick: onclick, style: "{style}", class: "{class}", inside } }, 156 | HtmlElement::Bold => rsx!{b {onclick: onclick, style: "{style}", class: "{class}", inside } }, 157 | HtmlElement::StrikeThrough => rsx!{s {onclick: onclick, style: "{style}", class: "{class}", inside } }, 158 | HtmlElement::Pre => rsx!{p {onclick: onclick, style: "{style}", class: "{class}", inside } }, 159 | HtmlElement::Code => rsx!{code {onclick: onclick, style: "{style}", class: "{class}", inside } }, 160 | }; 161 | 162 | let r: Element<'a> = self.0.render(vnode); 163 | r 164 | } 165 | 166 | fn el_span_with_inner_html(self, inner_html: String, attributes: ElementAttributes>) -> Self::View { 167 | let class = attributes.classes.join(" "); 168 | let style = attributes.style.unwrap_or_default(); 169 | let onclick = move |e| { 170 | if let Some(f) = &attributes.on_click { 171 | f.call(e) 172 | } 173 | }; 174 | self.0.render(rsx!{ 175 | span { 176 | dangerous_inner_html: "{inner_html}", 177 | style: "{style}", 178 | class: "{class}", 179 | onclick: onclick 180 | } 181 | }) 182 | } 183 | 184 | fn el_hr(self, attributes: ElementAttributes>) -> Self::View { 185 | let class = attributes.classes.join(" "); 186 | let style = attributes.style.unwrap_or_default(); 187 | let onclick = move |e| { 188 | if let Some(f) = &attributes.on_click { 189 | f.call(e) 190 | } 191 | }; 192 | self.0.render(rsx!(hr {onclick: onclick, style: "{style}", class: "{class}"})) 193 | } 194 | 195 | fn el_br(self)-> Self::View { 196 | self.0.render(rsx!(br {})) 197 | } 198 | 199 | fn el_fragment(self, children: Vec) -> Self::View { 200 | self.0.render( 201 | rsx!{children.into_iter()} 202 | ) 203 | } 204 | 205 | fn el_a(self, children: Self::View, href: String) -> Self::View { 206 | self.0.render( 207 | rsx!{a {href: "{href}", children}} 208 | ) 209 | } 210 | 211 | fn el_img(self, src: String, alt: String) -> Self::View { 212 | self.0.render( 213 | rsx!( 214 | img {src: "{src}", alt: "{alt}"} 215 | ) 216 | ) 217 | } 218 | 219 | fn el_text(self, text: CowStr<'a>) -> Self::View { 220 | self.0.render(rsx!{text.as_ref()}) 221 | } 222 | 223 | fn mount_dynamic_link(self, rel: &str, href: &str, integrity: &str, crossorigin: &str) { 224 | // let create_eval = use_eval(self.0); 225 | 226 | // let eval = create_eval( 227 | // r#" 228 | // // https://stackoverflow.com/a/18510577 229 | // let rel = await dioxus.recv(); 230 | // let href = await dioxus.recv(); 231 | // let integrity = await dioxus.recv(); 232 | // let crossorigin = await dioxus.recv(); 233 | // var newstyle = document.createElement("link"); // Create a new link Tag 234 | 235 | // newstyle.setAttribute("rel", rel); 236 | // newstyle.setAttribute("type", "text/css"); 237 | // newstyle.setAttribute("href", href); 238 | // newstyle.setAttribute("crossorigin", crossorigin); 239 | // newstyle.setAttribute("integrity", integrity); 240 | // document.getElementsByTagName("head")[0].appendChild(newstyle); 241 | // "#, 242 | // ) 243 | // .unwrap(); 244 | 245 | // // You can send messages to JavaScript with the send method 246 | // eval.send(rel.into()).unwrap(); 247 | // eval.send(href.into()).unwrap(); 248 | // eval.send(integrity.into()).unwrap(); 249 | // eval.send(crossorigin.into()).unwrap(); 250 | } 251 | 252 | 253 | fn el_input_checkbox(self, checked: bool, attributes: ElementAttributes>) -> Self::View { 254 | let class = attributes.classes.join(" "); 255 | let style = attributes.style.unwrap_or_default(); 256 | let onclick = move |e| { 257 | if let Some(f) = &attributes.on_click { 258 | f.call(e) 259 | } 260 | }; 261 | self.0.render(rsx!(input { 262 | r#type: "checkbox", 263 | checked: checked, 264 | style: "{style}", 265 | class: "{class}", 266 | onclick: onclick 267 | })) 268 | } 269 | 270 | fn props(self) -> rust_web_markdown::MarkdownProps<'a> { 271 | let props = self.0.props; 272 | 273 | rust_web_markdown::MarkdownProps { 274 | hard_line_breaks: props.hard_line_breaks, 275 | wikilinks: props.wikilinks, 276 | parse_options: props.parse_options.as_ref(), 277 | theme: props.theme.as_deref(), 278 | } 279 | 280 | } 281 | 282 | fn call_handler(callback: &Self::Handler, input: T) { 283 | callback.call(input) 284 | } 285 | 286 | fn make_md_handler(self, position: std::ops::Range, stop_propagation: bool) -> Self::Handler { 287 | let on_click = self.0.props.on_click.as_ref(); 288 | 289 | self.0.event_handler(move |e: MouseEvent| { 290 | if stop_propagation{ 291 | e.stop_propagation() 292 | } 293 | 294 | let report = MarkdownMouseEvent { 295 | position: position.clone(), 296 | mouse_event: e 297 | }; 298 | 299 | on_click.map(|x| x.call(report)); 300 | }) 301 | } 302 | 303 | fn set_frontmatter(self, frontmatter: String) { 304 | self.0.props.frontmatter.as_ref().map(|x| x.set(frontmatter)); 305 | } 306 | 307 | fn has_custom_links(self) -> bool { 308 | self.0.props.render_links.is_some() 309 | } 310 | 311 | fn render_links(self, link: LinkDescription) 312 | -> Result { 313 | // TODO: remove the unwrap call 314 | Ok(self.0.props.render_links.as_ref().unwrap()(self.0.scope, link)) 315 | } 316 | 317 | fn has_custom_component(self, name: &str) -> bool { 318 | self.0.props.components.0.get(name).is_some() 319 | } 320 | 321 | fn render_custom_component(self, name: &str, input: rust_web_markdown::MdComponentProps) -> Result { 322 | let f = self.0.props.components.0.get(name).unwrap(); 323 | f(self.0.scope, input) 324 | } 325 | } 326 | 327 | #[allow(non_snake_case)] 328 | pub fn Markdown<'a>(cx: &'a Scoped>) -> Element<'a> { 329 | let context = MdContext(cx); 330 | render_markdown(context, cx.props.src) 331 | } 332 | --------------------------------------------------------------------------------