diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..0fd2499
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,20 @@
+version: 2
+jobs:
+ test:
+ working_directory: ~/html2confluence
+ docker:
+ - image: circleci/ruby:2.5
+ steps:
+ - checkout
+ - run:
+ name: Bundle
+ command: bundle install --jobs=4 --retry=3
+ - run:
+ name: RSpec
+ command: bundle exec rspec
+
+workflows:
+ version: 2
+ test:
+ jobs:
+ - test
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b844b14
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+Gemfile.lock
diff --git a/.rspec b/.rspec
index 5052887..83e16f8 100644
--- a/.rspec
+++ b/.rspec
@@ -1 +1,2 @@
---color
\ No newline at end of file
+--color
+--require spec_helper
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..fa75df1
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,3 @@
+source 'https://rubygems.org'
+
+gemspec
diff --git a/README.mdown b/README.md
similarity index 100%
rename from README.mdown
rename to README.md
diff --git a/html2confluence.gemspec b/html2confluence.gemspec
index 2608c18..abbb9dc 100644
--- a/html2confluence.gemspec
+++ b/html2confluence.gemspec
@@ -15,4 +15,6 @@ Gem::Specification.new do |s|
s.files = Dir.glob("{lib,spec}/**/*") + %w(example.rb README.mdown)
s.add_dependency "nokogiri"
+
+ s.add_development_dependency "rspec"
end
diff --git a/spec/checkbox_examples_spec.rb b/spec/checkbox_examples_spec.rb
index 0b81c83..112b348 100644
--- a/spec/checkbox_examples_spec.rb
+++ b/spec/checkbox_examples_spec.rb
@@ -1,8 +1,5 @@
-# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
-
describe HTMLToConfluenceParser, "when running checkbox examples" do
+ let(:parser) { HTMLToConfluenceParser.new }
it "should match checkboxes" do
html = <<-END
@@ -17,16 +14,14 @@
END
markup = <<-END
-* (/) Example 1
-* (/) Example 2
-* (x) Example 3
-* (/) Example 4
-* (x) Example 5
+* (/) Example 1
+* (/) Example 2
+* (x) Example 3
+* (/) Example 4
+* (x) Example 5
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
-
end
diff --git a/spec/combination_examples_spec.rb b/spec/combination_examples_spec.rb
index f1ef51e..3ecd116 100644
--- a/spec/combination_examples_spec.rb
+++ b/spec/combination_examples_spec.rb
@@ -1,9 +1,6 @@
-# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
-
describe HTMLToConfluenceParser, "when running combination examples" do
-
+ let(:parser) { HTMLToConfluenceParser.new }
+
it "should match complex examples" do
html = <<-END
@@ -18,9 +15,7 @@
# numbered *item* that is +underlined+.
# list
END
-
-
- parser = HTMLToConfluenceParser.new
+
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -95,7 +90,6 @@
h1. With +nice+ formatting.
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -106,10 +100,15 @@
END
markup = <<-END
-{quote}\nbq. content here\n{quote}
+{quote}
+
+{quote}
+content here
+{quote}
+
+{quote}
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
@@ -122,7 +121,6 @@
markup = "Previous\n\n*Scenario 4a: Existing deletes their ID*\n*Given* I am an existing user"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -136,7 +134,6 @@
markup = "Previous line\n\n*Scenario 4a: Existing deletes their ID*\n*Given* I am an existing user"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -146,7 +143,6 @@
markup = "*And* first line\n\n*second line*"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -156,7 +152,6 @@
markup = "!a source!"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -165,7 +160,6 @@
html = "familiar with the XMLHttpRequest Object
\n\n"
markup = "familiar with the XMLHttpRequest Object"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
@@ -179,7 +173,6 @@
markup = "Previous line\n\n----"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -191,7 +184,6 @@
markup = "A"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
end
@@ -204,12 +196,7 @@
markup = "A"
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to eq(markup)
- end
-
+ end
end
-
-
-
diff --git a/spec/complex_tables_spec.rb b/spec/complex_tables_spec.rb
index 1c8fa12..ef69972 100644
--- a/spec/complex_tables_spec.rb
+++ b/spec/complex_tables_spec.rb
@@ -1,10 +1,7 @@
-# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
-
describe HTMLToConfluenceParser, "when running complex tables examples" do
-
- it "should handle table with newlines" do
+ let(:parser) { HTMLToConfluenceParser.new }
+
+ it "should handle table with newlines" do
html = <<-END
| As a... | I would like... | Because... |
Student or Teacher | There to be more candy | Candy is: - Delicious
- Shiny
- Good for my teeth
|
END
@@ -21,12 +18,11 @@
* Good for my teeth|
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
- it "should handle table empty cells" do
+ it "should handle table empty cells" do
html = <<-END
END
@@ -35,12 +31,11 @@
| |Empty| |
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
- it "should handle pre in table empty cells" do
+ it "should handle pre in table empty cells" do
html = <<-END
END
@@ -52,12 +47,11 @@
b{noformat} |c |
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
- it "should handle pre in table" do
+ it "should handle pre in table" do
html = <<-END
@@ -79,12 +73,7 @@
2{noformat} |3 |
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
expect(parser.to_wiki_markup.strip).to include(markup.strip)
end
-
end
-
-
-
diff --git a/spec/html2confluence_spec.rb b/spec/html2confluence_spec.rb
index 027f194..f8171b2 100644
--- a/spec/html2confluence_spec.rb
+++ b/spec/html2confluence_spec.rb
@@ -1,10 +1,8 @@
-# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
-
describe HTMLToConfluenceParser, "when converting html to textile" do
+ let(:parser) { HTMLToConfluenceParser.new }
+
context "in a large html document" do
- before :all do
+ before do
html = <<-END
@@ -126,105 +124,105 @@
|Not table
END
- parser = HTMLToConfluenceParser.new
+
parser.feed(html)
- @textile = parser.to_wiki_markup
+ @confluence = parser.to_wiki_markup
end
it "should convert heading tags" do
- expect(@textile).to match(/^h1(\([^\)]+\))?\./)
+ expect(@confluence).to match(/^h1(\([^\)]+\))?\./)
end
it "should convert underline tags" do
- expect(@textile).to include("text with +underlining+ is here")
+ expect(@confluence).to include("text with +underlining+ is here")
end
it "should not explicitly markup paragraphs unnecessarily" do
- expect(@textile).to_not include("p. test paragraph without id or class attributes")
+ expect(@confluence).to_not include("p. test paragraph without id or class attributes")
end
it "should treat divs as block level elements, but ignore any attributes (effectively converting them to paragraphs)" do
- expect(@textile).to include("\n\nA note\n\nFollowed by another note\n\n")
+ expect(@confluence).to include("\n\nA note\n\nFollowed by another note\n\n")
end
it "should not convert pointless spans to textile (i.e. without supported attributes)" do
- expect(@textile).to_not include("%a useless span%")
+ expect(@confluence).to_not include("%a useless span%")
end
it "should convert class and id attributes" do
- # We don't convert classes. expect(@textile).to include("h1(story.title entry-title#post-312).")
+ # We don't convert classes. expect(@confluence).to include("h1(story.title entry-title#post-312).")
end
it "should convert tables" do
- expect(@textile).to include("\n\n||heading 1 ||heading 2 || \n|value 1 |value 2 | \n")
+ expect(@confluence).to include("\n\n||heading 1 ||heading 2 || \n|value 1 |value 2 | \n")
end
it "should convert tables with text immediately preceding the opening table tag" do
- expect(@textile).to include("Some text before a table\n\n||heading 1 ||heading 2 || \n|value 1 |value 2 | \n")
+ expect(@confluence).to include("Some text before a table\n\n||heading 1 ||heading 2 || \n|value 1 |value 2 | \n")
end
it "should respect line breaks within block level elements" do
- expect(@textile).to include("\n# test 1 \n# test 2\nwith a line break in the middle")
+ expect(@confluence).to include("\n# test 1 \n# test 2\nwith a line break in the middle")
end
it "should handle paragraphs nested within blockquote" do
- expect(@textile).to include("{quote}\n\nparagraph inside a blockquote\n\nanother paragraph inside a blockquote\n\n{quote}")
+ expect(@confluence).to include("{quote}\n\nparagraph inside a blockquote\n\nanother paragraph inside a blockquote\n\n{quote}")
end
it "should retain leading and trailing whitespace within inline elements" do
- expect(@textile).to include("test *invalid* list item 1")
+ expect(@confluence).to include("test *invalid* list item 1")
end
it "should respect trailing line break tags within other elements" do
- expect(@textile).to include("*Please apply online at:*\n[www.something.co.uk/careers|http://www.something.co.uk/careers]")
+ expect(@confluence).to include("*Please apply online at:*\n[www.something.co.uk/careers|http://www.something.co.uk/careers]")
end
it "should handle nested inline elements" do
- expect(@textile).to include(" *_test emphasised bold text_* test")
+ expect(@confluence).to include(" *_test emphasised bold text_* test")
end
it "should remove empty quicktags before returning" do
- expect(@textile).to_not include("*more bold text* *\n*")
+ expect(@confluence).to_not include("*more bold text* *\n*")
end
it "should remove unsupported elements (e.g. script)" do
- expect(@textile).to_not include('script')
+ expect(@confluence).to_not include('script')
end
it "should remove unsupported attributes (i.e. everything but class and id)" do
- expect(@textile).to_not include('summary')
- expect(@textile).to_not include('a table with a caption')
- expect(@textile).to_not include('style')
- expect(@textile).to_not include('color:red;')
+ expect(@confluence).to_not include('summary')
+ expect(@confluence).to_not include('a table with a caption')
+ expect(@confluence).to_not include('style')
+ expect(@confluence).to_not include('color:red;')
end
it "should clean up multiple blank lines created by tolerant parsing before returning" do
- expect(@textile).to_not match(/(\n\n\s*){2,}/)
+ expect(@confluence).to_not match(/(\n\n\s*){2,}/)
end
it "should keep entity references" do
- expect(@textile).to include("©")
+ expect(@confluence).to include("©")
end
it "should output unknown named entity references" do
- expect(@textile).to include("&unknownref;")
+ expect(@confluence).to include("&unknownref;")
end
it "should convert numerical entity references to a utf-8 character" do
- expect(@textile).to include("…")
+ expect(@confluence).to include("…")
end
it "should ignore entities that are already converted" do
- expect(@textile).to include("Æïœü")
+ expect(@confluence).to include("Æïœü")
end
it "should ignore ampersands that are not part of an entity reference" do
- expect(@textile).to include("Hughes & Hughes")
+ expect(@confluence).to include("Hughes & Hughes")
end
it "should retain whitespace surrounding entity references" do
- expect(@textile).to include("… € 100")
- expect(@textile).to include("Something & something")
+ expect(@confluence).to include("… € 100")
+ expect(@confluence).to include("Something & something")
end
it "should escape special characters" do
@@ -232,22 +230,22 @@
# characters that would otherwise be mistaken for markup. It should not
# escape every instance of these characters.
pending 'only escape correct characters'
- expect(@textile).to include("\\# Not a list")
- expect(@textile).to include("\\* Not a list")
- expect(@textile).to include("\\- Not a list")
- expect(@textile).to include("\\*Not bold\\*")
- expect(@textile).to include("\\_Not a emph\\_")
- expect(@textile).to include("\\{Not curly\\}")
- expect(@textile).to include("\\|Not table")
+ expect(@confluence).to include("\\# Not a list")
+ expect(@confluence).to include("\\* Not a list")
+ expect(@confluence).to include("\\- Not a list")
+ expect(@confluence).to include("\\*Not bold\\*")
+ expect(@confluence).to include("\\_Not a emph\\_")
+ expect(@confluence).to include("\\{Not curly\\}")
+ expect(@confluence).to include("\\|Not table")
end
it "should support strikethrough" do
- expect(@textile).to include("-strike 1-")
- expect(@textile).to include("-strike 2-")
+ expect(@confluence).to include("-strike 1-")
+ expect(@confluence).to include("-strike 2-")
end
it "should transform code" do
- expect(@textile).to include("{code}some_good_code{code}")
+ expect(@confluence).to include("{code}some_good_code{code}")
end
end
@@ -265,11 +263,10 @@
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
- @textile = parser.to_wiki_markup
+ @confluence = parser.to_wiki_markup
- expect(@textile).to eq("{quote}\n{noformat}\n\n{noformat} \n\n{noformat}\n\n{noformat} \n\n{quote}")
+ expect(@confluence).to eq("{quote}\n{noformat}\n\n{noformat} \n\n{noformat}\n\n{noformat} \n\n{quote}")
end
it "should convert ending blockquotes without a leading pre" do
@@ -284,11 +281,10 @@
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
- @textile = parser.to_wiki_markup
+ @confluence = parser.to_wiki_markup
- expect(@textile).to eq("{quote}\n\n{noformat}\n\n{noformat} \n\n{quote}")
+ expect(@confluence).to eq("{quote}\n\n{noformat}\n\n{noformat} \n\n{quote}")
end
it "should convert ending blockquotes without a nested pre" do
@@ -303,10 +299,9 @@
END
- parser = HTMLToConfluenceParser.new
parser.feed(html)
- @textile = parser.to_wiki_markup
+ @confluence = parser.to_wiki_markup
- expect(@textile).to eq("{quote}\n{noformat}\n\n{noformat} \n\n{quote}")
+ expect(@confluence).to eq("{quote}\n{noformat}\n\n{noformat} \n\n{quote}")
end
end
diff --git a/spec/jira_examples_spec.rb b/spec/jira_examples_spec.rb
index 3310541..a3390d4 100644
--- a/spec/jira_examples_spec.rb
+++ b/spec/jira_examples_spec.rb
@@ -1,316 +1,312 @@
-# encoding: utf-8
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
-require 'html2confluence'
-
describe HTMLToConfluenceParser, "when running JIRA examples" do
-
- before :all do
- html = <<-END
-Biggest heading
-Bigger heading
-Big heading
-Normal heading
-Small heading
-Smallest heading
+ let(:parser) { HTMLToConfluenceParser.new }
-strong
-emphasis
-citation
-deleted
-inserted
-superscript
-subscript
-monospaced
-Some block quoted text
+ it "should convert images within a link" do
+ imagetarget = "https://example.com/image.jpg"
+ link = "https://example.com/index.html"
+ test_html = %{
+
+
+
+
+
+ }
-
- here is quotable
- content to be quoted
+ parser.feed test_html
+ @textile = parser.to_wiki_markup
-
- look ma, red text!
+ expect(@textile).to eq("[!#{imagetarget}!|#{link}]")
+ end
-a
b
+ context "with large document" do
+ before do
+ html = <<-END
+ Biggest heading
+ Bigger heading
+ Big heading
+ Normal heading
+ Small heading
+ Smallest heading
-a
-b
+ strong
+ emphasis
+ citation
+ deleted
+ inserted
+ superscript
+ subscript
+ monospaced
+ Some block quoted text
-
+
+ here is quotable
+ content to be quoted
-a – b
-a — b
+
+ look ma, red text!
-anchor
+ a
b
-http://jira.atlassian.com
-Atlassian
+ a
+ b
-file:///c:/temp/foo.txt
+
-
+ a – b
+ a — b
-
- - some
- - bullet
-
-
- - points
-
+ anchor
+ http://jira.atlassian.com
+ Atlassian
-
- - different
- - bullet
- - types
-
+ file:///c:/temp/foo.txt
+
-
- - a
- - numbered
- - list
-
+
+ - some
+ - bullet
+
+
+ - points
+
-
- - a
- - numbered
-
- - with
- - nested
+
+ - different
- bullet
+ - types
-
- - list
-
-
- - a
- - bulleted
- - with
- - nested
+ - a
- numbered
+ - list
-
- - list
-
-
-
-
-
-| heading 1 |
-heading 2 |
-heading 3 |
-
-
-| col A1 |
-col A2 |
-col A3 |
-
-
-| col B1 |
-col B2 |
-col B3 |
-
-
-
-
-
-
-
-
-
- END
-
- markup = <<-END
- h1. Biggest heading
-h2. Bigger heading
-h3. Big heading
-h4. Normal heading
-h5. Small heading
-h6. Smallest heading
-
-*strong*
-_emphasis_
-??citation??
--deleted-
-+inserted+
-^superscript^
-~subscript~
-{{monospaced}}
-bq. Some block quoted text
-
-{quote}
- here is quotable
- content to be quoted
-{quote}
-
-{color:red}
- look ma, red text!
-{color}
-
-a\\b
-
-a
-b
-
-----
-
-a -- b
-a --- b
-
-[#anchor]
-
-[http://jira.atlassian.com]
-[Atlassian|http://atlassian.com]
-
-[file:///c:/temp/foo.txt]
-
-{anchor:anchorname}
-
-* some
-* bullet
-** indented
-** bullets
-* points
-
-- different
-- bullet
-- types
-
-# a
-# numbered
-# list
-
-# a
-# numbered
-#* with
-#* nested
-#* bullet
-# list
-
-* a
-* bulleted
-*# with
-*# nested
-*# numbered
-* list
-
-||heading 1||heading 2||heading 3||
-|col A1|col A2|col A3|
-|col B1|col B2|col B3|
-
-{noformat}
-preformatted piece of text
- so *no* further _formatting_ is done here
-{noformat}
- END
-
-
- parser = HTMLToConfluenceParser.new
- parser.feed(html)
- @textile = parser.to_wiki_markup
- #puts @textile
- #puts RedCloth.new(@textile).to_html
- end
- it "should convert images within a link" do
- imagetarget = "https://example.com/image.jpg"
- link = "https://example.com/index.html"
- test_html = %{
-
-
-
-
-
- }
- parser = HTMLToConfluenceParser.new
- parser.feed test_html
- @textile = parser.to_wiki_markup
+
+ - a
+ - numbered
+
+ - with
+ - nested
+ - bullet
+
+
+ - list
+
- expect(@textile).to eq("[!#{imagetarget}!|#{link}]")
- end
- it "should convert heading tags" do
- expect(@textile).to match(/^h1. Biggest heading/)
- expect(@textile).to match(/^h2. Bigger heading/)
- expect(@textile).to match(/^h3. Big heading/)
- expect(@textile).to match(/^h4. Normal heading/)
- expect(@textile).to match(/^h5. Small heading/)
- expect(@textile).to match(/^h6. Smallest heading/)
- end
-
- it "should convert inline formatting" do
- expect(@textile).to match(/^\*strong\*/)
- expect(@textile).to match(/^_emphasis_/)
- expect(@textile).to match(/^\?\?citation\?\?/)
- expect(@textile).to match(/^-deleted-/)
- expect(@textile).to match(/^\+inserted\+/)
- expect(@textile).to match(/^\^superscript\^/)
- expect(@textile).to match(/^\~subscript\~/)
- expect(@textile).to match(/^\{\{monospaced\}\}/)
- end
-
- it "should convert block quotes" do
- expect(@textile).to match(/^bq. Some block quoted text/)
- expect(@textile).to match(/^\{quote\}\s*here is quotable\s*content to be quoted\s*{quote}/)
- end
-
- it "should handle text color" do
- expect(@textile).to match(/^\{color\:red\}\s*look ma, red text!\s*\{color\}/)
- end
-
- it "should convert horizontal rules" do
- expect(@textile).to match(/^----/)
- end
-
- it "should convert dashes" do
- expect(@textile).to match(/^a -- b/)
- expect(@textile).to match(/^a --- b/)
- end
-
- it "should convert links" do
- expect(@textile).to match(/^\[\#anchor\]/)
- expect(@textile).to match(/^\[http\:\/\/jira.atlassian.com\]/)
- expect(@textile).to match(/^\[Atlassian\|http\:\/\/atlassian.com\]/)
- expect(@textile).to match(/^\[file\:\/\/\/c\:\/temp\/foo.txt\]/)
- end
-
- it "should convert bullets" do
- expect(@textile).to match(/\* some\s*\* bullet\s*\*\* indented\s*\*\* bullets\s*\* points/)
- expect(@textile).to match(/- different\s*- bullet\s*- types/)
- expect(@textile).to match(/# a\s*# numbered\s*# list/)
- expect(@textile).to match(/# a\s*# numbered\s*#\* with\s*#\* nested\s*#\* bullet\s*# list/)
- expect(@textile).to match(/\* a\s*\* bulleted\s*\*# with\s*\*# nested\s*\*# numbered\s*\* list/)
- end
-
- it "should convert pre blocks" do
- expect(@textile).to match(/^\{noformat\}\s*preformatted piece of text\s*so \*no\* further _formatting_ is done here\s*\{noformat\}/)
- end
-
- it "should convert tables" do
- expect(@textile).to include("||heading 1 ||heading 2 ||heading 3 ||")
- expect(@textile).to include("|col A1 |col A2 |col A3 |")
- expect(@textile).to include("|col B1 |col B2 |col B3 |")
- end
+
+ - a
+ - bulleted
+
+ - with
+ - nested
+ - numbered
+
+
+ - list
+
- it "should convert emoji from jira" do
- expect(@textile).to include(":)")
- expect(@textile).to include("(!)")
- expect(@textile).to include("(off)")
- expect(@textile).to include("(/)")
+
+
+
+ | heading 1 |
+ heading 2 |
+ heading 3 |
+
+
+ | col A1 |
+ col A2 |
+ col A3 |
+
+
+ | col B1 |
+ col B2 |
+ col B3 |
+
+
+
+
+
+
+
+
+
+ END
+
+ markup = <<-END
+ h1. Biggest heading
+ h2. Bigger heading
+ h3. Big heading
+ h4. Normal heading
+ h5. Small heading
+ h6. Smallest heading
+
+ *strong*
+ _emphasis_
+ ??citation??
+ -deleted-
+ +inserted+
+ ^superscript^
+ ~subscript~
+ {{monospaced}}
+
+ {quote}
+ Some block quoted text
+ {quote}
+
+ {quote}
+ here is quotable
+ content to be quoted
+ {quote}
+
+ {color:red}
+ look ma, red text!
+ {color}
+
+ a\\b
+
+ a
+ b
+
+ ----
+
+ a -- b
+ a --- b
+
+ [#anchor]
+
+ [http://jira.atlassian.com]
+ [Atlassian|http://atlassian.com]
+
+ [file:///c:/temp/foo.txt]
+
+ {anchor:anchorname}
+
+ * some
+ * bullet
+ ** indented
+ ** bullets
+ * points
+
+ - different
+ - bullet
+ - types
+
+ # a
+ # numbered
+ # list
+
+ # a
+ # numbered
+ #* with
+ #* nested
+ #* bullet
+ # list
+
+ * a
+ * bulleted
+ *# with
+ *# nested
+ *# numbered
+ * list
+
+ ||heading 1||heading 2||heading 3||
+ |col A1|col A2|col A3|
+ |col B1|col B2|col B3|
+
+ {noformat}
+ preformatted piece of text
+ so *no* further _formatting_ is done here
+ {noformat}
+ END
+
+ parser.feed(html)
+ @confluence = parser.to_wiki_markup
+ end
+
+ it "should convert heading tags" do
+ expect(@confluence).to match(/^h1. Biggest heading/)
+ expect(@confluence).to match(/^h2. Bigger heading/)
+ expect(@confluence).to match(/^h3. Big heading/)
+ expect(@confluence).to match(/^h4. Normal heading/)
+ expect(@confluence).to match(/^h5. Small heading/)
+ expect(@confluence).to match(/^h6. Smallest heading/)
+ end
+
+ it "should convert inline formatting" do
+ expect(@confluence).to match(/^\*strong\*/)
+ expect(@confluence).to match(/^_emphasis_/)
+ expect(@confluence).to match(/^\?\?citation\?\?/)
+ expect(@confluence).to match(/^-deleted-/)
+ expect(@confluence).to match(/^\+inserted\+/)
+ expect(@confluence).to match(/^\^superscript\^/)
+ expect(@confluence).to match(/^\~subscript\~/)
+ expect(@confluence).to match(/^\{\{monospaced\}\}/)
+ end
+
+ it "should convert block quotes" do
+ expect(@confluence).to match(/^{quote}\nSome block quoted text\n{quote}/)
+ expect(@confluence).to match(/^\{quote\}\s*here is quotable\s*content to be quoted\s*{quote}/)
+ end
+
+ it "should handle text color" do
+ expect(@confluence).to match(/^\{color\:red\}\s*look ma, red text!\s*\{color\}/)
+ end
+
+ it "should convert horizontal rules" do
+ expect(@confluence).to match(/^----/)
+ end
+
+ it "should convert dashes" do
+ expect(@confluence).to match(/^a -- b/)
+ expect(@confluence).to match(/^a --- b/)
+ end
+
+ it "should convert links" do
+ expect(@confluence).to match(/^\[\#anchor\]/)
+ expect(@confluence).to match(/^\[http\:\/\/jira.atlassian.com\]/)
+ expect(@confluence).to match(/^\[Atlassian\|http\:\/\/atlassian.com\]/)
+ expect(@confluence).to match(/^\[file\:\/\/\/c\:\/temp\/foo.txt\]/)
+ end
+
+ it "should convert bullets" do
+ expect(@confluence).to match(/\* some\s*\* bullet\s*\*\* indented\s*\*\* bullets\s*\* points/)
+ expect(@confluence).to match(/- different\s*- bullet\s*- types/)
+ expect(@confluence).to match(/# a\s*# numbered\s*# list/)
+ expect(@confluence).to match(/# a\s*# numbered\s*#\* with\s*#\* nested\s*#\* bullet\s*# list/)
+ expect(@confluence).to match(/\* a\s*\* bulleted\s*\*# with\s*\*# nested\s*\*# numbered\s*\* list/)
+ end
+
+ it "should convert pre blocks" do
+ expect(@confluence).to match(/^\{noformat\}\s*preformatted piece of text\s*so \*no\* further _formatting_ is done here\s*\{noformat\}/)
+ end
+
+ it "should convert tables" do
+ expect(@confluence).to include("||heading 1 ||heading 2 ||heading 3 ||")
+ expect(@confluence).to include("|col A1 |col A2 |col A3 |")
+ expect(@confluence).to include("|col B1 |col B2 |col B3 |")
+ end
+
+ it "should convert emoji from jira" do
+ expect(@confluence).to include(":)")
+ expect(@confluence).to include("(!)")
+ expect(@confluence).to include("(off)")
+ expect(@confluence).to include("(/)")
+ end
end
-
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..8c3b69f
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,8 @@
+require 'rspec'
+require 'html2confluence'
+
+RSpec.configure do |config|
+ config.filter_gems_from_backtrace "rspec-core", "rspec"
+ config.run_all_when_everything_filtered = true
+ config.order = :random
+end