ZMediumToMarkdown 1.9.4 → 1.9.7

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: 4d35b81935c45082bfc47c94cb990ceffb37292c4b2d535a384451341196dc37
4
- data.tar.gz: 85817b58a2acda2a7ede68e87e29e0adb73d7bc2e8e90b1623f30886c978a346
3
+ metadata.gz: 521c7a377c1e9b93996dc31355a8e7d6afb90708d154f69e31f4f20675bed060
4
+ data.tar.gz: 396d663eaf2f302168dde595842f092bd0051094baf2cbf4974018c0b2aaf270
5
5
  SHA512:
6
- metadata.gz: ab2b7cf2f122a8458dfcee583b992e5f928d42b38fb1948c5d1204258e476106dc4b3c0097819b02ceb98a917bfffa6c4edc6bd304196d10c488bd04e7ee49f8
7
- data.tar.gz: 4153f9e6403d7877713693f238dc6752e1c53fb20f3279b1de220c8e09ab03c462c0118f4a0ff72902262c2a462eef8bbcb91f5b165806a11cb3f716f0b1aa27
6
+ metadata.gz: 57d8f51c5fe1fa5d193e0cdd1e7d11152a5010520867e54966681d064d0f30a7d81b57fb389c765ed8c522f896b4fad4e5ddb3bff9d58f6ae4687172cc381cfd
7
+ data.tar.gz: 9c5dfe1ff916f9f9d6c288c3537fd9b542a664959f34101f573f66dd0ce2655611b930fb78396a7392c1998b8ae2c52bee9276e1250c40861ad7a97f2dce0809
@@ -65,7 +65,6 @@ class Main
65
65
 
66
66
  opts.on('-v', '--version', 'Print current ZMediumToMarkdown Version & Output Path') do
67
67
  puts "Version:#{Helper.getLocalVersion().to_s}"
68
- puts "Output Path:#{outputFilePath.getAbsolutePath(nil)}"
69
68
 
70
69
  Helper.printNewVersionMessageIfExists()
71
70
  end
data/lib/Helper.rb CHANGED
@@ -109,6 +109,8 @@ class Helper
109
109
  result += "date: #{postInfo.firstPublishedAt.strftime('%Y-%m-%dT%H:%M:%S.%LZ')}\n"
110
110
  result += "categories: #{postInfo.collectionName}\n"
111
111
  result += "tags: [#{postInfo.tags.join(",")}]\n"
112
+ result += "description: #{postInfo.description}\n"
113
+ result += "render_with_liquid: false\n"
112
114
  result += "---\n"
113
115
  result += "\r\n"
114
116
 
@@ -4,7 +4,11 @@ require "Parsers/Parser"
4
4
  require 'Models/Paragraph'
5
5
 
6
6
  class CodeBlockParser < Parser
7
- attr_accessor :nextParser
7
+ attr_accessor :nextParser, :isForJekyll
8
+
9
+ def initialize(isForJekyll)
10
+ @isForJekyll = isForJekyll
11
+ end
8
12
 
9
13
  def self.getTypeString()
10
14
  'CODE_BLOCK'
@@ -20,7 +24,11 @@ class CodeBlockParser < Parser
20
24
 
21
25
  def parse(paragraph)
22
26
  if CodeBlockParser.isCodeBlock(paragraph)
23
- "```\n#{paragraph.text}\n```"
27
+ result = "```\n"
28
+
29
+ result += paragraph.text.chomp
30
+
31
+ result += "\n```"
24
32
  else
25
33
  if !nextParser.nil?
26
34
  nextParser.parse(paragraph)
@@ -74,7 +74,12 @@ class IframeParser < Parser
74
74
  gistHTML.search('a').each do |a|
75
75
  if a.text == 'view raw'
76
76
  gistRAW = Request.body(Request.URL(a['href']))
77
- result = "```#{lang}\n#{gistRAW}\n```"
77
+
78
+ result = "```#{lang}\n"
79
+
80
+ result += gistRAW.chomp
81
+
82
+ result += "\n```"
78
83
  end
79
84
  end
80
85
  else
@@ -22,7 +22,6 @@ class LinkParser
22
22
 
23
23
  if isForJekyll
