I'm merging legacy Systems and some components use 开发者_如何转开发Markdown and others use Textile formatting. This is extremely confusing to my users. Therefore I want to standardize on Markdown.
Is there a way to convert at least the Bulk of Textile formatting to markdown automatically?
The forthcoming pandoc 1.8 (or the current github version) can convert Textile to Markdown directly. I don't know how much of Textile it handles, but
pandoc index.textile -o index.markdown
worked nicely here.
Because Markdown and Textile are both meant to produce HTML, consider converting all Texile to HTML first. There are a number of Markdown implementations which also support converting HTML back to Markdown. Pandoc being one example. Another possible solution would be using XSLT.
Because Textile is more verbose than Markdown, some elements (like tables) will stay marked up as HTML, which is perfectly fine with Markdown but may also be a source of confusion for your users.
Like Simon says, you can use pandoc, a universal document converter.
A single file
pandoc --from textile --to markdown "input.textile" -o "output.md"
Multiple files
To convert a directory full of textile files (including files in nested directories) to markdown, you need to loop over each file and call pandoc each time:
for textile_filename in ./**/*.textile; do
markdown_filename="${textile_filename%.textile}.md"
printf "Converting %s to %s\n" $textile_filename $markdown_filename
pandoc --from textile --to markdown $textile_filename -o $markdown_filename
done
Some issues with the markdown output:
- The metadata header (YAML Front Matter) is broken, and requires reformatting to its original. The metadata header between textile and markdown is the same, so it should not have to change.
- New lines are added into paragraphs to make them shorter than a certain cahracter length, so you have to remove extra new lines in all your sentences. Instead of one long line of 500 characters (your paragraph), you'll get 8 lines with about 80 characters each.
Feel free to add to this list if you find something annoying, or if you find a way to workaround these. There is much more general information in the Pandoc manual but it doesn't cover conversion in much depth.
精彩评论