ZMediumToMarkdown 1.7.0 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ZMediumToMarkdown +4 -4
- data/lib/Helper.rb +12 -2
- data/lib/Parsers/IframeParser.rb +5 -2
- data/lib/ZMediumFetcher.rb +7 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a5c3a9b6f9ffba5bf008842145b31639e5e45aa3eebbd084cbe2a19ee767067
|
4
|
+
data.tar.gz: 1f3c8807c99ce9a4ad8be93a5290dcce4c4bd6c7ad402ee2b57e74d90dbb35ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eae3e52d955759153ad325b67ef373980779ac29510aab7387a602ebed59b3c53b447f8a3b93d15678c0f0c9e2ef647213370f0c89358bbab5d5f4d20387bcb
|
7
|
+
data.tar.gz: 70da035f2fef37e46c9261860de82594b67989769f02acbde9597a66848cec69872b12e88a17545f2bb731d7c8b1c04912e2140ba716726cb7fd827b998d2485
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -19,21 +19,21 @@ class Main
|
|
19
19
|
opts.banner = "Usage: ZMediumFetcher [options]"
|
20
20
|
|
21
21
|
opts.on('-uUSERNAME', '--username=USERNAME', 'Downloading all posts from user') do |username|
|
22
|
-
outputFilePath = PathPolicy.new(filePath, "
|
22
|
+
outputFilePath = PathPolicy.new(filePath, "Output")
|
23
23
|
fetcher.downloadPostsByUsername(username, outputFilePath)
|
24
24
|
|
25
25
|
Helper.printNewVersionMessageIfExists()
|
26
26
|
end
|
27
27
|
|
28
28
|
opts.on('-pPOST_URL', '--postURL=POST_URL', 'Downloading single post') do |postURL|
|
29
|
-
outputFilePath = PathPolicy.new(filePath, "
|
29
|
+
outputFilePath = PathPolicy.new(filePath, "Output")
|
30
30
|
fetcher.downloadPost(postURL, outputFilePath)
|
31
31
|
|
32
32
|
Helper.printNewVersionMessageIfExists()
|
33
33
|
end
|
34
34
|
|
35
35
|
opts.on('-jUSERNAME', '--jekyllUsername=USERNAME', 'Downloading all posts from user with Jekyll friendly') do |username|
|
36
|
-
outputFilePath = PathPolicy.new(filePath, "
|
36
|
+
outputFilePath = PathPolicy.new(filePath, "/")
|
37
37
|
fetcher.isForJekyll = true
|
38
38
|
fetcher.downloadPostsByUsername(username, outputFilePath)
|
39
39
|
|
@@ -41,7 +41,7 @@ class Main
|
|
41
41
|
end
|
42
42
|
|
43
43
|
opts.on('-kpPOST_URL', '--jekyllPostURL=POST_URL', 'Downloading single post with Jekyll friendly') do |postURL|
|
44
|
-
outputFilePath = PathPolicy.new(filePath, "
|
44
|
+
outputFilePath = PathPolicy.new(filePath, "/")
|
45
45
|
fetcher.isForJekyll = true
|
46
46
|
fetcher.downloadPost(postURL, outputFilePath)
|
47
47
|
|
data/lib/Helper.rb
CHANGED
@@ -159,7 +159,17 @@ class Helper
|
|
159
159
|
end
|
160
160
|
|
161
161
|
|
162
|
-
def self.createWatermark(postURL)
|
163
|
-
text = "\r\n
|
162
|
+
def self.createWatermark(postURL)
|
163
|
+
text = "\r\n\r\n\r\n"
|
164
|
+
text += "+-----------------------------------------------------------------------------------+"
|
165
|
+
text += "\r\n"
|
166
|
+
text += "\r\n"
|
167
|
+
text += "| **[View original post on Medium](#{postURL}) - Converted by [ZhgChgLi](https://zhgchg.li)/[ZMediumToMarkdown](https://github.com/ZhgChgLi/ZMediumToMarkdown)** |"
|
168
|
+
text += "\r\n"
|
169
|
+
text += "\r\n"
|
170
|
+
text += "+-----------------------------------------------------------------------------------+"
|
171
|
+
text += "\r\n"
|
172
|
+
|
173
|
+
text
|
164
174
|
end
|
165
175
|
end
|
data/lib/Parsers/IframeParser.rb
CHANGED
@@ -60,11 +60,14 @@ class IframeParser < Parser
|
|
60
60
|
gist.gsub! '\"', '"'
|
61
61
|
gist.gsub! '<\/', '</'
|
62
62
|
gistHTML = Nokogiri::HTML(gist)
|
63
|
-
lang = gistHTML.search('table').first['data-tagsearch-lang']
|
63
|
+
lang = gistHTML.search('table').first['data-tagsearch-lang'].downcase
|
64
|
+
if isForJekyll and lang == "objective-c"
|
65
|
+
lang = "objectivec"
|
66
|
+
end
|
64
67
|
gistHTML.search('a').each do |a|
|
65
68
|
if a.text == 'view raw'
|
66
69
|
gistRAW = Request.body(Request.URL(a['href']))
|
67
|
-
result = "```#{lang
|
70
|
+
result = "```#{lang}\n#{gistRAW}\n```"
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -253,10 +253,6 @@ class ZMediumFetcher
|
|
253
253
|
if !linkParser.nil?
|
254
254
|
result = linkParser.parse(result, paragraph.markupLinks)
|
255
255
|
end
|
256
|
-
|
257
|
-
if paragraph.orgText == "延伸閱讀" or result.include? "Like Z Realm" or paragraph.orgText == "有任何問題及指教歡迎與我聯絡。"
|
258
|
-
break
|
259
|
-
end
|
260
256
|
|
261
257
|
file.puts(result)
|
262
258
|
|
@@ -307,10 +303,15 @@ class ZMediumFetcher
|
|
307
303
|
progress.message = "Downloading posts..."
|
308
304
|
progress.printLog()
|
309
305
|
|
310
|
-
|
306
|
+
if isForJekyll
|
307
|
+
downloadPathPolicy = pathPolicy
|
308
|
+
else
|
309
|
+
downloadPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "users/#{username}")
|
310
|
+
end
|
311
|
+
|
311
312
|
index = 0
|
312
313
|
postURLS.each do |postURL|
|
313
|
-
downloadPost(postURL,
|
314
|
+
downloadPost(postURL, downloadPathPolicy)
|
314
315
|
|
315
316
|
index += 1
|
316
317
|
progress.currentPostIndex = index
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ZMediumToMarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZhgChgLi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|