Skip to content

Add RTL support to markdown renderer

username-removed-132921 requested to merge ebraminio/gitlab-ce:master into master

WIP, mostly from performance standpoint, also needs unit-tests and check if ported code license thing is OK to be used here, or, if it has any issue, could it be resolved by separating this thing into a separate gem, but anyway reviews are welcomed.

What does this MR do?

It estimates direction of paragraphsbased on their text and set appropriate direction when needed. Needed for RTL markdown support on comments and wiki pages.

Are there points in the code the reviewer needs to double check?

If this needed to be behind a default disabled flag or not.

Why was this MR needed?

To support RTL markdown documents.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Resolves/makes these obsolete: #35 (closed), !124 (closed), #1901 (moved)

Screenshot and test

Sample 1

Consider you want render this:

# asdasd sadas sadas da sd as d (LTR)
# سیشسی شسی شس ی شسی سش (RTL)

asdasd asd as d as da sd asdas das d asd (LTR)

شسیش سی شس یشس ی شس یش سی شسی (RTL)

LTR:
> asdasdasdasdasDasd as d as da sd

RTL:
> سشیشس یشس ی شس یش سی شس ی شسی

LTR: (don't mess with codes even if they contain some RTL text)
''' (replace these with three backtick on your test)
سشیسی
شسیشسی
'''

LTR:
1. asdasds
2. asdasdasd


RTL
1. شسیشسی
2. ضسشیشسیشسی

LTR:
* ABDCVFDS
- ASDASDASd
+ ASDASDASd

RTL:
* سشیشسیشسی
- سشیشسی شسیش سی شس ی
+ شسیشسی شسی شس ی سشی

Before this change the result was:

image

After this: image

Sample 2

LTR:
- [x] Completed task
- [ ] Incomplete task
    - [ ] Sub-task 1
    - [x] Sub-task 2
    - [ ] Sub-task 3

RTL:
- [x] سیسشی
- [ ] سشیشسی
    - [ ] شسیشسی
    - [x] شسیشسی
    - [ ] شسیسشی

LTR:

| header 1 | header 2 |
| -------- | -------- |
| cell 1   | cell 2   |
| cell 3   | cell 4   |

RTL:

| سشیشسی  | شسی |
| -------- | -------- |
| شسیشسی   | شسیشسی  |
| شسیشسی  | شسیشسی  |


RTL:

sadsad شسیش سیش سی شسی شس یش سیشسی

LTR:

شسیشسیش sadasd as da sd as da sd as d


LTR:

شسیشس یشس یش سی asd asssd as d asd a sd asd as da sd as das d asd 


RTL:

asda asd as da sd as d شسی شسی شس ی شسی ش سی شسی شس ی شسی شس ی سشب سشی

Before the change: image

After the change: image

Merge request reports