md2pukiwiki 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3f6772be1c5d36b6fa2233dc5da1b9ed849899a
4
- data.tar.gz: 5476c351b4d8ce08c4c178cd9dec4e3f75dc3523
3
+ metadata.gz: ddd5485b9fbe9ebae3d9bd0eaaad48b89fb3036e
4
+ data.tar.gz: 2d7052c36d825c44ee77407c0f258981bc8db1b6
5
5
  SHA512:
6
- metadata.gz: 059407a05b13c57648a2741d78a7e7ace80fdff2796d37605354356d3534cffb0c5666bf628b5f55f5db10b4bc3a4cce41279b70081b62662239e967748d7eeb
7
- data.tar.gz: 39372cff963b948c171867635fe126549c416ccd717becaf19622ba3737efc6e6831732511ccf2f8390c587cc9aa405c435ff9984901b8683380f730124f04b7
6
+ metadata.gz: 40135a692d4f869d8ad921d9f5eaa3f3514f5e447e24fa8f6e58e9891b883a3ba3cfb91d17beaa2107abdee9f8cf44fcc34ce85a451626b67dd22e028ac96f57
7
+ data.tar.gz: 250fd6f6e0bb46bef201d83b7f8b05cc511aa2f4d8ce26734d45504eb806278e8807c1717f74c947f97111848891bcceca6d630881d55f9368c9ac7660998927
@@ -0,0 +1,6 @@
1
+ # 0.0.2
2
+ * Convert subsub-header correctly
3
+ * Refactor codes
4
+
5
+ # 0.0.1
6
+ * Initial release
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
  [![Build Status](https://travis-ci.org/dtan4/md2pukiwiki.svg?branch=master)](https://travis-ci.org/dtan4/md2pukiwiki)
3
3
  [![Coverage Status](https://coveralls.io/repos/dtan4/md2pukiwiki/badge.png)](https://coveralls.io/r/dtan4/md2pukiwiki)
4
4
  [![Code Climate](https://codeclimate.com/github/dtan4/md2pukiwiki.png)](https://codeclimate.com/github/dtan4/md2pukiwiki)
5
+ [![Gem Version](https://badge.fury.io/rb/md2pukiwiki.svg)](http://badge.fury.io/rb/md2pukiwiki)
5
6
 
6
7
  Convert Markdown to Pukiwiki-notation
7
8
 
@@ -2,19 +2,16 @@ require "md2pukiwiki/version"
2
2
 
3
3
  module Md2pukiwiki
4
4
  def self.convert(text)
5
+ decorated_type = %w{bold italic strikethrough}
6
+ prefixed_type = %w{header list numbered_list}
7
+ special_type = %w{image link}
8
+
5
9
  text.lines.map do |line|
6
10
  new_line = line.chomp
7
11
 
8
- new_line = convert_header(new_line)
9
- new_line = convert_list(new_line)
10
- new_line = convert_numbered_list(new_line)
11
-
12
- new_line = convert_bold_text(new_line)
13
- new_line = convert_italic_text(new_line)
14
- new_line = convert_strikethrough_text(new_line)
15
-
16
- new_line = convert_image(new_line)
17
- new_line = convert_link(new_line)
12
+ [decorated_type, prefixed_type, special_type].flatten.each do |type|
13
+ new_line = self.send("convert_#{type}", new_line)
14
+ end
18
15
 
19
16
  new_line
20
17
  end.join("\n")
@@ -50,16 +47,17 @@ module Md2pukiwiki
50
47
  end
51
48
 
52
49
  # "**bold**" => "''bold''"
53
- def self.convert_bold_text(line)
50
+ def self.convert_bold(line)
54
51
  line.gsub(/(?:\*{2}|_{2})(?<bold>.+?)(?:\*{2}|_{2})/, "''\\k<bold>''")
55
52
  end
56
53
 
57
54
  # "*italic*" => "'''italic'''"
58
- def self.convert_italic_text(line)
55
+ def self.convert_italic(line)
59
56
  line.gsub(/(?:\*{1}|_{1})(?<italic>.+?)(?:\*{1}|_{1})/, "'''\\k<italic>'''")
60
57
  end
61
58
 
62
- def self.convert_strikethrough_text(line)
59
+ # "~~strikethrough~~" => "%%strikethrough%%"
60
+ def self.convert_strikethrough(line)
63
61
  line.gsub(/~{2}(?<strikethrough>.+?)~{2}/, '%%\k<strikethrough>%%')
64
62
  end
65
63
 
@@ -1,3 +1,3 @@
1
1
  module Md2pukiwiki
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -10,6 +10,10 @@ describe Md2pukiwiki do
10
10
  expect(Md2pukiwiki.convert("## header")).to eq "**header"
11
11
  end
12
12
 
13
+ it "should convert subsub-header" do
14
+ expect(Md2pukiwiki.convert("### header")).to eq "***header"
15
+ end
16
+
13
17
  it "should convert list" do
14
18
  expect(Md2pukiwiki.convert("* list")).to eq "- list"
15
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md2pukiwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dtan4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-30 00:00:00.000000000 Z
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,7 @@ files:
91
91
  - ".gitignore"
92
92
  - ".rspec"
93
93
  - ".travis.yml"
94
+ - CHANGELOG.md
94
95
  - Gemfile
95
96
  - Guardfile
96
97
  - LICENSE.txt
@@ -129,4 +130,3 @@ summary: Convert Markdown to Pukiwiki-notation
129
130
  test_files:
130
131
  - spec/md2pukiwiki_spec.rb
131
132
  - spec/spec_helper.rb
132
- has_rdoc: