reverse_markdown 0.7.0 → 0.8.0
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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/lib/reverse_markdown/cleaner.rb +1 -0
- data/lib/reverse_markdown/converters.rb +4 -0
- data/lib/reverse_markdown/converters/div.rb +2 -1
- data/lib/reverse_markdown/converters/em.rb +1 -1
- data/lib/reverse_markdown/converters/strong.rb +1 -1
- data/lib/reverse_markdown/converters/text.rb +9 -1
- data/lib/reverse_markdown/version.rb +1 -1
- data/spec/assets/basic.html +8 -0
- data/spec/components/basic_spec.rb +4 -0
- data/spec/components/from_the_wild_spec.rb +1 -3
- data/spec/lib/reverse_markdown/cleaner_spec.rb +5 -0
- data/spec/lib/reverse_markdown/converters/text_spec.rb +25 -0
- data/spec/lib/reverse_markdown/converters_spec.rb +19 -0
- data/spec/spec_helper.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01b3bd87ed314c7c27b36ea54e85094b8978f47a
|
4
|
+
data.tar.gz: 5e6281c33ddd442a52ada8b35753f7e50782f0f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ddc12421dd427d581c14e0c4fe3eb98087bb057b24401b7e8bed7975ed8a1ff52b1ddefbbb9494c8a7136dbe35010cb0fcd31ef2419be338247bf45b5ef90ea
|
7
|
+
data.tar.gz: 9078b5ed562091011c7d3de8578bf514fcfba0c83aad596c9752c38b5e56a00d63e38c737e6c9e09fcad75b338ed673b4f7a78f34c8ed3141e5cfb2a70748e3c
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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)
|
@@ -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
|
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
|
data/spec/assets/basic.html
CHANGED
@@ -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
|
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 bar "
|
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
|
data/spec/spec_helper.rb
CHANGED
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.
|
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-
|
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
|