ZMediumToMarkdown 1.7.1 → 1.7.4
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 +4 -4
- data/bin/ZMediumToMarkdown +9 -1
- data/lib/Parsers/IMGParser.rb +12 -5
- data/lib/Parsers/IframeParser.rb +5 -2
- data/lib/Parsers/PQParser.rb +3 -1
- data/lib/ZMediumFetcher.rb +7 -2
- 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: 9f0456e760bcd742867a97de33738cefa1f58fadd03a2bcb3ec8488bd82a043b
|
4
|
+
data.tar.gz: ab014836dcc1216baed216ffc928a05eed8a368489284d1b13dfb9cb4156c8e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6fc090b46f1b20de4298762cef0e8c71f5eecd9ee672db669ac6392d617c4e259668e199666be92d4514967210c1e3e6500d843467d3588b8de19dec0333488
|
7
|
+
data.tar.gz: ea38435d80577a2c253b93f49aec296ea4e4b9eed2220b0f0b3695dfb1ba3bc1f6869ba35bb1b254bea47f2e350c42be30744a471814dadb011738efb8618aa9
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -40,7 +40,15 @@ class Main
|
|
40
40
|
Helper.printNewVersionMessageIfExists()
|
41
41
|
end
|
42
42
|
|
43
|
-
opts.on('-
|
43
|
+
opts.on('-kPOST_URL', '--jekyllPostURL=POST_URL', 'Downloading single post with Jekyll friendly') do |postURL|
|
44
|
+
outputFilePath = PathPolicy.new(filePath, "/")
|
45
|
+
fetcher.isForJekyll = true
|
46
|
+
fetcher.downloadPost(postURL, outputFilePath)
|
47
|
+
|
48
|
+
Helper.printNewVersionMessageIfExists()
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on('-cPOST_URL', '--jekyllPostURL=POST_URL', 'Downloading single post with Jekyll friendly') do |postURL|
|
44
52
|
outputFilePath = PathPolicy.new(filePath, "/")
|
45
53
|
fetcher.isForJekyll = true
|
46
54
|
fetcher.downloadPost(postURL, outputFilePath)
|
data/lib/Parsers/IMGParser.rb
CHANGED
@@ -23,21 +23,28 @@ class IMGParser < Parser
|
|
23
23
|
imagePathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), paragraph.postID)
|
24
24
|
absolutePath = imagePathPolicy.getAbsolutePath(fileName)
|
25
25
|
|
26
|
+
result = ""
|
26
27
|
comment = ""
|
27
|
-
if paragraph.
|
28
|
-
comment = " \"#{paragraph.
|
28
|
+
if paragraph.orgText != ""
|
29
|
+
comment = " \"#{paragraph.orgText}\""
|
29
30
|
end
|
30
31
|
|
31
32
|
if ImageDownloader.download(absolutePath, imageURL)
|
32
33
|
relativePath = "#{pathPolicy.getRelativePath(nil)}/#{imagePathPolicy.getRelativePath(fileName)}"
|
33
34
|
if isForJekyll
|
34
|
-
"\r\n\r\n"
|
35
|
+
result = "\r\n\r\n"
|
35
36
|
else
|
36
|
-
"\r\n\r\n"
|
37
|
+
result = "\r\n\r\n"
|
37
38
|
end
|
38
39
|
else
|
39
|
-
"\r\n\r\n"
|
40
|
+
result = "\r\n\r\n"
|
40
41
|
end
|
42
|
+
|
43
|
+
if paragraph.text != ""
|
44
|
+
result += "#{paragraph.text}\r\n"
|
45
|
+
end
|
46
|
+
|
47
|
+
result
|
41
48
|
else
|
42
49
|
if !nextParser.nil?
|
43
50
|
nextParser.parse(paragraph)
|
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/Parsers/PQParser.rb
CHANGED
@@ -7,10 +7,12 @@ class PQParser < Parser
|
|
7
7
|
attr_accessor :nextParser
|
8
8
|
def parse(paragraph)
|
9
9
|
if paragraph.type == 'PQ'
|
10
|
-
result = ""
|
10
|
+
result = "\r\n\r\n"
|
11
11
|
paragraph.text.each_line do |p|
|
12
12
|
result += "> #{p}"
|
13
13
|
end
|
14
|
+
result += "\r\n\r\n"
|
15
|
+
|
14
16
|
result
|
15
17
|
else
|
16
18
|
if !nextParser.nil?
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -303,10 +303,15 @@ class ZMediumFetcher
|
|
303
303
|
progress.message = "Downloading posts..."
|
304
304
|
progress.printLog()
|
305
305
|
|
306
|
-
|
306
|
+
if isForJekyll
|
307
|
+
downloadPathPolicy = pathPolicy
|
308
|
+
else
|
309
|
+
downloadPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "users/#{username}")
|
310
|
+
end
|
311
|
+
|
307
312
|
index = 0
|
308
313
|
postURLS.each do |postURL|
|
309
|
-
downloadPost(postURL,
|
314
|
+
downloadPost(postURL, downloadPathPolicy)
|
310
315
|
|
311
316
|
index += 1
|
312
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.4
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|