Use this css rule:
unicode-bidi:plaintext;
on your element where the rendered markdown.
I’m from Algeria too
Use this css rule:
unicode-bidi:plaintext;
on your element where the rendered markdown.
I’m from Algeria too
It seems it works. I have tried it in some examples and the result was amazing.
Still I have to apply it on different other elements like lists, table and different mixture of RTL and LTR text.
In cases when “first strong character” heuristic is wrong, ideally you want an override that will also be understood by whatever plain-text editor you are using to edit the markdown source.
This is quite important for editing, otherwise the wrong order and “jumping punctuation” make it very annoying to go back and change the text!
Overriding with explicit <div dir=rtl>
or some other syntax would probably not do that for any editor? (Dual-pane editors will render it in preview pane, but not source pane.)
Overriding by inserting an LRM / RLM character would work with bidi-friendly editors
The heuristic usually fails when an RTL sentence starts with LTR word/quotation or vice-versa, so overriding by U+2068 FIRST STRONG ISOLATE … U+2069 POP DIRECTIONAL ISOLATE might work too in an editor (support less common yet). But it might not translate into a browser(?). That’s what <bdi>
, nowdays implied by setting dir
, is for.
Many plain-text editors don’t auto-detect paragraph direction at all . E.g. windows Notepad doesn’t, it lets you use left/right Ctrl+Shift to set default direction for whole window but that’s not stored in the text at all! Can’t help in this case.
Gnome’s gedit does auto-detect direction of each line separately. So does retext
, based on same GTK widgets. I don’t know how many such editors exist, but heavy RTL users probably use them
For web <textarea>
inputs, default used to depend on browser but unicode-bidi: plaintext
makes modern browsers (it’s CSS3, https://caniuse.com/#feat=mdn-css_properties_unicode-bidi_plaintext) auto-detect direction per line
It might also help rendered output, requiring less invasive changes than dir=auto(?) See https://github.com/gingko/client/issues/78#issuecomment-418448612 for an example of a program where it helped without deeper modifications. Though I don’t fully understand its behavior.
Given an editor that auto-detects direction per line, it’s very helpful to use markdown processors that allows line break in source WITHOUT a line break in the output. Then you can split mixed sentences/paragraphs such into LTR and RTL fragments on separate lines, making editing much easier.
To take this DIscuss for example, it’s pretty sub-optimal for bidi…
unicode-bidi: plaintext
in devtools helps!בבב ccc
dddAAA `BBB ccc` ddd
, note how the “directional run” detected by unicode algorithm crosses the element boundary! That was deliberate in the original algorithm, but mostly wrong, and isolates were invented later to fix that.
<div dir=auto>
works, but really, how many can you insert manually?