rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
18.12k stars 1.63k forks source link

No RTL Support & Search not working for languages like arabic or persian! #2316

Open nimafanniasl opened 8 months ago

nimafanniasl commented 8 months ago

Problem

Hey! I'm working on a website with mdBook that is written in Persian and I stumbled upon these issues:

First: There is no RTL support. I fixed the problem at least for the content itself in the book with this CSS:

#content > main:nth-child(1) > * {
    text-align: start;
    unicode-bidi: plaintext;
}

But still, as you can see, some parts aren't fixed with this fix.

I think it's a simple fix, but it's really needed!

Second problem: Search doesn't work for Arabic/Persian text but works perfectly for English!

Screenshot from 2024-02-13 22-36-07

Steps

  1. Make a new project
  2. Write some Persian/Arabic Text in it
  3. Search for the Persian/Arabic Text

Possible Solution(s)

No response

Notes

No response

Version

mdbook v0.4.37
ehuss commented 8 months ago

Thanks for the report! To support RTL, you need to set the book.text-direction option (see docs).

As for search support, that is tracked in #1081.

nimafanniasl commented 8 months ago

Hey! Thanks so much.

Also, is there a way to have English text be LTR and Persian/Arabic text automatically be RTL with the config file or does this still need custom css?

ehuss commented 8 months ago

I don't think there is an automatic way to handle that based on the script. You can wrap text in something like <div dir="ltr"> to switch it.

mo1ein commented 8 months ago

That's right. Search non-English languages are not supported. But for RTL, you can handle it like these:

<ul dir="rtl">
    <li>صفحه اصلی</li>
</ul>

or

<p dir="rtl">سلام</p>
nimafanniasl commented 8 months ago

Hi! Yeah, but setting it manually isn't a good way to do it, But the CSS I shared above works fine as a custom CSS and does this automatically :)

#content > main:nth-child(1) > * {
    text-align: start;
    unicode-bidi: plaintext;
}

The main problem for me is the search not working for Persian text :)

miaomiao1992 commented 7 months ago

Any new progress on this issue?