ZMediumToMarkdown 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Helper.rb +2 -2
- data/lib/Parsers/CodeBlockParser.rb +9 -1
- data/lib/Parsers/LinkParser.rb +1 -13
- data/lib/ZMediumFetcher.rb +5 -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: 57ebbd86d072c9c43a5baef02031561323e9e7f6857e639aecc754de5741c543
|
4
|
+
data.tar.gz: 03bde3f39434b21c7d96380d05dbc9ccc7096f30ab97aade0e6838165e28de3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d108f648afe9eb0f90231dc771e22fd6f3f15d820f6d19aa941d23b48b2416c672350b6353af85c58dd13ccc1c3faa194b55f622476d09ea8bc84cccff6ba6ac
|
7
|
+
data.tar.gz: e484a2d51bc9ec006dc5511e2586d29eaab102bf778a030240ee92941b4fdfd9a726fbc5542677af7dbd8bb192e6c5d162b30b8c8b5001d166d3561edabdb9ec
|
data/lib/Helper.rb
CHANGED
@@ -164,7 +164,7 @@ class Helper
|
|
164
164
|
text += "+-----------------------------------------------------------------------------------+"
|
165
165
|
text += "\r\n"
|
166
166
|
text += "\r\n"
|
167
|
-
text += "| **[View original post on Medium](#{postURL}) - Converted by [ZhgChgLi](https://
|
167
|
+
text += "| **[View original post on Medium](#{postURL}) - Converted by [ZhgChgLi](https://zhgchg.li)/[ZMediumToMarkdown](https://github.com/ZhgChgLi/ZMediumToMarkdown)** |"
|
168
168
|
text += "\r\n"
|
169
169
|
text += "\r\n"
|
170
170
|
text += "+-----------------------------------------------------------------------------------+"
|
@@ -172,4 +172,4 @@ class Helper
|
|
172
172
|
|
173
173
|
text
|
174
174
|
end
|
175
|
-
end
|
175
|
+
end
|
@@ -10,8 +10,16 @@ class CodeBlockParser < Parser
|
|
10
10
|
'CODE_BLOCK'
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.isCodeBlock(paragraph)
|
14
|
+
if paragraph.nil?
|
15
|
+
false
|
16
|
+
else
|
17
|
+
paragraph.type == CodeBlockParser.getTypeString()
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
def parse(paragraph)
|
14
|
-
if
|
22
|
+
if CodeBlockParser.isCodeBlock(paragraph)
|
15
23
|
"```\n#{paragraph.text}\n```"
|
16
24
|
else
|
17
25
|
if !nextParser.nil?
|
data/lib/Parsers/LinkParser.rb
CHANGED
@@ -23,19 +23,7 @@ class LinkParser
|
|
23
23
|
|
24
24
|
postPath = link.split("/").last
|
25
25
|
if !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == postPath.split("-").last }.nil?
|
26
|
-
markdownString = markdownString.sub! link, postPath
|
27
|
-
end
|
28
|
-
else
|
29
|
-
if !(link =~ /\A#{URI::regexp(['http', 'https'])}\z/)
|
30
|
-
# medium will give you an relative path if url is medium's post (due to we use html to markdown render)
|
31
|
-
# e.g. /zrealm-ios-dev/visitor-pattern-in-ios-swift-ba5773a7bfea
|
32
|
-
# it's not a vaild url
|
33
|
-
|
34
|
-
# fullfill url from markup attribute
|
35
|
-
match = markupLinks.find{ |markupLink| markupLink.include? link }
|
36
|
-
if !match.nil?
|
37
|
-
markdownString = markdownString.sub! link, match
|
38
|
-
end
|
26
|
+
markdownString = markdownString.sub! link, "../#{postPath}"
|
39
27
|
end
|
40
28
|
end
|
41
29
|
end
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -231,8 +231,11 @@ class ZMediumFetcher
|
|
231
231
|
|
232
232
|
index = 0
|
233
233
|
paragraphs.each do |paragraph|
|
234
|
-
|
235
|
-
|
234
|
+
if !(CodeBlockParser.isCodeBlock(paragraph) || PREParser.isPRE(paragraph))
|
235
|
+
markupParser = MarkupParser.new(paragraph)
|
236
|
+
paragraph.text = markupParser.parse()
|
237
|
+
end
|
238
|
+
|
236
239
|
result = startParser.parse(paragraph)
|
237
240
|
|
238
241
|
if !linkParser.nil?
|
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.6.
|
4
|
+
version: 1.6.2
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|