tommilligan / mdbook-admonish

A preprocessor for mdbook to add Material Design admonishments.
MIT License
174 stars 19 forks source link

After updating to `v1.12.0`, I get a panic as `byte index XX is not a char boundary;` #127

Closed CoralPink closed 1 year ago

CoralPink commented 1 year ago

Hello, thanks for the last time! πŸ˜†

I had a little trouble this time, after updating mdbook-admonish to v1.12.0, when I did the mdbook build, the process was interrupted by a panic.... 😒

πŸ“ Markdown file (click me) ~~~markdown # Chapter 1 δΎ‹γˆγ°γ“γ‚Œγ―`ng` γ§γ™πŸ˜… `Abc`and`Def`ghi ```admonish success title="" ![example](example.webp)
Screenshot of abcdefg hi jklMN opqrstu Vwxyzab cde etc...
``` A preprocessor for mdbook to add Material Design admonishments, based on the mkdocs-material implementation. ac It turns this: ```admonish info A beautifully styled message. ``` into this: Simple Message Read the documentation here, to see the actual examples in action. You can see the source in the ./book subdirectory. Other projects using mdbook-admonish: The Rhai Book Usage Use any fenced code-block as you normally would, but annotate it with admonish : ```admonish example My example is the best! ``` Best Example See the reference page for a list of supported admonitions. You'll find: info warning danger example and quite a few more! You can also leave out the admonition type altogether, in which case it will default to note: ```admonish A plain note. ``` ~~~
> RUST_BACKTRACE=full mdbook build
2023-09-19 12:28:20 [INFO] (mdbook::book): Book building has started
thread 'main' panicked at 'byte index 14 is not a char boundary; it is inside 'δΎ‹' (bytes 13..16) of `# Chapter 1

δΎ‹γˆγ°γ“γ‚Œγ―`ng` γ§γ™πŸ˜…
`Abc`and`Def`ghi

```admonish success title=""
![example](example.webp)

<div style="text-align: right;font-style: italic;" >
    Screenshot of abcdefg hi jklMN opqrstu Vwxyzab cde etc...
</div>
```

A preproc`[...]', /Users/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-admonish-1.12.0/src/markdown.rs:38:26
stack backtrace:
   0:        0x104e2c5b0 - __mh_execute_header
   1:        0x104e47230 - __mh_execute_header
   2:        0x104e2a184 - __mh_execute_header
   3:        0x104e2c408 - __mh_execute_header
   4:        0x104e2d82c - __mh_execute_header
   5:        0x104e2d5bc - __mh_execute_header
   6:        0x104e2dd5c - __mh_execute_header
   7:        0x104e2dc68 - __mh_execute_header
   8:        0x104e2c990 - __mh_execute_header
   9:        0x104e2d9d4 - __mh_execute_header
  10:        0x104e5cbfc - __mh_execute_header
  11:        0x104e4acc4 - __mh_execute_header
  12:        0x104e5d0b8 - __mh_execute_header
  13:        0x104ccd0bc - __mh_execute_header
  14:        0x104cd1854 - __mh_execute_header
  15:        0x104cca974 - __mh_execute_header
  16:        0x104c96c60 - __mh_execute_header
  17:        0x104c9c414 - __mh_execute_header
  18:        0x104ca4654 - __mh_execute_header
  19:        0x104e2552c - __mh_execute_header
  20:        0x104c987d8 - __mh_execute_header
2023-09-19 12:28:20 [ERROR] (mdbook::utils): Error: The "admonish" preprocessor exited unsuccessfully with exit status: 101 status

I thought it was simply a bad multibyte character, so I tried the following...?

πŸ“ Markdown ~~~markdown # Chapter 1 δΎ‹γˆγ°γ“γ‚Œγ―`ng` γ§γ™πŸ˜… `Abc`and`Def`ghi ~~~

This seems to be OK.

At this point, I have no idea anymore, but what confuses me even more is that if I delete a few lines from the first file, it somehow becomes OK.

πŸ“ Markdown ~~~markdown # Chapter 1 δΎ‹γˆγ°γ“γ‚Œγ―`ok` γ§γ™πŸ˜„ `Abc`and`Def`ghi ```admonish success title="" ![example](example.webp)
Screenshot of abcdefg hi jklMN opqrstu Vwxyzab cde etc...
``` A preprocessor for mdbook to add Material Design admonishments, based on the mkdocs-material implementation. It turns this: ```admonish info A beautifully styled message. ``` Read the documentation here, to see the actual examples in action. You can see the source in the ./book subdirectory. Other projects using mdbook-admonish: The Rhai Book Usage Use any fenced code-block as you normally would, but annotate it with admonish : ```admonish example My example is the best! ``` Best Example See the reference page for a list of supported admonitions. You'll find: info warning danger example and quite a few more! You can also leave out the admonition type altogether, in which case it will default to note: ```admonish A plain note. ``` ~~~

(...I can't help but wonder why this is OK.)

All I know is that if the error occurs, the problem definitely occurs at markdown.rs:38:26.

Sorry for the vague report. I hope it helps... πŸ˜“

tommilligan commented 1 year ago

Thank you for the report! I'm a big dummy, I'm pretty sure I immediately know exactly what the problem is. Will put out a fix when I get online this morning.

CoralPink commented 1 year ago

Thank you! That's great!

I am already relieved.😊

tommilligan commented 1 year ago

A fix is just running through CI now: #128

If you're able to, please install that branch directly and see if it fixes your use case:

cargo install --git https://github.com/tommilligan/mdbook-admonish --branch bug-127
CoralPink commented 1 year ago

Thanks! I tried it on this branch and it worked!! πŸ˜†