Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geckoeidechse/mdbook-obsidian
mdBook preprocessor to render Obsidian specific syntax
https://github.com/geckoeidechse/mdbook-obsidian
mdbook mdbook-preprocessor obsidian obsidian-md rust
Last synced: 2 months ago
JSON representation
mdBook preprocessor to render Obsidian specific syntax
- Host: GitHub
- URL: https://github.com/geckoeidechse/mdbook-obsidian
- Owner: GeckoEidechse
- License: mpl-2.0
- Created: 2024-02-05T14:16:00.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-30T23:28:31.000Z (9 months ago)
- Last Synced: 2024-03-31T00:21:33.929Z (9 months ago)
- Topics: mdbook, mdbook-preprocessor, obsidian, obsidian-md, rust
- Language: Rust
- Homepage: https://crates.io/crates/mdbook-obsidian
- Size: 1.14 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# mdbook-obsidian
[![crates.io](https://img.shields.io/crates/v/mdbook-obsidian.svg)](https://crates.io/crates/mdbook-obsidian)
[![MPL 2.0 LICENSE](https://img.shields.io/github/license/GeckoEidechse/mdbook-obsidian.svg)](LICENSE)
[![docs.rs](https://docs.rs/mdbook-obsidian/badge.svg)](https://docs.rs/mdbook-obsidian)
[![Build](https://github.com/GeckoEidechse/mdbook-obsidian/actions/workflows/build.yml/badge.svg)](https://github.com/GeckoEidechse/mdbook-obsidian/actions/workflows/build.yml)
[![Test](https://github.com/GeckoEidechse/mdbook-obsidian/actions/workflows/test.yml/badge.svg)](https://github.com/GeckoEidechse/mdbook-obsidian/actions/workflows/test.yml)[mdBook](https://github.com/rust-lang/mdBook) preprocessor to render [Obsidian](https://obsidian.md/) specific syntax in mdBook.
To see the preprocessor in action, check out [this rendered example book](https://geckoeidechse.github.io/mdbook-obsidian/).
To see the list of existing and supported syntax, see [this GitHub issue](https://github.com/GeckoEidechse/mdbook-obsidian/issues/1).
> ⚠️ WIP ⚠️
>
> This mdBook preprocessor is very much work-in-progress and currently only supports a small subset of the total Obsidian specific syntax.
> Contributions to expand the supported syntax are more than welcome <3
>
> If you'd like to take over maintainership or ownership of this crate, please get in touch via an issue in the GitHub repo of this crate.## Usage
First, install the preprocessor:
```bash
cargo install mdbook-obsidian
```Then, add the preprocessor to your `book.toml`:
```toml
[book]
authors = ["Jill Doe"]
language = "en"
multilingual = false
src = "src"
title = "My awesome Book"# ADD THIS
[preprocessor.obsidian]```
## Development
### How it works
The way this preprocessor works is primarily by using regexes to search for specific patterns like
```markdown
> [!CALLOUT_TYPE]
> CALLOUT_BODY
```and then replacing it with the corresponding HTML code like
```html
/* a bunch of CSS */
CALLOUT_TYPE
CALLOUT_BODY
```### Expanding the preprocessor
The currently supported syntax is tracked in [this GitHub issue](https://github.com/GeckoEidechse/mdbook-obsidian/issues/1)
To add support for some currently unsupported syntax, expand the existing existing main render loop in `lib.rs`
```rust
/// Apply to all chapters
fn handle_chapter(chapter: &mut Chapter) -> Result<(), Error> {
chapter.content = callouts::render(&chapter.content)?;
// Add your additional syntax parsing hereOk(())
}
```with a function that calls the corresponding parsing logic.
In your parsing logic, use regex or any other methods to scan for the specific pattern of the syntax you want to support and replace it with the corresponding HTML code.