ZMediumToMarkdown 1.6.1 → 1.6.2

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: 92b412153da4daf0a7594c1558a847412863405eec14da02325984a22bc855a8
4
- data.tar.gz: ccdf1c0e166323323f55b91fc0991b3eae1da0ad070e2b884b3b30266661c03b
3
+ metadata.gz: 57ebbd86d072c9c43a5baef02031561323e9e7f6857e639aecc754de5741c543
4
+ data.tar.gz: 03bde3f39434b21c7d96380d05dbc9ccc7096f30ab97aade0e6838165e28de3e
5
5
  SHA512:
6
- metadata.gz: 120c75b800992a2a815c058430326f6b279f52f08ba4484465fdf7eca31b8460f1170bdd30956c1bfd771a3fbb0d5763a21e9327530e80e76250d52551a4ec9f
7
- data.tar.gz: ffb13239eabe2a6f302a093dfea6309eaaaa3eee0ffb960ee9798f96969c922de6a287b3c8ac47aca1c8b4af2f51adcc52bdf2470e59f8cf12420338a03e019b
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://blog.zhgchg.li)/[ZMediumToMarkdown](https://github.com/ZhgChgLi/ZMediumToMarkdown)** |"
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 paragraph.type == CodeBlockParser.getTypeString()
22
+ if CodeBlockParser.isCodeBlock(paragraph)
15
23
  "```\n#{paragraph.text}\n```"
16
24
  else
17
25
  if !nextParser.nil?
@@ -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
@@ -231,8 +231,11 @@ class ZMediumFetcher
231
231
 
232
232
  index = 0
233
233
  paragraphs.each do |paragraph|
234
- markupParser = MarkupParser.new(paragraph)
235
- paragraph.text = markupParser.parse()
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.1
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-07 00:00:00.000000000 Z
11
+ date: 2022-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri