markdown2confluence 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.rvmrc +1 -1
- data/Gemfile +1 -1
- data/README.markdown +1 -1
- data/Rakefile +7 -0
- data/bin/markdown2confluence +4 -9
- data/lib/markdown2confluence/convertor/confluence.rb +9 -12
- data/lib/markdown2confluence/version.rb +1 -1
- data/markdown2confluence.gemspec +6 -0
- data/test/markdown2confluence_test.rb +85 -0
- data/test/test_helper.rb +4 -0
- metadata +92 -69
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
N2UyY2I1YjZmYTU5ZTkwODg0NzA5OGU1ZDZkMDEyODI3MzhjOWFlMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWZmYWM5NzUwODMxYWFlYzVmMjgzODZjYTY0M2IyZjY5YjgyYWNmOQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
M2I5MGRmYmQwZjllMzAxMGE2N2U5MDBlZGY0ZTFlMzkzODM5ZDAyY2JjZmVm
|
10
|
+
ZjkyMTA4NTVmN2FkNjBlYTUwMjNjOWE1ZTRkOWM4MmE3MWVhZmVlYWUyNjRh
|
11
|
+
MTc2OWNiYjdlZGIwYTU1Y2QwNTY4YzY2ODM5NDVmYTQ0NDM1ZGM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzIxMGViNjM1OWY0M2NkYzI2ODlkMjEzNWQwYjU2YWY1MDMwYzAyMGNmOWFk
|
14
|
+
ZTQ0MTlkODQ1ZGJhYTVkNDgwOThhOWYyODMyZjg2N2EyZDhlMGJiMTYzYTMx
|
15
|
+
OWZjNWE1YTI4ZjkyNDcyOTRmZWExZTRlM2RmODQyZWE1ZTUwNTk=
|
data/.rvmrc
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
This code is a quick hack for converting markdown to [Atlassian confluence](http://atlassian.com/confluence) markup language.
|
2
|
-
It's
|
2
|
+
It's not a 100% full conversion, but I find it rather usuable already. I will continue to improve where possible.
|
3
3
|
|
4
4
|
The gem is based on [Kramdown](https://github.com/gettalong/kramdown)
|
5
5
|
|
data/Rakefile
CHANGED
data/bin/markdown2confluence
CHANGED
@@ -2,17 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'markdown2confluence'
|
4
4
|
|
5
|
-
filename=ARGV[0]
|
6
|
-
if ARGV.size < 1
|
7
|
-
puts "We need at least on file argument"
|
8
|
-
exit -1
|
9
|
-
end
|
5
|
+
filename = ARGV[0]
|
6
|
+
abort "We need at least on file argument" if ARGV.size < 1
|
10
7
|
|
11
8
|
begin
|
12
|
-
text=File.read(filename)
|
13
|
-
|
14
|
-
s=Kramdown::Document.new(text).to_confluence
|
15
|
-
puts s
|
9
|
+
text = File.read(filename)
|
10
|
+
puts Kramdown::Document.new(text).to_confluence
|
16
11
|
rescue Exception => ex
|
17
12
|
warn "There was an error running the convertor: \n#{ex}"
|
18
13
|
end
|
@@ -82,10 +82,9 @@ module Kramdown
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def convert_p(el, indent)
|
85
|
-
"#{' '*indent}#{inner(el, indent)}\n
|
85
|
+
"#{' '*indent}#{inner(el, indent)}\n"
|
86
86
|
end
|
87
87
|
|
88
|
-
|
89
88
|
def convert_blockquote(el, indent)
|
90
89
|
"#{' '*indent}bq. #{inner(el, indent)}\n"
|
91
90
|
end
|
@@ -106,7 +105,7 @@ module Kramdown
|
|
106
105
|
alias :convert_dl :convert_ul
|
107
106
|
|
108
107
|
def convert_li(el, indent)
|
109
|
-
"#{'-'}#{inner(el,
|
108
|
+
"#{'-'*(indent/2)}#{inner(el, 0)}"
|
110
109
|
end
|
111
110
|
|
112
111
|
alias :convert_dd :convert_li
|
@@ -119,7 +118,7 @@ module Kramdown
|
|
119
118
|
markup=case el.value
|
120
119
|
when "iframe" then "{iframe:src=#{el.attr["src"]}}"
|
121
120
|
when "pre" then
|
122
|
-
if
|
121
|
+
if inner(el,indent).strip.match(/\n/)
|
123
122
|
"{code}#{inner(el,indent)}{code}"
|
124
123
|
else
|
125
124
|
"{{#{inner(el,indent).strip}}}"
|
@@ -161,17 +160,15 @@ module Kramdown
|
|
161
160
|
end
|
162
161
|
|
163
162
|
def convert_a(el, indent)
|
164
|
-
text=inner(el,indent)
|
165
|
-
link=el.attr['href']
|
166
|
-
|
167
|
-
return markup
|
163
|
+
text = inner(el,indent)
|
164
|
+
link = el.attr['href']
|
165
|
+
"[#{text+'|' unless text.nil?}#{link}]"
|
168
166
|
end
|
169
167
|
|
170
168
|
def convert_img(el, indent)
|
171
|
-
src=el.attr['src']
|
172
|
-
alt=el.attr['alt']
|
173
|
-
|
174
|
-
return markup
|
169
|
+
src = el.attr['src']
|
170
|
+
alt = el.attr['alt']
|
171
|
+
alt.to_s.empty? ? "!#{src}!" : "!#{src}|alt=#{alt}!"
|
175
172
|
end
|
176
173
|
|
177
174
|
def convert_codeblock(el, indent)
|
data/markdown2confluence.gemspec
CHANGED
@@ -12,13 +12,19 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = %q{Based on Kramdown, a convert object .to_confluence}
|
13
13
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.required_ruby_version = '>= 1.9.3'
|
15
16
|
s.rubyforge_project = "markdown2confluence"
|
16
17
|
|
17
18
|
s.add_dependency "kramdown"
|
18
19
|
s.add_dependency "nokogiri"
|
20
|
+
|
21
|
+
s.add_development_dependency('rake', "~> 0.9.2")
|
22
|
+
s.add_development_dependency('activesupport', '>= 3.0.0')
|
23
|
+
s.add_development_dependency('turn')
|
19
24
|
|
20
25
|
s.files = `git ls-files`.split("\n")
|
21
26
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
22
27
|
s.require_path = 'lib'
|
28
|
+
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
23
29
|
end
|
24
30
|
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Markdown2ConfluenceTest < ActiveSupport::TestCase
|
4
|
+
test "header 1" do
|
5
|
+
assert_equal "h1. Hello\n", confluence("# Hello")
|
6
|
+
end
|
7
|
+
|
8
|
+
test "heading 2" do
|
9
|
+
assert_equal "h2. Hello\n", confluence("## Hello")
|
10
|
+
end
|
11
|
+
|
12
|
+
test "heading 3" do
|
13
|
+
assert_equal "h3. Hello\n", confluence("### Hello")
|
14
|
+
end
|
15
|
+
|
16
|
+
test "heading 4" do
|
17
|
+
assert_equal "h4. Hello\n", confluence("#### Hello")
|
18
|
+
end
|
19
|
+
|
20
|
+
test "unordered list" do
|
21
|
+
list = "* this\n"
|
22
|
+
list << "* is\n"
|
23
|
+
list << "* a\n"
|
24
|
+
list << "* list\n"
|
25
|
+
confluence_list = list.gsub("*", "- ")
|
26
|
+
assert_equal confluence_list, confluence(list)
|
27
|
+
end
|
28
|
+
|
29
|
+
# FIX - failing test
|
30
|
+
test "ordered list" do
|
31
|
+
assert_equal "1. this\n2. is\n3. a\n4. list\n", confluence("1. this\n2. is\n3. a\n4. list\n" )
|
32
|
+
end
|
33
|
+
|
34
|
+
test "strong text" do
|
35
|
+
assert_equal "*strong*\n", confluence("**strong**")
|
36
|
+
end
|
37
|
+
|
38
|
+
test "italics text" do
|
39
|
+
assert_equal "_some text here_\n", confluence("*some text here*")
|
40
|
+
end
|
41
|
+
|
42
|
+
test "inline code" do
|
43
|
+
assert_equal "{{hello world}}\n", confluence("`hello world`")
|
44
|
+
end
|
45
|
+
|
46
|
+
test "block of code" do
|
47
|
+
code = " this is code\n"
|
48
|
+
assert_equal "{code}this is code\n{code}\n", confluence(code)
|
49
|
+
end
|
50
|
+
|
51
|
+
# FIX - failing test
|
52
|
+
test "strikethrough" do
|
53
|
+
assert_equal "-strikethrough text-\n", confluence("~~strikethrough text~~")
|
54
|
+
end
|
55
|
+
|
56
|
+
# FIX - failing test
|
57
|
+
test "quote" do
|
58
|
+
assert_equal "bq. this is a quote", confluence("> this is a quote")
|
59
|
+
end
|
60
|
+
|
61
|
+
test "hyperlink" do
|
62
|
+
assert_equal "[github|http://github.com]\n", confluence("[github](http://github.com)")
|
63
|
+
end
|
64
|
+
|
65
|
+
test "image link without alt" do
|
66
|
+
assert_equal "!http://github.com/logo.png!\n", confluence("")
|
67
|
+
end
|
68
|
+
|
69
|
+
test "image link with alt" do
|
70
|
+
assert_equal "!http://github.com/logo.png|alt=logo!\n", confluence("")
|
71
|
+
end
|
72
|
+
|
73
|
+
test "horizontal rule" do
|
74
|
+
assert_equal "----\n", confluence("* * *")
|
75
|
+
assert_equal "----\n", confluence("***")
|
76
|
+
assert_equal "----\n", confluence("*****")
|
77
|
+
assert_equal "----\n", confluence("---------------------------------------")
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def confluence(text)
|
83
|
+
Kramdown::Document.new(text).to_confluence
|
84
|
+
end
|
85
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,60 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown2confluence
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Patrick Debois
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
type: :runtime
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
prerelease: false
|
11
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
32
14
|
name: kramdown
|
33
|
-
|
34
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
35
20
|
type: :runtime
|
36
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
hash: 3
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
21
|
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
46
28
|
name: nokogiri
|
47
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: turn
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
48
83
|
description: Based on Kramdown, a convert object .to_confluence
|
49
|
-
email:
|
84
|
+
email:
|
50
85
|
- patrick.debois@jedi.be
|
51
|
-
executables:
|
86
|
+
executables:
|
52
87
|
- markdown2confluence
|
53
88
|
extensions: []
|
54
|
-
|
55
89
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
90
|
+
files:
|
58
91
|
- .gitignore
|
59
92
|
- .rvmrc
|
60
93
|
- Gemfile
|
@@ -65,40 +98,30 @@ files:
|
|
65
98
|
- lib/markdown2confluence/convertor/confluence.rb
|
66
99
|
- lib/markdown2confluence/version.rb
|
67
100
|
- markdown2confluence.gemspec
|
101
|
+
- test/markdown2confluence_test.rb
|
102
|
+
- test/test_helper.rb
|
68
103
|
homepage: http://github.com/jedi4ever/markdown2confluence/
|
69
104
|
licenses: []
|
70
|
-
|
105
|
+
metadata: {}
|
71
106
|
post_install_message:
|
72
107
|
rdoc_options: []
|
73
|
-
|
74
|
-
require_paths:
|
108
|
+
require_paths:
|
75
109
|
- lib
|
76
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
|
-
requirements:
|
88
|
-
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
hash: 23
|
91
|
-
segments:
|
92
|
-
- 1
|
93
|
-
- 3
|
94
|
-
- 6
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 1.9.3
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
95
119
|
version: 1.3.6
|
96
120
|
requirements: []
|
97
|
-
|
98
121
|
rubyforge_project: markdown2confluence
|
99
|
-
rubygems_version:
|
122
|
+
rubygems_version: 2.0.6
|
100
123
|
signing_key:
|
101
|
-
specification_version:
|
124
|
+
specification_version: 4
|
102
125
|
summary: Convert Markdown to confluence wiki style
|
103
|
-
test_files:
|
104
|
-
|
126
|
+
test_files:
|
127
|
+
- test/test_helper.rb
|