Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Ecodev/redmine_convert_textile_to_markown

Repository files navigation

Unmaintained

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.

Redmine converter from Textile to Markown Build Status

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.

Known limitations

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:

  • Numbered lists containing <pre> blocks will lose their numbering (restarting at 1 after the <pre>). Some complex cases will lose their list layout entirely.
  • Tables without proper headers will be rendered with an empty header
  • Multilines tables will in the first pandoc run converted mostly to HTML which we detect and then in a second might end up as proper markdown tables (if it doesn't work it stays a HTML table) by removing the <br/> and afterwards introducing them again into the markdown.
  • Some interlaced formatting of inline code and bold will be messed up
  • <!-- --> may appear in final ouput in a few places because Redmine incorrectly does not support HTML in markdown

Usage

  1. Backup your database

  2. Install pandoc. See the example script setup.sh and adapt it to your environment for preparing the conversion.

  3. 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
  4. Run the task:

    bundle exec rake convert_textile_to_markdown RAILS_ENV=production
  5. 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.

Testing

Run the tests with

ruby test.rb

History

This script was built upon @sigmike answer on Stack Overflow, later slightly modified by Hugues C. and finally significantly completed by us.

About

Redmine rake task to convert content from textile to markdown

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published