writetheman 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -1
- data/lib/writetheman/article/content.rb +1 -1
- data/lib/writetheman/article/utils.rb +9 -1
- data/lib/writetheman/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -49,9 +49,14 @@ Read an article file
|
|
49
49
|
|
50
50
|
article.load_from_file(filename)
|
51
51
|
OR article.load_from_title(title, date)
|
52
|
-
|
52
|
+
|
53
53
|
After loading it you have access to the article attributes
|
54
54
|
|
55
|
+
puts(article.title)
|
56
|
+
puts(article.tags)
|
57
|
+
puts(article.str_date)
|
58
|
+
puts(article.body)
|
59
|
+
|
55
60
|
List articles :
|
56
61
|
|
57
62
|
articles = blog.list_articles
|
@@ -75,7 +75,7 @@ module Writetheman
|
|
75
75
|
@header_params = init_header_params_from_content
|
76
76
|
raise "no header params from header \n#{@header}\nand content \n#{@all_content}" if @header_params.nil? || @header_params.empty?
|
77
77
|
@body = get_body_from_content
|
78
|
-
raise "no body from content \n#{@all_content}" if @body.nil? || @body.empty?
|
78
|
+
raise "no body from content \n#{@all_content}" if @body.nil? # || @body.empty?
|
79
79
|
end
|
80
80
|
|
81
81
|
def get_body_from_content
|
@@ -19,13 +19,21 @@ module Writetheman
|
|
19
19
|
|
20
20
|
def self.special_encoding(content)
|
21
21
|
content = encoding_from_windows(content)
|
22
|
-
content
|
22
|
+
content = format_readable_html(content)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.format_content_from_file(content)
|
26
26
|
content = special_encoding(content.force_encoding('utf-8')).gsub("\r", "")
|
27
27
|
end
|
28
28
|
|
29
|
+
def self.format_readable_html(content)
|
30
|
+
content.gsub("<br><h2>", "<h2>").gsub("<div><br></div><h1>", "<h1>")
|
31
|
+
.gsub("><div>", "> \n<div>").gsub("</div><", "</div> \n<")
|
32
|
+
.gsub("><br>", "> \n<br> \n").gsub(".<br>", ". \n<br> \n")
|
33
|
+
.gsub("<br></h1>", "</h1>").gsub("<br></h2>", "</h2>")
|
34
|
+
.gsub(" ", " ")
|
35
|
+
end
|
36
|
+
|
29
37
|
def self.regex_body_from_content(content)
|
30
38
|
content = format_content_from_file(content)
|
31
39
|
content.match(/$(\n---\n)\s*$(.*)/ms).to_s.gsub("\n---\n", "")
|
data/lib/writetheman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: writetheman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|