ZMediumToMarkdown 2.0.1 → 2.0.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/lib/Parsers/LinkParser.rb +25 -27
- data/lib/Parsers/MarkupStyleRender.rb +5 -1
- data/lib/ZMediumFetcher.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5ce4efab5975e6c870bacec7f2a480bbf0f938dfdaa9fe6f050e0c99254f646
|
4
|
+
data.tar.gz: c6bd9f40a681d5f75213604bdbf4e1678d78401e2403d0808cbfe9cb748d554c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e221e9785da97d866daa114ca1dee36b9ad94f89434b2b88dc8b8ea34f3c2fbd50e85fcac1046a272f518da89ac6534d3b3975bb9513a8f05ee9195b2c623bb
|
7
|
+
data.tar.gz: 9710e3fdb0076085770f516865dd7c30fdcd0ddcc6240521516025f53c66993cf49c9972637230dfd02b52a16d75cf7d5ddeeeb972fd86330ad028b8d210d4ec
|
data/lib/Parsers/LinkParser.rb
CHANGED
@@ -10,43 +10,41 @@ class LinkParser
|
|
10
10
|
@isForJekyll = false
|
11
11
|
end
|
12
12
|
|
13
|
-
def parse(markdownString
|
14
|
-
|
15
|
-
|
16
|
-
if !matchLinks.nil?
|
13
|
+
def parse(markdownString)
|
14
|
+
matchLinks = markdownString.scan(/\[[^\]]*\]\(([^\)]*)\)/m)
|
15
|
+
if !matchLinks.nil?
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
-
|
39
|
+
newLinkMarkdown = "(../#{postPath}/)"
|
34
40
|
else
|
35
|
-
|
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
|
-
|
48
|
-
|
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
|
-
|
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"
|
data/lib/ZMediumFetcher.rb
CHANGED