The BiDiTools gadget assists editors who edit mixed RTL and LTR text. Examples of where this becomes problematic (in say an R2L Hebrew document):
- If the sentence ends with an English word, the period will appear on the wrong side.
- A single-lined, ordered list with consecutive English words will display these words in the wrong order.
- 'Words' such as chemical names will appear with their molecules reversed.
Unicode has a BiDi (bidirectional) algorithm which computes which text should be written right-to-left (R2L) and left-to-right (L2R). Usually it guesses these orders correctly, but in the complicated cases given above, it will guess wrong. To this end, special BiDi control characters can be embedded in documents to tell the BiDi engine how to display the text. This gadget provides buttons and other help for working with these special characters.
Important: The BiDiTools gadget is intended for users who already have a good understanding of how BiDi works. Although the codes are explained below, users of this gadget are expected to understand why invisible characters can make their whole document appear backwards.
The characters (with identically named buttons):
|LRE||Left-to-Right Embedding||Use to place a LTR 'section' of chars in a RTL section.|
|RLE||Right-to-Left Embedding||Use to place a RTL 'section' of chars in a LTR section.|
|Pop Directional Format||End markup for LRE, RLE, LRO, RLO.|
|LRO||Left-to-Right Override||Override letter ordering. Could be useful|
|RLO||Right-to-Left Ovverride||Use for a 'section' of LTR chars in a RTL paragraph.|
User installation and usage
- To install the BidiTools gadget, simply select it in your Special:Preferences under 'Gadgets'.
- Clicking on any of the buttons will insert their respective character in your text.
- Make sure any text preceded by a LRE,RLE,LRO,RLO is followed by a PDF afterwards.
- If you highlight a block of text first and then click a button, the PDF is automatically added at the end.
- Click the BiDi->HTML or HTML->BiDi button to switch between using your chars and seeing where they are.
- On save, all the Unicode BiDi chars are converted to their HTML entity equivalents. This is prevent confusing users without the gadget who might not understand why their editor is behaving backwards for no reason. Likewise, on load, HTML chars are converted to Unicode so that they display correctly in the editor.
Installation on other Wikis
- Install Extension:Gadgets
- View the source / edit MediaWiki:Gadget-BiDiTools.js and this page and copy them to your Wiki
- Edit MediaWiki:Gadgets-definition and add the line '* BiDiTools|BiDiTools.js'.
- Check Special:Gadgets to make sure BiDiTools appears on the list.
This is still a work in process. Comments and additions are welcome.