ZMediumToMarkdown 2.0.2 → 2.0.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: 9d5d59f757813210f3d5d98025ab4bcbb79eaf99c7a8f75d9540854fc7aa7093
4
- data.tar.gz: ab7fcd5f9d8588697bc59bd4f26b0a334d69b4e9f21325425e144f53c7a9f38b
3
+ metadata.gz: 2c6540c31739d0b7673b180fa73887641933b08f431346a7aa77e89c5188acb6
4
+ data.tar.gz: 9cd571bc32f08011d136d6814fadf8afb3ab3bc1251ea1476bc0144b30fc4461
5
5
  SHA512:
6
- metadata.gz: 9d8913a1d4b741a30e4496513fa5c7e6cd0b80b495eb2b62a22eeee4f2e66cdb5873f5b886de1200dff62d2bb1dc175f15312999e7bc28f56fd0cffd361be9cd
7
- data.tar.gz: 42dca718b61f52b20424edf8de42a0c9936f39adfdb0392efcc4990cc53df1b4534650d6cb5d48f6945e4d513a39a39657132682dce242d44a897686c5c39503
6
+ metadata.gz: 57162ffcec3607c5fdb654b984593eef97a6badbd1e3ebb8e11bb8be2ea1b7301f17aa51d93fa6d864a2db58bfbb45ceda6b3cade25a2ca633a5eb90d08c5240
7
+ data.tar.gz: 862072b9c0d384bf1a45f02590b5a0f9286d96ad480b8874670f067e56fc5c66b9c2c33e62f24d799871459504cb807e705d7876576c56f5e9317e80caa0a145
@@ -10,43 +10,41 @@ class LinkParser
10
10
  @isForJekyll = false
11
11
  end
12
12
 
13
- def parse(markdownString, markupLinks)
14
- if !markupLinks.nil?
15
- matchLinks = markdownString.scan(/\[[^\]]*\]\(([^\)]*)\)/)
16
- if !matchLinks.nil?
13
+ def parse(markdownString)
14
+ matchLinks = markdownString.scan(/\[[^\]]*\]\(([^\)]*)\)/m)
15
+ if !matchLinks.nil?
17
16
 
18
- matchLinks.each do |matchLink|
19
- link = matchLink[0]
20
- linkMarkdown = "(#{link})"
21
- newLinkMarkdown = linkMarkdown
17
+ matchLinks.each do |matchLink|
18
+ link = matchLink[0]
19
+ linkMarkdown = "(#{link})"
20
+ newLinkMarkdown = linkMarkdown
21
+
22
+ if isForJekyll
23
+ newLinkMarkdown = "(#{link}){:target=\"_blank\"}"
24
+ end
25
+
26
+
27
+ if !usersPostURLs.nil?
28
+ # if have provide user's post urls
29
+ # find & replace medium url to local post url if matched
22
30
 
23
31
  if isForJekyll
24
- newLinkMarkdown = "(#{link}){:target=\"_blank\"}"
32
+ postPath = link.split("/").last.split("-").last
33
+ else
34
+ postPath = link.split("/").last
25
35
  end
26
36
 
27
-
28
- if !usersPostURLs.nil?
29
- # if have provide user's post urls
30
- # find & replace medium url to local post url if matched
31
-
37
+ if !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == postPath.split("-").last }.nil?
32
38
  if isForJekyll
33
- postPath = link.split("/").last.split("-").last
39
+ newLinkMarkdown = "(../#{postPath})"
34
40
  else
35
- postPath = link.split("/").last
36
- end
37
-
38
- if !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == postPath.split("-").last }.nil?
39
- if isForJekyll
40
- newLinkMarkdown = "(../#{postPath})"
41
- else
42
- newLinkMarkdown = "(#{postPath})"
43
- end
41
+ newLinkMarkdown = "(#{postPath})"
44
42
  end
45
43
  end
44
+ end
46
45
 
47
- if linkMarkdown != newLinkMarkdown
48
- markdownString = markdownString.sub! linkMarkdown, newLinkMarkdown
49
- end
46
+ if linkMarkdown != newLinkMarkdown
47
+ markdownString = markdownString.sub! linkMarkdown, newLinkMarkdown
50
48
  end
51
49
  end
52
50
  end
@@ -236,7 +236,7 @@ class ZMediumFetcher
236
236
  if lines.first.start_with?("---")
237
237
  dateLine = lines.select { |line| line.start_with?("last_modified_at:") }.first
238
238
  if !dateLine.nil?
239
- #fileLatestPublishedAt = Time.parse(dateLine[/^(last_modified_at:)\s+(\S*)/, 2]).to_i
239
+ fileLatestPublishedAt = Time.parse(dateLine[/^(last_modified_at:)\s+(\S*)/, 2]).to_i
240
240
  end
241
241
  end
242
242
  end
@@ -264,7 +264,7 @@ class ZMediumFetcher
264
264
  end
265
265
 
266
266
  result = startParser.parse(paragraph)
267
- result = linkParser.parse(result, paragraph.markupLinks)
267
+ result = linkParser.parse(result)
268
268
 
269
269
  file.puts(result)
270
270
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ZMediumToMarkdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ZhgChgLi