ZMediumToMarkdown 2.0.1 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c410145d7924db7410198b57030d8a886b81162d2dc0f63c580d9140131aaae3
4
- data.tar.gz: 91930b43c92725becb2d6f2e2246a4df6c2bed1d7616cd4f6dfb11cafa0d3af3
3
+ metadata.gz: e5ce4efab5975e6c870bacec7f2a480bbf0f938dfdaa9fe6f050e0c99254f646
4
+ data.tar.gz: c6bd9f40a681d5f75213604bdbf4e1678d78401e2403d0808cbfe9cb748d554c
5
5
  SHA512:
6
- metadata.gz: b23e795f4af879ad6902dcf7a842cb0f1ad160e722196b1e8e4b17bb404686ac0f9fb3801b396124e4f248beb4743c1c56787bf5ef17fecb1b662f880983ce74
7
- data.tar.gz: 9fa9954456a922437b624e2b4a762b509e5fac44ba453ca947b87ab838ad0110fd005cb628e9ae8042d2ddf60f0b850e92a08a8a9a148c0a00e8c30c77326670
6
+ metadata.gz: 2e221e9785da97d866daa114ca1dee36b9ad94f89434b2b88dc8b8ea34f3c2fbd50e85fcac1046a272f518da89ac6534d3b3975bb9513a8f05ee9195b2c623bb
7
+ data.tar.gz: 9710e3fdb0076085770f516865dd7c30fdcd0ddcc6240521516025f53c66993cf49c9972637230dfd02b52a16d75cf7d5ddeeeb972fd86330ad028b8d210d4ec
@@ -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
@@ -175,7 +175,11 @@ class MarkupStyleRender
175
175
  elsif markup.type == "STRONG"
176
176
  tag = TagChar.new(2, markup.start, markup.end, "**", "**")
177
177
  elsif markup.type == "ESCAPE"
178
- tag = TagChar.new(2, markup.start, markup.end, "\\", "**")
178
+ escapeTagChar = TagChar.new(0,markup.start, markup.end,'','')
179
+ escapeTagChar.startChars = TextChar.new('\\'.chars,'Text')
180
+ escapeTagChar.endChars = TextChar.new([],'Text')
181
+
182
+ tag = escapeTagChar
179
183
  elsif markup.type == "A"
180
184
  url = markup.href
181
185
  if markup.anchorType == "LINK"
@@ -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.1
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ZhgChgLi