Bug 157037 - Auto-detect paragraph directions when opening plain text files and when pasting plain text
Summary: Auto-detect paragraph directions when opening plain text files and when pasti...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Jonathan Clark
URL:
Whiteboard: target:26.8.0 inReleaseNotes:26.8
Keywords:
Depends on:
Blocks: Paste File-Opening 162305 RTL
  Show dependency treegraph
 
Reported: 2023-08-31 12:08 UTC by AvidSeeker
Modified: 2026-01-24 04:44 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Plain text RTL document example (2.22 KB, text/markdown)
2023-09-20 11:48 UTC, AvidSeeker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description AvidSeeker 2023-08-31 12:08:19 UTC
Description:
Libreoffice doesn't correctly set text direction when opening plain text files.

Steps to Reproduce:
1. Write a plain text file with mostly RTL language (E.g: Arabic:  https://ar.wikipedia.org/wiki/ليبر_أوفيس)
2. Open it with Libreoffice writer

Actual Results:
Text direction is LTR

Expected Results:
Text direction is RTL


Reproducible: Always


User Profile Reset: No

Additional Info:
I suppose Libreoffice already have language detection capabilities. If not, please take a look on Google's language detection library: https://github.com/Mimino666/langdetect.
Comment 1 Dieter 2023-09-16 09:25:16 UTC
AvidSeeker, please add a plain text file with rtl language as this makes it easier for us to verify the bug. thank you.
=> NEEDINFO
Comment 2 AvidSeeker 2023-09-20 11:48:43 UTC
Created attachment 189715 [details]
Plain text RTL document example
Comment 3 QA Administrators 2023-09-21 03:16:14 UTC Comment hidden (obsolete)
Comment 4 Stéphane Guillou (stragu) 2023-09-28 23:35:45 UTC
That makes sense to me.

If gedit displays the sample text RTL, why shouldn't LO do the same, setting the page style accordingly? Or at least recognise the language properly per paragraph, and set its direction accordingly.

Weirdly, when importing the sample file, the paragraphs are assigned the Hindi language instead of Arabic... (same in OOo 3.3)

Tested with recent master build:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 2902ab24ecc5ffbf4907ea83b2028508b9de6364
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: es-MX (en_AU.UTF-8); UI: en-US
Calc: threaded
Comment 5 Eyal Rozenberg 2024-07-26 13:15:43 UTC
My Thunderbird extension does this for incoming plain text emails...

https://github.com/eyalroz/bidimailui/
Comment 6 Eyal Rozenberg 2025-11-06 21:47:54 UTC
Any objections to me expanding the title to cover pasting plain text?

Also, what about textual, but non-plain, formats, like Markdown and such?
Comment 7 Commit Notification 2026-01-23 23:48:24 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/974d50f66f16762f82857eaf817328460afb8b6b

tdf#157037 Auto-detect paragraph directions in plain text

It will be available in 26.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Jonathan Clark 2026-01-23 23:59:45 UTC
This commit handles opening and pasting plain text files. Other use cases should be filed as separate bugs.
Comment 9 Eyal Rozenberg 2026-01-24 00:13:55 UTC
Just noticed that the attachment here is actually a Markdown file rather than plain text.

So, Just to clarify - after the fix, if we open `.md` files in LibreOffice we _don't_ get direction auto-detection, right?


Anyway - kudos to Jonathan for another significant improvement to RTL support in LibreOffice! I hope to try this out soon myself.
Comment 10 Jonathan Clark 2026-01-24 04:44:44 UTC
(In reply to Eyal Rozenberg from comment #9)
> So, Just to clarify - after the fix, if we open `.md` files in LibreOffice
> we _don't_ get direction auto-detection, right?
That's correct.