ultra_markdown 0.1.1 → 0.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.
data/README.md CHANGED
@@ -18,7 +18,12 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO
21
+
22
+ ### CSS
23
+
24
+ ```
25
+ //= require solarized
26
+ ```
22
27
 
23
28
  ## Contributing
24
29
 
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class NilClass
3
+ def to_markdown
4
+ return ""
5
+ end
6
+
7
+ def to_markdown_for_rss
8
+ return ""
9
+ end
10
+
11
+ end
@@ -0,0 +1,76 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class String
3
+ def to_markdown
4
+ content = self
5
+ return "" if content.blank?
6
+
7
+ UltraMarkdown::MarkdownProcessor.compile(content).html_safe
8
+ end
9
+
10
+ def to_markdown_for_rss
11
+ content = self
12
+ return "" if content.blank?
13
+
14
+ UltraMarkdown::MarkdownProcessor.compile_for_rss(content).html_safe
15
+ end
16
+
17
+
18
+
19
+ def to_markdown_preview(current_line = 1)
20
+ return to_markdown if current_line == 1
21
+
22
+ content = self
23
+ mirror_content = content.clone
24
+ random_seed = (0...16).map{ ('a'..'z').to_a[rand(26)] }.join
25
+
26
+ mirror_content = insert_to_specific_line(mirror_content, current_line, random_seed)
27
+ mirror_content_markdown = mirror_content.to_markdown
28
+ pivot_line = find_text_in_line(mirror_content_markdown, random_seed)
29
+
30
+ insert_to_specific_line(content.to_markdown, pivot_line, "<span class=\"preview-target\"> </span>")
31
+ end
32
+
33
+
34
+ def excerpt
35
+ if self.index(UltraMarkdown::MarkdownSnippets::MORE_REGEX)
36
+ self.split(UltraMarkdown::MarkdownSnippets::MORE_REGEX)[0].try(:html_safe)
37
+ else
38
+ self
39
+ end
40
+ end
41
+
42
+
43
+
44
+ private
45
+
46
+
47
+
48
+ def insert_to_specific_line(mirror_content = "", current_line = 0, insert_text)
49
+ output = ""
50
+ line_num = 0
51
+
52
+ mirror_content.each_line do |line|
53
+ line_num += 1
54
+ if (line_num == current_line)
55
+ output += insert_text + line
56
+ else
57
+ output += line
58
+ end
59
+ end
60
+
61
+ output
62
+ end
63
+
64
+ def find_text_in_line(mirror_content_markdown = "", text)
65
+ line_num = 0
66
+
67
+ mirror_content_markdown.each_line do |line|
68
+ line_num += 1
69
+ return line_num if line[text]
70
+ end
71
+ end
72
+
73
+
74
+
75
+ end
76
+
@@ -1,3 +1,3 @@
1
1
  module UltraMarkdown
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultra_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -153,6 +153,8 @@ files:
153
153
  - LICENSE.txt
154
154
  - README.md
155
155
  - Rakefile
156
+ - config/initializers/nil.rb
157
+ - config/initializers/string.rb
156
158
  - lib/ultra_markdown.rb
157
159
  - lib/ultra_markdown/engine.rb
158
160
  - lib/ultra_markdown/engine3.rb