Skip to content

Commit ba2fba1

Browse files
committed
chore: release 0.2.9
add more apps to docs and upgrade packages
1 parent b527f4d commit ba2fba1

File tree

8 files changed

+486
-336
lines changed

8 files changed

+486
-336
lines changed

Cargo.lock

Lines changed: 391 additions & 324 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[package]
22
name = "mdbook-embedify"
3-
version = "0.2.8"
3+
version = "0.2.9"
44
edition = "2021"
55
license = "MIT"
66
readme = "README.md"
77
exclude = ["docs/*"]
8-
keywords = ["mdbook", "embed", "plugin"]
8+
keywords = ["mdbook", "embed", "plugin", "preprocessor"]
99
authors = ["MR-Addict <[email protected]>"]
1010
repository = "https://github.com/MR-Addict/mdbook-embedify"
1111
documentation = "https://mr-addict.github.io/mdbook-embedify"
1212
description = "A rust based mdbook preprocessor plugin that allows you to embed apps to your book, like youtube, codepen and some other apps"
1313

1414
[dependencies]
15-
clap = "4.4.18"
16-
mdbook = "0.4.37"
17-
pulldown-cmark = "0.10.0"
18-
regex = "1.10.3"
19-
rust-embed = "8.2.0"
20-
serde_json = "1.0.111"
15+
clap = "4.5.10"
16+
mdbook = "0.4.40"
17+
pulldown-cmark = "0.11.0"
18+
regex = "1.10.5"
19+
rust-embed = "8.5.0"
20+
serde_json = "1.0.120"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ Then you can use `embed` macro to embed an app. The syntax is like this:
4747
![preview](preview.png)
4848

4949
You can see a live demo and more detailed documentation [here](https://mr-addict.github.io/mdbook-embedify).
50+
51+
## 4. More Apps
52+
53+
If you want to add more apps to this preprocessor, you can follow the instructions [here](https://mr-addict.github.io/mdbook-embedify/more-apps.html).

docs/book.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ use-default-preprocessors = false
1414
[output.html]
1515
default-theme = "Light"
1616
preferred-dark-theme = "Ayu"
17-
curly-quotes = true
17+
smart-punctuation = true
1818
mathjax-support = true
1919
copy-fonts = true
2020
no-section-label = false
2121
git-repository-url = "https://github.com/mr-addict/mdbook-embedify"
22-
edit-url-template = "https://github.com/mr-addict/mdbook-embedify/edit/main/example/{path}"
22+
edit-url-template = "https://github.com/mr-addict/mdbook-embedify/edit/main/docs/{path}"
2323
additional-css = ["assets/css/patch.css"]
2424

2525
[output.html.print]

docs/src/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
- [Intro](index.md)
66
- [Usage](usage.md)
7-
- [Ignore Embeds](ignore-embeds.md)
87
- [Global Embedding](global-embedding.md)
8+
- [Ignore Embeds](ignore-embeds.md)
9+
- [More Apps](more-apps.md)
910

1011
# Apps
1112

docs/src/more-apps.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# More Apps
2+
3+
In this section, I will show you how to add more apps to this preprocessor.
4+
5+
## Create a new app
6+
7+
You may have some other apps that this preprocessor doesn't support. Actually, it's very easy to add a new app based on my custom template engine.
8+
9+
What we need to do is put a new app template in the `templates` folder. The template file name should be the app name.
10+
11+
For example we want to add a new app called `youtube`, and we know that youtube embedding code is using an iframe. It looks like this:
12+
13+
```html
14+
<iframe
15+
allowfullscreen
16+
name="youtube"
17+
loading="lazy"
18+
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
19+
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
20+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
21+
></iframe>
22+
```
23+
24+
> 💥Attention
25+
>
26+
> You can even add `style` and `js` content to the template file. you can take a look of [scroll-to-top](templates/scroll-to-top.html) example.
27+
28+
## Add options
29+
30+
We want the src youtube `id` and `loading` strategy to be dynamic and loading strategy has default `lazy` value. So we can replace them with placeholders like this:
31+
32+
```html
33+
<iframe
34+
allowfullscreen
35+
name="youtube"
36+
loading="{% raw(loading=lazy) %}"
37+
src="https://www.youtube.com/embed/{% raw(id) %}"
38+
style="width: 100%; height: 100%; border: none; aspect-ratio: 16/9; border-radius: 1rem; background: black"
39+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
40+
></iframe>
41+
```
42+
43+
The placeholder syntax is similar to a **function call** in programming languages.
44+
45+
Which `raw` means the value will not be changed. Now the preprocessor supports two functions, `raw` and `markdown`. `markdown` call will treat the value as markdown content and render it to be html. This call is used in `footer` and `announcement-banner` apps. And inner value will be the `key`, if the key has a `default` value, we put an equal sign and the default value after the key.
46+
47+
## Build the project
48+
49+
After build the project, the new app will be automatically added to the preprocessor binary.
50+
51+
```sh
52+
cargo build --release
53+
```
54+
55+
And you can use it in your book:
56+
57+
<!-- embed ignore begin -->
58+
59+
```text
60+
{% embed youtube id="dQw4w9WgXcQ" loading="eager" %}
61+
```
62+
63+
Because the `loading` key has a default value `lazy`, we can omit it.
64+
65+
```text
66+
{% embed youtube id="dQw4w9WgXcQ" %}
67+
```
68+
69+
<!-- embed ignore end -->
70+
71+
If you are using this repository as a template, then you can build your book to see the result by running:
72+
73+
```sh
74+
mdbook build docs
75+
```
76+
77+
That's it. If you have some apps need to be added, you can create a new issue or pull request.

docs/src/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Installation
44

5-
There are two ways to install this plugin.
5+
There are two ways to install this preprocessor.
66

77
You can install it from crates.io using cargo.
88

templates/announcement-banner.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
text-align: center;
4848
white-space: nowrap;
4949
text-overflow: ellipsis;
50+
text-wrap: balance;
5051
}
5152

5253
.announcement-banner button {

0 commit comments

Comments
 (0)