mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Support for Right-To-Left text #217
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mhmd-azeez on GitHub (Aug 11, 2018).
Adding support for markdown in achieved by adding
dirattribute to the rendered html elements. There are two ways of doing that:Either you explicitly mark elements as rtl based on their contents, which is not too hard but might slow things down a bit. Or, you mark all of the structural elements with
dir="auto"and let the browsers do the heavy lifting.If you are interested, I am willing to send a PR, but I might need some help in some decisions and specific areas (like getting the first character of a block in a fast way, for example). For more information please take a look at dear-github/dear-github#147. Whichever way we choose, it's better than not supporting it at all.
I played with the second idea a bit, it's very easy to implement it. But not every browser supports it according to my tests and no browser seems to support tables. Here is a simple implementation of the second method:
For the following markdown:
The following html is produced (note, to view the html correctly, you might need to have
<meta charset="UTF-8">in the head of the html document):Screenshot (Chrome):

In Chrome, Opera and Firefox, all of the elements (except for table) are rendered correctly. Unfortunately, Edge and IE don't respect the direction attribute at all (If its set to "auto").