Redmine rake task to convert content from textile to markdown
This project was archived in December 2020. It will keep working for a while. But in the future it will require adaptations for future versions of Redmine and Pandoc. When the time comes, I suggest you to fork this project.
This is a rake task for Redmine that uses pandoc to convert database content from Textile to Markdown formatting. The conversion is tweaked to adapt to Redmine's special features.
Because Redmine's textile is different than pandoc's textile, and because of some limitation in pandoc, the result will not be perfect, but it should be good enough to get you started. Here are some known limitations:
<pre>
blocks will lose their numbering (restarting at 1 after the <pre>
). Some complex cases will lose their list layout entirely.<br/>
and afterwards introducing them again into the markdown.<!-- -->
may appear in final ouput in a few places because Redmine incorrectly does not support HTML in markdown
Backup your database
Install pandoc.
See the example script setup.sh
and adapt it to your environment for preparing the conversion.
Install the task:
cd $REDMINE_ROOT_DIRECTORY
wget -P lib/tasks/ https://github.com/Ecodev/redmine_convert_textile_to_markown/raw/master/convert_textile_to_markdown.rake
Run the task:
bundle exec rake convert_textile_to_markdown RAILS_ENV=production
Check if you have strangely converted HTML or Markdown Tables -> There might be false positives.
cd $REDMINE_ROOT_DIRECTORY
wget -P lib/tasks/ https://github.com/Ecodev/count_tables/raw/master/convert_textile_to_markdown.rake
bundle exec rake count_tables RAILS_ENV=production
This will output all content into files in the current working dir where HTML or markdown tables have been detected to counter check.
Run the tests with
ruby test.rb
This script was built upon @sigmike answer on Stack Overflow, later slightly modified by Hugues C. and finally significantly completed by us.