ZMediumToMarkdown 1.7.0 → 1.7.3

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
  SHA256:
3
- metadata.gz: ff9b27bae7ac1365701ccb1b3174a8b7a2d3b7b2fa12771d10665368636c1733
4
- data.tar.gz: 0f68f9aca2a902694898560c82b689bc10b0e45d6c2d181b279002fb263f74d4
3
+ metadata.gz: 1a5c3a9b6f9ffba5bf008842145b31639e5e45aa3eebbd084cbe2a19ee767067
4
+ data.tar.gz: 1f3c8807c99ce9a4ad8be93a5290dcce4c4bd6c7ad402ee2b57e74d90dbb35ab
5
5
  SHA512:
6
- metadata.gz: a397b8860995b6fe0e7f4aea405c352d5ce05de20de0d9dc041001bc8af3c8509ac01387f5ea7ae5ecedc844ba41e70ade1ac6f6f58d4d9baca02cce0783c28d
7
- data.tar.gz: 532bcf53a46474d897bb27dcdfe3153dfd3103cc43de01a9588608776284ddb0f23f89e836797bf453469168c38ed041a1c63f1a607c0b16616bafd002df75f1
6
+ metadata.gz: 8eae3e52d955759153ad325b67ef373980779ac29510aab7387a602ebed59b3c53b447f8a3b93d15678c0f0c9e2ef647213370f0c89358bbab5d5f4d20387bcb
7
+ data.tar.gz: 70da035f2fef37e46c9261860de82594b67989769f02acbde9597a66848cec69872b12e88a17545f2bb731d7c8b1c04912e2140ba716726cb7fd827b998d2485
@@ -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, "Output")
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, "Output")
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[Medium 原文](#{postURL})"
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
@@ -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.downcase}\n#{gistRAW}\n```"
70
+ result = "```#{lang}\n#{gistRAW}\n```"
68
71
  end
69
72
  end
70
73
  end
@@ -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
- userPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "users/#{username}")
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, userPathPolicy)
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2022-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri