You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This one might be done quite easily by using include_str... but it would be a lot of repetitive lines, since highlight.js has tons of separate files with different language support. It could all be packed into one file and exported, but it would be a large file, with lots of stuff that would never be used.
Currently, the code knows which code languages are being used on the markdown page, so there's no issue in including just the right files. So an "easy" way to solve this issue is something like:
Create a folder in res with an import of highlight.js files.
Create a hashmap, maybe with lazy_static or once_cell with include_str lines for these.
Package them up in a struct with a sensible interface to write these script files like we do here:
An interesting, more complicated idea, might be to make this reusable, maybe even pull this concept into a separate crate. Something like an include_dir! proc macro that recursively reads the whole contents of a directory, and does the whole lazy-static hashmap setup above, it just doesn't require somebody to manually go over the individual files in the source. The hashmap that include_dir! spits out could be keyed by a Path. The contents might even be compressed like include_flate does, but that's a separate thing.
The text was updated successfully, but these errors were encountered:
This one might be done quite easily by using
include_str
... but it would be a lot of repetitive lines, since highlight.js has tons of separate files with different language support. It could all be packed into one file and exported, but it would be a large file, with lots of stuff that would never be used.Currently, the code knows which code languages are being used on the markdown page, so there's no issue in including just the right files. So an "easy" way to solve this issue is something like:
res
with an import ofhighlight.js
files.lazy_static
oronce_cell
withinclude_str
lines for these.quickmd/src/assets.rs
Lines 88 to 93 in 9e09b02
An interesting, more complicated idea, might be to make this reusable, maybe even pull this concept into a separate crate. Something like an
include_dir!
proc macro that recursively reads the whole contents of a directory, and does the whole lazy-static hashmap setup above, it just doesn't require somebody to manually go over the individual files in the source. The hashmap thatinclude_dir!
spits out could be keyed by aPath
. The contents might even be compressed likeinclude_flate
does, but that's a separate thing.The text was updated successfully, but these errors were encountered: