mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

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

Open nimafanniasl opened this issue 6 months ago • 6 comments

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

nimafanniasl avatar Feb 13 '24 19:02 nimafanniasl

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.

ehuss avatar Feb 13 '24 20:02 ehuss

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?

nimafanniasl avatar Feb 13 '24 21:02 nimafanniasl

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.

ehuss avatar Feb 14 '24 18:02 ehuss

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>

mo1ein avatar Feb 27 '24 18:02 mo1ein

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 :)

nimafanniasl avatar Feb 27 '24 18:02 nimafanniasl

Any new progress on this issue?

miaomiao1992 avatar Mar 14 '24 11:03 miaomiao1992