Created
March 3, 2011 14:10
-
-
Save ongaeshi/852819 to your computer and use it in GitHub Desktop.
tw2hatena.rb
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
| # -*- coding: utf-8 -*- | |
| # | |
| # @file | |
| # @brief convert link, TiddlyWiki 2 Hatena | |
| # @author ongaeshi | |
| # @date 2011/03/03 | |
| def tw2hatena(line) | |
| # h1, h2, h3.. | |
| line = line.gsub(/^\!/, "*") | |
| line = line.gsub(/^\!\!/, "**") | |
| line = line.gsub(/^\!\!\!/, "***") | |
| # link | |
| line = line.gsub(/\[\[(.*)\|(.*)\]\]/, '[\2:title=\1]') | |
| end | |
| while line = gets | |
| print tw2hatena(line) | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment