reverse_markdown 0.7.0 → 0.8.0

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: d1ee719972c0c06f84c6df44ff2cacdec0d3630c
4
- data.tar.gz: 857ee9cfc3c01374fe0904dbed85ed63fb58ce79
3
+ metadata.gz: 01b3bd87ed314c7c27b36ea54e85094b8978f47a
4
+ data.tar.gz: 5e6281c33ddd442a52ada8b35753f7e50782f0f1
5
5
  SHA512:
6
- metadata.gz: 4f5d772f3847ed3cb6e82e8f177dc70cc1143bb6f38edaf98eaa554d0d2965f6a8f85fe14d7999b72ef824ea10a4d5eb93d991a6c7d51d609f34aafa8faf8859
7
- data.tar.gz: dbb1c987a62990504c492879026ebdb37d3fb82bc7f12b16bdb60be920cb489e90cbf574162c39d96bdae145054abfdaddcd9eb7de7f66f7753fc3af77b73abb
6
+ metadata.gz: 9ddc12421dd427d581c14e0c4fe3eb98087bb057b24401b7e8bed7975ed8a1ff52b1ddefbbb9494c8a7136dbe35010cb0fcd31ef2419be338247bf45b5ef90ea
7
+ data.tar.gz: 9078b5ed562091011c7d3de8578bf514fcfba0c83aad596c9752c38b5e56a00d63e38c737e6c9e09fcad75b338ed673b4f7a78f34c8ed3141e5cfb2a70748e3c
@@ -2,7 +2,7 @@ rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
4
  - 2.1.0
5
- - 2.1.1
5
+ - 2.1.5
6
6
  - 2.2.0
7
7
 
8
8
  script: "bundle exec rake spec"
