A field method for the excellent Kirby CMS for the proper alignment of bi-directional text.
If you set the dir="auto"
attribute on block-level elements, browsers will detect the proper text direction based on what unicode characters are inside the element.
This is useful when writing bi-directional content, for example a blog post with a mix of Latin and Arabic text.
field-bidi automatically adds these direction attributes to your markup so you don't have to do it manually.
Install this plugin as a git submodule to make updates and version control easy.
cd your/kirby/root
git submodule add https://github.com/samnabi/field-bidi.git site/plugins/field-bidi
Otherwise, just download this repo and drop the whole field-bidi
folder into your site/plugins
folder.
You can chain this field method to the end of any markdown()
or kirbytext()
method, like this:
// Outputs <p>Lorem ipsum</p>
<?php echo $text->kirbytext() ?>
// Outputs <p dir="auto">Lorem ipsum</p>
<?php echo $text->kirbytext()->bidi() ?>