reverse_markdown 0.8.1 → 0.8.2
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/CHANGELOG.md +4 -0
- data/lib/reverse_markdown/cleaner.rb +3 -0
- data/lib/reverse_markdown/config.rb +5 -3
- data/lib/reverse_markdown/version.rb +1 -1
- data/spec/lib/reverse_markdown/cleaner_spec.rb +12 -0
- data/spec/lib/reverse_markdown/converters/strong_spec.rb +20 -0
- 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: 883820fb93f917bc937cd5c12963f3482a0e808f
|
4
|
+
data.tar.gz: a02eedd1b8ab8d3e115947e55d72e6f559577e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a03b2214708c5bf1a56d76d9ce944f4b3a7ea76f0f00657c6873d3b25617122b2376b685980f7f149894274a617aedb01cd7d5952e518db737d406c1579a89a
|
7
|
+
data.tar.gz: 91371fc841d5b46cbb99a6af813ce404702ceffe0b46403f5eb61bc579609c00ade300dc174cc68b982e7a3f18b05c4a2a28abb4f7b7a8c0bf4132bdbdef3d0c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## 0.8.2 - May 2015
|
5
|
+
### Changes
|
6
|
+
- Don't add whitespaces in links and images if they contain underscores
|
7
|
+
|
4
8
|
## 0.8.1 - April 2015
|
5
9
|
### Changes
|
6
10
|
- Don't add newlines after nested lists
|
@@ -64,6 +64,9 @@ module ReverseMarkdown
|
|
64
64
|
def preserve_border_whitespaces(string, options = {}, &block)
|
65
65
|
return string if string =~ /\A\s*\Z/
|
66
66
|
default_border = options.fetch(:default_border, '')
|
67
|
+
# If the string contains part of a link so the characters [,],(,)
|
68
|
+
# then don't add any extra spaces
|
69
|
+
default_border = '' if string =~ /[\[\(\]\)]/
|
67
70
|
string_start = present_or_default(string[/\A\s*/], default_border)
|
68
71
|
string_end = present_or_default(string[/\s*\Z/], default_border)
|
69
72
|
result = yield
|
@@ -3,9 +3,11 @@ module ReverseMarkdown
|
|
3
3
|
attr_accessor :unknown_tags, :github_flavored
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@unknown_tags
|
7
|
-
@github_flavored
|
8
|
-
@
|
6
|
+
@unknown_tags = :pass_through
|
7
|
+
@github_flavored = false
|
8
|
+
@em_delimiter = '_'
|
9
|
+
@strong_delimiter = '**'
|
10
|
+
@inline_options = {}
|
9
11
|
end
|
10
12
|
|
11
13
|
def with(options = {})
|
@@ -79,6 +79,18 @@ describe ReverseMarkdown::Cleaner do
|
|
79
79
|
expect(result).to eq "1 **fat** 2"
|
80
80
|
end
|
81
81
|
|
82
|
+
it "doesn't add whitespaces to underscore'ed elements if they are part of links" do
|
83
|
+
input = ""
|
84
|
+
result = cleaner.clean_tag_borders(input)
|
85
|
+
expect(result).to eq ""
|
86
|
+
end
|
87
|
+
|
88
|
+
it "still cleans up whitespaces that aren't inside a link" do
|
89
|
+
input = "now __italic __with following [under__scored](link)"
|
90
|
+
result = cleaner.clean_tag_borders(input)
|
91
|
+
expect(result).to eq "now __italic__ with following [under__scored](link)"
|
92
|
+
end
|
93
|
+
|
82
94
|
it 'cleans italic stuff as well' do
|
83
95
|
input = "1 __italic __ 2 __ italic__ 3__italic __4"
|
84
96
|
result = cleaner.clean_tag_borders(input)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ReverseMarkdown::Converters::Strong do
|
4
|
+
let(:converter) { ReverseMarkdown::Converters::Strong.new }
|
5
|
+
|
6
|
+
it 'returns an empty string if the node is empty' do
|
7
|
+
input = node_for('<strong></strong>')
|
8
|
+
expect(converter.convert(input)).to eq ''
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns just the content if the strong tag is nested in another strong' do
|
12
|
+
input = node_for('<strong><strong>foo</strong></strong>')
|
13
|
+
expect(converter.convert(input.children.first)).to eq 'foo'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'moves border whitespaces outside of the delimiters tag' do
|
17
|
+
input = node_for("<strong> \n foo </strong>")
|
18
|
+
expect(converter.convert(input)).to eq " **foo** "
|
19
|
+
end
|
20
|
+
end
|
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.8.
|
4
|
+
version: 0.8.2
|
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-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- spec/lib/reverse_markdown/converters/del_spec.rb
|
176
176
|
- spec/lib/reverse_markdown/converters/li_spec.rb
|
177
177
|
- spec/lib/reverse_markdown/converters/pre_spec.rb
|
178
|
+
- spec/lib/reverse_markdown/converters/strong_spec.rb
|
178
179
|
- spec/lib/reverse_markdown/converters/text_spec.rb
|
179
180
|
- spec/lib/reverse_markdown/converters_spec.rb
|
180
181
|
- spec/lib/reverse_markdown_spec.rb
|
@@ -235,6 +236,7 @@ test_files:
|
|
235
236
|
- spec/lib/reverse_markdown/converters/del_spec.rb
|
236
237
|
- spec/lib/reverse_markdown/converters/li_spec.rb
|
237
238
|
- spec/lib/reverse_markdown/converters/pre_spec.rb
|
239
|
+
- spec/lib/reverse_markdown/converters/strong_spec.rb
|
238
240
|
- spec/lib/reverse_markdown/converters/text_spec.rb
|
239
241
|
- spec/lib/reverse_markdown/converters_spec.rb
|
240
242
|
- spec/lib/reverse_markdown_spec.rb
|