Repository navigation
Description
What happened?
With Pandoc installed, filee convert file.rtf --to txt doesn't take LibreOffice's direct RTF → TXT edge (cost 25). It takes Pandoc's two steps, RTF → MD (gfm) → TXT, at a cost of 10 + 10 = 20. The result changes the text in two ways:
1. Code copied from an IDE gets backticks everywhere. Code pasted from an IDE keeps its colours: a monospace font, a \cfN run per token and an italic run here and there (System. + out). Pandoc then reads every run as an inline Code span. The Markdown step writes them next to each other, and the TXT step leaves the backticks in:
source: content.append(line).append("\n");
result: content.append(line).append(``"``\``n``"``);
The result no longer compiles.
2. Plain-font code loses its layout. In a normal font (TextEdit's default Helvetica) the result loses:
- leading indentation
- blank lines
- runs of spaces, which collapse to one
In addition, straight quotes become curly quotes, "%d\n" becomes “%d”, C:\\Users becomes C:\Users, and lines are wrapped at 72 columns.
Where it comes from
PandocConverterhasrtf → mdandmd → txtat the default cost of 10.LibreOfficeConverteraddsrtf → txtatFallback = 25. The route planner takes the cheaper two-step route.- Pandoc's RTF reader turns runs in a monospace font into separate
Codeinlines when it can't make one code block, here because of the italic run (issue 1). - The middle step writes
gfmbut reads it back asmarkdown, which hassmarton and treats backslashes as escapes (part of issue 2). Theplainwriter wraps at 72 columns by default. - Calling Pandoc directly (
-f rtf -t plain --wrap=none) fixes the backticks and the quotes. It still drops indentation and blank lines, so Pandoc isn't a good fit for RTF → TXT in general.
Suggestions
- Mark Pandoc's
rtf → mdedgeDirectOnly(astxt → csvandpdf → xlsxalready are). RTF → MD keeps working as it does today. RTF → TXT then goes through LibreOffice. This is the smallest change and fixes both issues when LibreOffice is there. - When LibreOffice isn't installed, there's no other RTF → TXT route after (1). This could be a Pandoc
rtf → txtedge with a cost above 25 and--wrap=none. - Separately, for every MD → X step: read Markdown with the same flavour Filee writes it in (
gfm), or at leastmarkdown-smart. Then quotes and backslashes survive any route that passes through Markdown, not only this one.
I'd be happy to open a PR for (1) with a test for each sample, and (2)/(3) if you want them in the same change or separately.
What did you expect?
The same text as the RTF, line for line. On the attached samples, macOS textutil -convert txt -encoding UTF-8 produces exactly that.
Steps to reproduce
- Install Pandoc and LibreOffice (both "Found on this Mac" from Homebrew here).
filee convert colored-code.rtf --to txt, and the same forplain-code.rtffrom the attached zip.- Compare each
.txtwith the RTF opened in TextEdit.
Running Filee's own commands by hand gives the same output (Pandoc 3.9, with the PlainMarkdown Lua filter):
pandoc in.rtf -f rtf -t gfm --lua-filter=plain.lua -o mid.md
pandoc mid.md -f markdown -t plain -o out.txt
Files involved
Filee version
2.3.0
Operating system
MacOS 27.0.1
Engines page status
Pandoc, LibreOffice: Found on this Mac (Homebrew).
Log
Activity
KnifeLemon commentedon Nov 6, 2026
Thanks for the careful analysis, @yavuzmeteafsar! The route choice and the backticks are clear from what you've laid out, and this is a real bug.
A two-step route through Markdown shouldn't beat a direct edge when the middle format loses information.
Would you like to send a PR? If you'd rather not, just say so, and it stays open here for us. Please add a test with a run-heavy RTF like your IDE example.
yavuzmeteafsar commentedon Nov 6, 2026
Thanks! Yes, I'll send the PR. It will mark Pandoc's
rtf → mdedgeDirectOnly, so RTF → TXT goes through LibreOffice again, plus a route test and an engine test with a run-heavy RTF like the IDE example (one colour run per token and an italic run). I'll link it here when it's up.KnifeLemon commentedon Nov 6, 2026
Thanks, @yavuzmeteafsar, that plan works:
DirectOnlyon Pandoc'srtf → mdedge, plus the route test and the engine test. I've assigned this to you.yavuzmeteafsar commentedon Nov 11, 2026
The PR is up: #1388. The plan changed a little:
DirectOnlyon Pandoc'srtf → mdsent RTF → TXT through the HWPX writer, which puts the whole file on one line, so the PR gives LibreOffice a directrtf → txtedge instead. Details are in the PR.Allow LibreOffice's RTF → TXT edge below the fallback cost in the test (
Convert RTF to TXT through LibreOffice (#1204)