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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/lib/md2pukiwiki.rb +11 -13
- data/lib/md2pukiwiki/version.rb +1 -1
- data/spec/md2pukiwiki_spec.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddd5485b9fbe9ebae3d9bd0eaaad48b89fb3036e
|
4
|
+
data.tar.gz: 2d7052c36d825c44ee77407c0f258981bc8db1b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40135a692d4f869d8ad921d9f5eaa3f3514f5e447e24fa8f6e58e9891b883a3ba3cfb91d17beaa2107abdee9f8cf44fcc34ce85a451626b67dd22e028ac96f57
|
7
|
+
data.tar.gz: 250fd6f6e0bb46bef201d83b7f8b05cc511aa2f4d8ce26734d45504eb806278e8807c1717f74c947f97111848891bcceca6d630881d55f9368c9ac7660998927
|
data/CHANGELOG.md
ADDED
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
|
|
data/lib/md2pukiwiki.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
10
|
-
|
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.
|
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.
|
55
|
+
def self.convert_italic(line)
|
59
56
|
line.gsub(/(?:\*{1}|_{1})(?<italic>.+?)(?:\*{1}|_{1})/, "'''\\k<italic>'''")
|
60
57
|
end
|
61
58
|
|
62
|
-
|
59
|
+
# "~~strikethrough~~" => "%%strikethrough%%"
|
60
|
+
def self.convert_strikethrough(line)
|
63
61
|
line.gsub(/~{2}(?<strikethrough>.+?)~{2}/, '%%\k<strikethrough>%%')
|
64
62
|
end
|
65
63
|
|
data/lib/md2pukiwiki/version.rb
CHANGED
data/spec/md2pukiwiki_spec.rb
CHANGED
@@ -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.
|
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-
|
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:
|