Repository navigation
fix: convert RTF to TXT through LibreOffice - #1388
Conversation
The built-in routes read RTF through Pandoc: through Markdown every run in a monospace font became a code span, so code copied from an IDE came out full of backticks; through the HWPX writer the line breaks are lost. LibreOffice's RTF → TXT now costs as much as a chosen engine, as a direct route only.
|
CI caught something I missed: I looked into why the built-in HWPX route loses the lines, and it isn't Filee: the HWPX the writer makes from the RTF is right (13 So there are a few ways to go, and I'd like your call:
I'll update the PR once you've picked one. |
|
Thanks for digging into this, @yavuzmeteafsar, and for tracking the one-line output down to Unhwp. Let's go with option 1: keep this PR and allow RTF → TXT as an exception in The rule in that test is there so routes Filee can run by itself win. RTF has none: What's needed:
About the HWPX line breaks: please open a separate Filee issue with what you found ( |
KnifeLemon#1204) RTF has no built-in reader: every other route reads it through Pandoc, so this is the one LibreOffice edge besides presentations → PDF that may cost less than 25.
|
Thanks! Done in the second commit: |
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks, @yavuzmeteafsar, that's exactly it.
- The exception in
Every_edge_has_a_filter_of_its_applicationis as narrow as it should be, and the comment says why. DirectOnlykeeps RTF → TXT from becoming a hop on the way to other formats, andRtf_goes_to_txt_through_libreofficepins that down (rtf → mdstill goes through Pandoc).- The IDE sample in
RtfToTextTestscovers the three things #1204 was about: backticks, indentation and blank lines.
And thanks for filing the Unhwp line breaks separately as #1416. Merging now!
What does this change?
Fixes #1204. RTF → TXT now takes LibreOffice's direct edge, so code copied from an IDE keeps its text, indentation and blank lines.
This is a change from the plan in the issue. Marking Pandoc's
rtf → mdedgeDirectOnlymoved the route to the next built-in one, RTF → HWPX → TXT (about 32 with the priority penalties, against 34 for LibreOffice; through Markdown it was about 29). That route has no backticks, but it puts the whole file on one line:So Pandoc is untouched, and instead LibreOffice adds
rtf → txtatChosen(10) as aDirectOnlyedge:DirectOnlykeeps it a route of its own, so it doesn't become a cheap hop towards other formats (RTF → EPUB, for example).The HWPX route losing the line breaks looks like a bug of its own, so I can open a separate issue for it if you'd like.
Type of change
How was it tested?
On macOS 27.0.1 with Pandoc and LibreOffice installed:
dotnet format --verify-no-changesdotnet test:Filee.Core.Tests(1216 passed, 6 skipped), plus the route, RTF → TXT, Pandoc and Markdown tests inFilee.Engines.Tests(109 passed, 37 skipped). The one failure there,FolderIso632Tests.Archive_to_iso_uses_a_direct_archive_route_without_enabling_unrelated_inputs, fails the same way onmainwithout this commit: 7-Zip isn't installed here, soPlan("zip", "iso")is null.New tests:
LibreOfficeRouteTests.Rtf_goes_to_txt_through_libreoffice: RTF → TXT is one LibreOffice step, RTF → MD is still Pandoc, and RTF → EPUB doesn't go through TXT.RtfToTextTests.Code_copied_from_an_IDE_keeps_its_text: a run-heavy RTF like the IDE example (a colour run per token and an italicout) comes out with no backticks and with its blank lines, indentation,"\n"and"\\W+". It is skipped without LibreOffice.One more note: for text in a proportional font (not code from an IDE), LibreOffice adds a U+2006 before each space in a run of spaces. It does this on purpose to match Word's spacing (tdf#123703). The IDE case isn't affected, and I left it out of this PR.
Checklist
src/Filee.App/Assets/i18n/*.jsonfilesTHIRD-PARTY-NOTICES.md