Created
June 3, 2014 18:09
-
-
Save ggarnier/67ba17583168133abfe5 to your computer and use it in GitHub Desktop.
Textile to Markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def process_file oldfilename | |
| markdown_content = textile_to_markdown(File.read(oldfilename)) | |
| filename = oldfilename.split("/").last.split(".").first.gsub("-", "_") | |
| File.open("doc_src/content/#{filename}.md", "w") do |f| | |
| f.write <<-CONTENT | |
| --- | |
| title: #{filename.capitalize} | |
| group: Base | |
| --- | |
| CONTENT | |
| f.write(markdown_content) | |
| end | |
| end | |
| def textile_to_markdown textile_content | |
| textile_content. | |
| gsub(/h(\d)\./) {|s| '#' * $1.to_i }. | |
| gsub(/@([^@\n]+)@/, '`\1`'). | |
| gsub(/"([^"]+)":([^ \.]+(\.html)?)/, '[\1](\2)'). | |
| gsub(/<xml>/, '~~~html'). | |
| gsub(/<\/xml>/, '~~~') | |
| end | |
| Dir.glob("doc_src_old/*.textile") do |oldfilename| | |
| process_file oldfilename | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment