Feature #44435
openPreview Rich Text Format (.rtf) files
Description
The attached patch extends the Markdown-based preview for Office documents introduced in #8959 to Rich Text Format (.rtf) files. Pandoc has supported RTF as an input format since version 2.14.2 (2021-08-21), so the patch adds .rtf to the extensions handled by Redmine::Markdownizer when Pandoc 2.14.2 or later is installed.
Although RTF is less common than it once was, it is still widely supported and remains in use. Microsoft Word, LibreOffice Writer, and many other applications can read and write RTF, and organizations may have existing .rtf documents attached to issues and wiki pages.
Redmine currently shows "No preview available" for these files, so users have to download them to view their content. With this patch, .rtf attachments get the same in-browser preview as .docx and .odt files. Since Redmine already has a Pandoc-based preview for Office documents, the actual implementation needed to support RTF only requires adding .rtf to the extension list. The version check is kept because some distributions still ship older Pandoc, for example Ubuntu 22.04 (2.9.2.1) and RHEL 9 / EPEL 9 (2.14.0.3); on those systems, .rtf previews are simply not enabled.
diff --git a/lib/redmine/markdownizer.rb b/lib/redmine/markdownizer.rb
index ac1c67203..9bca4db8a 100644
--- a/lib/redmine/markdownizer.rb
+++ b/lib/redmine/markdownizer.rb
@@ -103,7 +103,8 @@ module Redmine
else
return (@markdownizable_extensions = [])
end
- # Pandoc >= 3.8.3 supports Microsoft Excel and PowerPoint files
+ # Formats that require a newer version of Pandoc
+ @markdownizable_extensions += %w[.rtf] if (@pandoc_version <=> [2, 14, 2]) >= 0
@markdownizable_extensions += %w[.xlsx .pptx] if (@pandoc_version <=> [3, 8, 3]) >= 0
@markdownizable_extensions
Files
Updated by Go MAEDA about 5 hours ago
- File 0001-Add-preview-support-for-Rich-Text-Format-.rtf-files.patch 0001-Add-preview-support-for-Rich-Text-Format-.rtf-files.patch added
- File deleted (
0001-Add-preview-support-for-Rich-Text-Format-.rtf-files.patch) - Description updated (diff)