24
24
  newLinkMarkdown = "(#{link}){:target=\"_blank\"}"
25
- puts newLinkMarkdown
26
25
  end
27
26
 
28
27
 
@@ -4,7 +4,11 @@ require "Parsers/Parser"
4
4
  require 'Models/Paragraph'
5
5
 
6
6
  class PREParser < Parser
7
- attr_accessor :nextParser
7
+ attr_accessor :nextParser, :isForJekyll
8
+
9
+ def initialize(isForJekyll)
10
+ @isForJekyll = isForJekyll
11
+ end
8
12
 
9
13
  def self.isPRE(paragraph)
10
14
  if paragraph.nil?
@@ -17,10 +21,14 @@ class PREParser < Parser
17
21
  def parse(paragraph)
18
22
  if PREParser.isPRE(paragraph)
19
23
  result = "```\n"
24
+
20
25
  paragraph.text.each_line do |p|
21
26
  result += p
22
27
  end
28
+
29
+ result = result.chomp
23
30
  result += "\n```"
31
+
24
32
  result
25
33
  else
26
34
  if !nextParser.nil?
data/lib/Post.rb CHANGED
@@ -9,7 +9,7 @@ require 'date'
9
9
  class Post
10
10
 
11
11
  class PostInfo
12
- attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :collectionName
12
+ attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :collectionName, :description
13
13
  end
14
14
 
15
15
  def self.getPostIDFromPostURLString(postURLString)
@@ -60,6 +60,7 @@ class Post
60
60
 
61
61
  def self.parsePostInfoFromPostContent(content, postID)
62
62
  postInfo = PostInfo.new()
63
+ postInfo.description = content&.dig("Post:#{postID}", "previewContent", "subtitle")
63
64
  postInfo.title = content&.dig("Post:#{postID}", "title")
64
65
  postInfo.tags = content&.dig("Post:#{postID}", "tags").map{ |tag| tag["__ref"].gsub! 'Tag:', '' }
65
66
 
@@ -50,9 +50,9 @@ class ZMediumFetcher
50
50
  info += "-"
51
51
  end
52
52
  if !currentPostParagraphIndex.nil? && !totalPostParagraphsLength.nil?
53
- info += "[#{postPath[0..10]}...(#{currentPostParagraphIndex}/#{totalPostParagraphsLength})]"
53
+ info += "[#{postPath[0..15]}...(#{currentPostParagraphIndex}/#{totalPostParagraphsLength})]"
54
54
  else
55
- info += "[#{postPath[0..10]}...]"
55
+ info += "[#{postPath[0..15]}...]"
56
56
  end
57
57
  end
58
58
 
@@ -101,9 +101,9 @@ class ZMediumFetcher
101
101
  iframeParser.setNext(imgParser)
102
102
  bqParser = BQParser.new()
103
103
  imgParser.setNext(bqParser)
104
- preParser = PREParser.new()
104
+ preParser = PREParser.new(isForJekyll)
105
105
  bqParser.setNext(preParser)
106
- codeBlockParser = CodeBlockParser.new()
106
+ codeBlockParser = CodeBlockParser.new(isForJekyll)
107
107
  preParser.setNext(codeBlockParser)
108
108
  fallbackParser = FallbackParser.new()
109
109
  codeBlockParser.setNext(fallbackParser)
@@ -230,7 +230,7 @@ class ZMediumFetcher
230
230
  absolutePath = postPathPolicy.getAbsolutePath("#{postWithDatePath}.md")
231
231
 
232
232
  # if markdown file is exists and last modification time is >= latestPublishedAt(last update post time on medium)
233
- if File.file?(absolutePath) && File.mtime(absolutePath) >= postInfo.latestPublishedAt
233
+ if File.file?(absolutePath) && File.mtime(absolutePath).to_time.to_i >= postInfo.latestPublishedAt.to_i
234
234
  # Already downloaded and nothing has changed!, Skip!
235
235
  progress.currentPostParagraphIndex = paragraphs.length
236
236
  progress.message = "Skip, Post already downloaded and nothing has changed!"
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.9.4
4
+ version: 1.9.7
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-21 00:00:00.000000000 Z
11
+ date: 2022-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri