ZMediumToMarkdown 1.9.3 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Parsers/LinkParser.rb +17 -5
- data/lib/ZMediumFetcher.rb +5 -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: 4d35b81935c45082bfc47c94cb990ceffb37292c4b2d535a384451341196dc37
|
4
|
+
data.tar.gz: 85817b58a2acda2a7ede68e87e29e0adb73d7bc2e8e90b1623f30886c978a346
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab2b7cf2f122a8458dfcee583b992e5f928d42b38fb1948c5d1204258e476106dc4b3c0097819b02ceb98a917bfffa6c4edc6bd304196d10c488bd04e7ee49f8
|
7
|
+
data.tar.gz: 4153f9e6403d7877713693f238dc6752e1c53fb20f3279b1de220c8e09ab03c462c0118f4a0ff72902262c2a462eef8bbcb91f5b165806a11cb3f716f0b1aa27
|
data/lib/Parsers/LinkParser.rb
CHANGED
@@ -5,9 +5,9 @@ require 'Models/Paragraph'
|
|
5
5
|
class LinkParser
|
6
6
|
attr_accessor :usersPostURLs, :isForJekyll
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@usersPostURLs =
|
10
|
-
@isForJekyll =
|
8
|
+
def initialize()
|
9
|
+
@usersPostURLs = nil
|
10
|
+
@isForJekyll = false
|
11
11
|
end
|
12
12
|
|
13
13
|
def parse(markdownString, markupLinks)
|
@@ -17,6 +17,14 @@ class LinkParser
|
|
17
17
|
|
18
18
|
matchLinks.each do |matchLink|
|
19
19
|
link = matchLink[0]
|
20
|
+
linkMarkdown = "(#{link})"
|
21
|
+
newLinkMarkdown = linkMarkdown
|
22
|
+
|
23
|
+
if isForJekyll
|
24
|
+
newLinkMarkdown = "(#{link}){:target=\"_blank\"}"
|
25
|
+
puts newLinkMarkdown
|
26
|
+
end
|
27
|
+
|
20
28
|
|
21
29
|
if !usersPostURLs.nil?
|
22
30
|
# if have provide user's post urls
|
@@ -30,12 +38,16 @@ class LinkParser
|
|
30
38
|
|
31
39
|
if !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == postPath.split("-").last }.nil?
|
32
40
|
if isForJekyll
|
33
|
-
|
41
|
+
newLinkMarkdown = "(../#{postPath})"
|
34
42
|
else
|
35
|
-
|
43
|
+
newLinkMarkdown = "(#{postPath})"
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
47
|
+
|
48
|
+
if linkMarkdown != newLinkMarkdown
|
49
|
+
markdownString = markdownString.sub! linkMarkdown, newLinkMarkdown
|
50
|
+
end
|
39
51
|
end
|
40
52
|
end
|
41
53
|
end
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -71,7 +71,7 @@ class ZMediumFetcher
|
|
71
71
|
|
72
72
|
def initialize
|
73
73
|
@progress = Progress.new()
|
74
|
-
@linkParser = LinkParser.new(
|
74
|
+
@linkParser = LinkParser.new()
|
75
75
|
@isForJekyll = false
|
76
76
|
end
|
77
77
|
|
@@ -223,6 +223,8 @@ class ZMediumFetcher
|
|
223
223
|
progress.message = "Converting Post..."
|
224
224
|
progress.printLog()
|
225
225
|
|
226
|
+
linkParser.isForJekyll = isForJekyll
|
227
|
+
|
226
228
|
postWithDatePath = "#{postInfo.firstPublishedAt.strftime("%Y-%m-%d")}-#{postPath}"
|
227
229
|
|
228
230
|
absolutePath = postPathPolicy.getAbsolutePath("#{postWithDatePath}.md")
|
@@ -248,10 +250,7 @@ class ZMediumFetcher
|
|
248
250
|
end
|
249
251
|
|
250
252
|
result = startParser.parse(paragraph)
|
251
|
-
|
252
|
-
if !linkParser.nil?
|
253
|
-
result = linkParser.parse(result, paragraph.markupLinks)
|
254
|
-
end
|
253
|
+
result = linkParser.parse(result, paragraph.markupLinks)
|
255
254
|
|
256
255
|
file.puts(result)
|
257
256
|
|
@@ -295,7 +294,7 @@ class ZMediumFetcher
|
|
295
294
|
nextID = postPageInfo["nextID"]
|
296
295
|
end while !nextID.nil?
|
297
296
|
|
298
|
-
|
297
|
+
linkParser.usersPostURLs = postURLS
|
299
298
|
|
300
299
|
progress.totalPostsLength = postURLS.length
|
301
300
|
progress.currentPostIndex = 0
|
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.9.
|
4
|
+
version: 1.9.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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|