@@ -1,6 +1,13 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 0.8.0 - April 2015
5
+ ### Added
6
+ - `article` tag is now supported and treated like a div
7
+
8
+ ### Changed
9
+ - Special characters are treated correctly inside of backticks, see (#47)
10
+
4
11
  ## 0.7.0 - February 2015
5
12
  ### Added
6
13
  - pre-tags support syntax github and confluence syntax highlighting now
@@ -62,6 +62,7 @@ module ReverseMarkdown
62
62
  private
63
63
 
64
64
  def preserve_border_whitespaces(string, options = {}, &block)
65
+ return string if string =~ /\A\s*\Z/
65
66
  default_border = options.fetch(:default_border, '')
66
67
  string_start = present_or_default(string[/\A\s*/], default_border)
67
68
  string_end = present_or_default(string[/\s*\Z/], default_border)
@@ -5,6 +5,10 @@ module ReverseMarkdown
5
5
  @@converters[tag_name.to_sym] = converter
6
6
  end
7
7
 
8
+ def self.unregister(tag_name)
9
+ @@converters.delete(tag_name.to_sym)
10
+ end
11
+
8
12
  def self.lookup(tag_name)
9
13
  @@converters[tag_name.to_sym] or default_converter(tag_name)
10
14
  end
@@ -6,6 +6,7 @@ module ReverseMarkdown
6
6
  end
7
7
  end
8
8
 
9
- register :div, Div.new
9
+ register :div, Div.new
10
+ register :article, Div.new
10
11
  end
11
12
  end
@@ -6,7 +6,7 @@ module ReverseMarkdown
6
6
  if content.strip.empty? || already_italic?(node)
7
7
  content
8
8
  else
9
- "_#{content}_"
9
+ "#{content[/^\s*/]}_#{content.strip}_#{content[/\s*$/]}"
10
10
  end
11
11
  end
12
12
 
@@ -6,7 +6,7 @@ module ReverseMarkdown
6
6
  if content.strip.empty? || already_strong?(node)
7
7
  content
8
8
  else
9
- "**#{content}**"
9
+ "#{content[/^\s*/]}**#{content.strip}**#{content[/\s*$/]}"
10
10
  end
11
11
  end
12
12
 
@@ -27,7 +27,9 @@ module ReverseMarkdown
27
27
  text = preserve_nbsp(text)
28
28
  text = remove_border_newlines(text)
29
29
  text = remove_inner_newlines(text)
30
- escape_keychars text
30
+ text = escape_keychars(text)
31
+
32
+ preserve_keychars_within_backticks(text)
31
33
  end
32
34
 
33
35
  def preserve_nbsp(text)
@@ -41,6 +43,12 @@ module ReverseMarkdown
41
43
  def remove_inner_newlines(text)
42
44
  text.tr("\n\t", ' ').squeeze(' ')
43
45
  end
46
+
47
+ def preserve_keychars_within_backticks(text)
48
+ text.gsub(/`.*?`/) do |match|
49
+ match.gsub('\_', '_').gsub('\*', '*')
50
+ end
51
+ end
44
52
  end
45
53
 
46
54
  register :text, Text.new
@@ -1,3 +1,3 @@
1
1
  module ReverseMarkdown
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -14,6 +14,10 @@
14
14
  before <em> <em> <br /> </em> </em> and after em tags containing whitespace
15
15
  <em><em>double em tags</em></em>
16
16
  <p><em><em>double em tags in p tag</em></em></p>
17
+ <em> em with leading and trailing </em>whitespace
18
+ <em>
19
+ em with extra leading and trailing
20
+ </em>whitespace
17
21
 
18
22
  <strong>strong tag content</strong>
19
23
  before <strong></strong> and after empty strong tags
@@ -27,6 +31,10 @@
27
31
  double strong tags containing whitespace
28
32
  </strong>
29
33
  </strong> after
34
+ <strong> strong with leading and trailing </strong>whitespace
35
+ <strong>
36
+ strong with extra leading and trailing
37
+ </strong>whitespace
30
38
 
31
39
  <b>b tag content</b>
32
40
  <i>i tag content</i>
@@ -19,6 +19,8 @@ describe ReverseMarkdown do
19
19
  it { should match /before and after em tags containing whitespace/ }
20
20
  it { should match /_double em tags_/ }
21
21
  it { should match /_double em tags in p tag_/ }
22
+ it { should match /_em with leading and trailing_ whitespace/ }
23
+ it { should match /_em with extra leading and trailing_ whitespace/ }
22
24
 
23
25
  it { should match /\*\*strong tag content\*\*/ }
24
26
  it { should match /before and after empty strong tags/ }
@@ -26,6 +28,8 @@ describe ReverseMarkdown do
26
28
  it { should match /\*\*double strong tags\*\*/ }
27
29
  it { should match /\*\*double strong tags in p tag\*\*/ }
28
30
  it { should match /before \*\*double strong tags containing whitespace\*\* after/ }
31
+ it { should match /\*\*strong with leading and trailing\*\* whitespace/ }
32
+ it { should match /\*\*strong with extra leading and trailing\*\* whitespace/ }
29
33
 
30
34
  it { should match /_i tag content_/ }
31
35
  it { should match /\*\*b tag content\*\*/ }
@@ -7,9 +7,7 @@ describe ReverseMarkdown do
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
9
  it "should make sense of strong-crazy markup (as seen in the wild)" do
10
- expect(subject).to eq '**.' + " \n" +
11
- ' \*\*\* intentcast ** : logo design' + " \n" +
12
- "**.**\n\n"
10
+ expect(subject).to eq "**. \n \\*\\*\\* intentcast** : logo design \n **.**\n\n"
13
11
  end
14
12
 
15
13
  end
@@ -45,6 +45,11 @@ describe ReverseMarkdown::Cleaner do
45
45
  result = cleaner.remove_inner_whitespaces("foo\t \tbar")
46
46
  expect(result).to eq "foo bar"
47
47
  end
48
+
49
+ it 'keeps lines that only contain whitespace' do
50
+ result = cleaner.remove_inner_whitespaces("foo \nbar \n \n \nfoo")
51
+ expect(result).to eq "foo \nbar \n \n \nfoo"
52
+ end
48
53
  end
49
54
 
50
55
  describe '#clean_punctuation_characters' do
@@ -28,4 +28,29 @@ describe ReverseMarkdown::Converters::Text do
28
28
  expect(result).to eq "foo&nbsp;bar &nbsp;"
29
29
  end
30
30
 
31
+ context 'within backticks' do
32
+ it "preserves single underscores" do
33
+ input = node_for("<p>`foo_bar`</p>")
34
+ result = converter.convert(input)
35
+ expect(result).to eq '`foo_bar`'
36
+ end
37
+
38
+ it "preserves multiple underscores" do
39
+ input = node_for("<p>`foo_bar __example__`</p>")
40
+ result = converter.convert(input)
41
+ expect(result).to eq '`foo_bar __example__`'
42
+ end
43
+
44
+ it "preserves single asterisks" do
45
+ input = node_for("<p>`def foo *args`</p>")
46
+ result = converter.convert(input)
47
+ expect(result).to eq '`def foo *args`'
48
+ end
49
+
50
+ it "preserves multiple asterisks" do
51
+ input = node_for("<p>`def foo 2***3`</p>")
52
+ result = converter.convert(input)
53
+ expect(result).to eq '`def foo 2***3`'
54
+ end
55
+ end
31
56
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReverseMarkdown::Converters do
4
+ before { ReverseMarkdown.config.unknown_tags = :raise }
5
+ let(:converters) { ReverseMarkdown::Converters }
6
+
7
+ describe '.register and .unregister' do
8
+ it 'adds a converter mapping to the list' do
9
+ expect { converters.lookup(:foo) }.to raise_error
10
+
11
+ converters.register :foo, :foobar
12
+ expect(converters.lookup(:foo)).to eq :foobar
13
+
14
+ converters.unregister :foo
15
+ expect { converters.lookup(:foo) }.to raise_error
16
+ end
17
+ end
18
+
19
+ end
@@ -4,7 +4,7 @@ CodeClimate::TestReporter.start
4
4
  require 'simplecov'
5
5
  # require 'byebug'
6
6
 
7
- SimpleCov.adapters.define 'gem' do
7
+ SimpleCov.profiles.define 'gem' do
8
8
  add_filter '/spec/'
9
9
  add_filter '/autotest/'
10
10
  add_group 'Libraries', '/lib/'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reverse_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -176,6 +176,7 @@ files:
176
176
  - spec/lib/reverse_markdown/converters/li_spec.rb
177
177
  - spec/lib/reverse_markdown/converters/pre_spec.rb
178
178
  - spec/lib/reverse_markdown/converters/text_spec.rb
179
+ - spec/lib/reverse_markdown/converters_spec.rb
179
180
  - spec/lib/reverse_markdown_spec.rb
180
181
  - spec/spec_helper.rb
181
182
  homepage: http://github.com/xijo/reverse_markdown
@@ -235,5 +236,6 @@ test_files:
235
236
  - spec/lib/reverse_markdown/converters/li_spec.rb
236
237
  - spec/lib/reverse_markdown/converters/pre_spec.rb
237
238
  - spec/lib/reverse_markdown/converters/text_spec.rb
239
+ - spec/lib/reverse_markdown/converters_spec.rb
238
240
  - spec/lib/reverse_markdown_spec.rb
239
241
  - spec/spec_helper.rb