mongoid_markdown_extension 0.1.1 → 0.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed5543f899cfbb9a773dbb7a05f05d6f8e9c0037
|
4
|
+
data.tar.gz: da87d5dc825cdeeffb2ad3742041ba4c0c579673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88f89f6fcad77e454afd7084cf6ceef3302b83a370fd8989cb2f3fe8e4d092791965cfcd62eeaae4575f59f8babd940f864aaf1d68a4a68f186b8a6d3929a62b
|
7
|
+
data.tar.gz: 9c0ad7920542db4e0038fbab17b7c7ad5edbbf951f96db80d0eb41cedbba29913b61c514fb8cb2af413e2974f577d236c0ace6a1aeebc9ab80c062e9964a54fc
|
data/.travis.yml
CHANGED
@@ -2,30 +2,29 @@ require 'redcarpet'
|
|
2
2
|
|
3
3
|
module MongoidMarkdownExtension
|
4
4
|
class InlineRenderer < Redcarpet::Render::HTML
|
5
|
-
|
6
5
|
include Redcarpet::Render::SmartyPants
|
7
6
|
|
8
|
-
def block_code
|
7
|
+
def block_code(_code, _language)
|
9
8
|
nil
|
10
9
|
end
|
11
10
|
|
12
|
-
def block_quote
|
11
|
+
def block_quote(_quote)
|
13
12
|
nil
|
14
13
|
end
|
15
14
|
|
16
|
-
def block_html
|
15
|
+
def block_html(_raw_html)
|
17
16
|
nil
|
18
17
|
end
|
19
18
|
|
20
|
-
def footnotes
|
19
|
+
def footnotes(_content)
|
21
20
|
nil
|
22
21
|
end
|
23
22
|
|
24
|
-
def footnote_def
|
23
|
+
def footnote_def(_content, _number)
|
25
24
|
nil
|
26
25
|
end
|
27
26
|
|
28
|
-
def header
|
27
|
+
def header(_text, _header_level)
|
29
28
|
nil
|
30
29
|
end
|
31
30
|
|
@@ -33,17 +32,16 @@ module MongoidMarkdownExtension
|
|
33
32
|
nil
|
34
33
|
end
|
35
34
|
|
36
|
-
def list
|
35
|
+
def list(_contents, _list_type)
|
37
36
|
nil
|
38
37
|
end
|
39
38
|
|
40
|
-
def list_item
|
39
|
+
def list_item(_text, _list_type)
|
41
40
|
nil
|
42
41
|
end
|
43
42
|
|
44
|
-
def paragraph
|
45
|
-
text
|
43
|
+
def paragraph(text)
|
44
|
+
text + "<br /><br />"
|
46
45
|
end
|
47
|
-
|
48
46
|
end
|
49
47
|
end
|
@@ -3,8 +3,7 @@ require 'redcarpet/render_strip'
|
|
3
3
|
|
4
4
|
module MongoidMarkdownExtension
|
5
5
|
class Markdown < String
|
6
|
-
|
7
|
-
def initialize str
|
6
|
+
def initialize(str)
|
8
7
|
super str.to_s
|
9
8
|
@str = str.to_s
|
10
9
|
end
|
@@ -18,7 +17,7 @@ module MongoidMarkdownExtension
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def to_inline_html
|
21
|
-
markdown_inline_renderer.render(@str).html_safe
|
20
|
+
markdown_inline_renderer.render(@str).html_safe.gsub(/(<br\s?\/?>)+?\Z/, '')
|
22
21
|
end
|
23
22
|
|
24
23
|
def to_stripped_s
|
@@ -49,7 +48,6 @@ module MongoidMarkdownExtension
|
|
49
48
|
# ---------------------------------------------------------------------
|
50
49
|
|
51
50
|
class << self
|
52
|
-
|
53
51
|
attr_accessor :configuration
|
54
52
|
|
55
53
|
def configure
|
@@ -61,24 +59,23 @@ module MongoidMarkdownExtension
|
|
61
59
|
@configuration ||= Configuration.new
|
62
60
|
end
|
63
61
|
|
64
|
-
def demongoize
|
62
|
+
def demongoize(value)
|
65
63
|
Markdown.new(value)
|
66
64
|
end
|
67
65
|
|
68
|
-
def mongoize
|
66
|
+
def mongoize(value)
|
69
67
|
case value
|
70
68
|
when Markdown then value.mongoize
|
71
69
|
else value
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
75
|
-
def evolve
|
73
|
+
def evolve(value)
|
76
74
|
case value
|
77
75
|
when Markdown then value.mongoize
|
78
76
|
else value
|
79
77
|
end
|
80
78
|
end
|
81
|
-
|
82
79
|
end
|
83
80
|
end
|
84
81
|
|
@@ -11,7 +11,6 @@ end
|
|
11
11
|
|
12
12
|
module MongoidMarkdownExtension
|
13
13
|
describe Markdown do
|
14
|
-
|
15
14
|
let(:string) { 'some text with _italic_' }
|
16
15
|
subject { MongoidMarkdownExtension::Markdown.new(string) }
|
17
16
|
|
@@ -23,14 +22,7 @@ module MongoidMarkdownExtension
|
|
23
22
|
end
|
24
23
|
end
|
25
24
|
it 'returns default values' do
|
26
|
-
MongoidMarkdownExtension::Markdown.configuration.extensions.must_equal(
|
27
|
-
autolink: true,
|
28
|
-
footnotes: true,
|
29
|
-
highlight: true,
|
30
|
-
space_after_headers: true,
|
31
|
-
strikethrough: true,
|
32
|
-
superscript: true
|
33
|
-
})
|
25
|
+
MongoidMarkdownExtension::Markdown.configuration.extensions.must_equal(autolink: true, footnotes: true, highlight: true, space_after_headers: true, strikethrough: true, superscript: true)
|
34
26
|
MongoidMarkdownExtension::Markdown.configuration.render_options.must_equal({})
|
35
27
|
end
|
36
28
|
end
|
@@ -54,11 +46,16 @@ module MongoidMarkdownExtension
|
|
54
46
|
end
|
55
47
|
|
56
48
|
describe '#to_inline_html' do
|
49
|
+
let(:string) { "some text with _italic_\n\nfoo" }
|
50
|
+
|
57
51
|
it 'survives nil' do
|
58
52
|
MongoidMarkdownExtension::Markdown.new(nil).to_inline_html.must_equal ''
|
59
53
|
end
|
60
54
|
it 'converts the string to html' do
|
61
|
-
subject.to_inline_html.wont_include
|
55
|
+
subject.to_inline_html.wont_include '<p>'
|
56
|
+
end
|
57
|
+
it 'replaces <p> with <br />' do
|
58
|
+
subject.to_inline_html.must_equal 'some text with <em>italic</em><br /><br />foo'
|
62
59
|
end
|
63
60
|
end
|
64
61
|
|
@@ -67,7 +64,7 @@ module MongoidMarkdownExtension
|
|
67
64
|
MongoidMarkdownExtension::Markdown.new(nil).to_stripped_s.must_equal ''
|
68
65
|
end
|
69
66
|
it 'converts the markdown to stripped string' do
|
70
|
-
subject.to_stripped_s.wont_include
|
67
|
+
subject.to_stripped_s.wont_include '_'
|
71
68
|
end
|
72
69
|
end
|
73
70
|
|
@@ -101,6 +98,5 @@ module MongoidMarkdownExtension
|
|
101
98
|
MongoidMarkdownExtension::Markdown.demongoize(string).must_be_kind_of MongoidMarkdownExtension::Markdown
|
102
99
|
end
|
103
100
|
end
|
104
|
-
|
105
101
|
end
|
106
102
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_markdown_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomáš Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.4.
|
131
|
+
rubygems_version: 2.4.6
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Custom field type for Mongoid that handles Markdown conversion via Redcarpet
|