metafates / marky

🏭 Convert Markdown documents into themed HTML pages with support for code syntax highlighting, LaTeX and Mermaid diagrams.
https://crates.io/crates/marky
27 stars 2 forks source link

How to use as a library #5

Open sdasda7777 opened 1 year ago

sdasda7777 commented 1 year ago

Hi, I'd love to use your project as a dependency for a tool I'm planning.

Could you please add an example of how to use it to convert Markdown String into HTML String?

sidju commented 1 year ago

Since there isn't any lib.rs file in the src directory it isn't possible to use this crate as a library. Also, you probably don't want to; most of the crate is handling of CLI, web-serving, watching for changes and user interaction.

The library used by marky for markdown parsing is https://crates.io/crates/markdown (note that marky uses version 1.0.0-alpha5, not the 0.0.3 version most visible on crates.io). That is probably the library you'd wish to use.

Finally: From what I can find markys markdown to html conversion logic is in this file: https://github.com/metafates/marky/blob/master/src/document.rs so you can probably take inspiration from it to create your own.